diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index 06a97355b..1a86eff46 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -1,6 +1,7 @@ #include "CollectionSystemManager.h" #include "guis/GuiInfoPopup.h" +#include "utils/StringUtil.h" #include "views/gamelist/IGameListView.h" #include "views/ViewController.h" #include "FileData.h" @@ -10,9 +11,7 @@ #include "SystemData.h" #include "ThemeData.h" #include "Util.h" -#include #include -#include #include #include #include @@ -351,26 +350,33 @@ bool CollectionSystemManager::isThemeCustomCollectionCompatible(std::vector systemsInUse = getSystemsFromConfig(); // get folders assigned to custom collections @@ -948,7 +954,7 @@ std::vector CollectionSystemManager::getCollectionsFromConfigFolder std::string filename = file.substr(configPath.string().size()); // need to confirm filename matches config format - if (boost::algorithm::ends_with(filename, ".cfg") && boost::algorithm::starts_with(filename, "custom-") && filename != "custom-.cfg") + if (filename != "custom-.cfg" && Utils::String::startsWith(filename, "custom-") && Utils::String::endsWith(filename, ".cfg")) { filename = filename.substr(7, filename.size()-11); systems.push_back(filename); diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 7417bb7d4..9ba6c082d 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -1,5 +1,6 @@ #include "FileData.h" +#include "utils/StringUtil.h" #include "utils/TimeUtil.h" #include "AudioManager.h" #include "CollectionSystemManager.h" @@ -11,7 +12,6 @@ #include "Util.h" #include "VolumeControl.h" #include "Window.h" -#include #include namespace fs = boost::filesystem; @@ -327,7 +327,7 @@ const std::string& CollectionFileData::getName() { if (mDirty) { mCollectionFileName = removeParenthesis(mSourceFileData->metadata.get("name")); - boost::trim(mCollectionFileName); + Utils::String::trim(mCollectionFileName); mCollectionFileName += " [" + strToUpper(mSourceFileData->getSystem()->getName()) + "]"; mDirty = false; } diff --git a/es-app/src/FileFilterIndex.cpp b/es-app/src/FileFilterIndex.cpp index bdef39946..1be1ca3f1 100644 --- a/es-app/src/FileFilterIndex.cpp +++ b/es-app/src/FileFilterIndex.cpp @@ -1,11 +1,11 @@ #include "FileFilterIndex.h" +#include "utils/StringUtil.h" #include "views/UIModeController.h" #include "FileData.h" #include "Log.h" #include "Settings.h" #include "Util.h" -#include #define UNKNOWN_LABEL "UNKNOWN" #define INCLUDE_UNKNOWN false; @@ -94,7 +94,7 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ case GENRE_FILTER: { key = strToUpper(game->metadata.get("genre")); - boost::trim(key); + Utils::String::trim(key); if (getSecondary && !key.empty()) { std::istringstream f(key); std::string newKey; @@ -121,7 +121,7 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ case PUBDEV_FILTER: { key = strToUpper(game->metadata.get("publisher")); - boost::trim(key); + Utils::String::trim(key); if ((getSecondary && !key.empty()) || (!getSecondary && key.empty())) key = strToUpper(game->metadata.get("developer")); @@ -173,7 +173,7 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ break; } } - boost::trim(key); + Utils::String::trim(key); if (key.empty() || (type == RATINGS_FILTER && key == "0 STARS")) { key = UNKNOWN_LABEL; } diff --git a/es-app/src/views/UIModeController.h b/es-app/src/views/UIModeController.h index 38760cb21..e26d68c2c 100644 --- a/es-app/src/views/UIModeController.h +++ b/es-app/src/views/UIModeController.h @@ -2,7 +2,6 @@ #ifndef ES_APP_VIEWS_UI_MODE_CONTROLLER_H #define ES_APP_VIEWS_UI_MODE_CONTROLLER_H -//#include "InputConfig.h" #include #include diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 625b1d8b7..6e4168497 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -6,7 +6,6 @@ #include "platform.h" #include "Settings.h" #include -#include #include std::vector ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } }; @@ -176,24 +175,24 @@ std::string resolvePath(const char* in, const fs::path& relative) std::map mVariables; -std::string &format_variables(const boost::xpressive::smatch &what) -{ - return mVariables[what[1].str()]; -} - std::string resolvePlaceholders(const char* in) { - if(!in || in[0] == '\0') - return std::string(in); - std::string inStr(in); - - using namespace boost::xpressive; - sregex rex = "${" >> (s1 = +('.' | _w)) >> '}'; - - std::string output = regex_replace(inStr, rex, format_variables); - return output; + if(inStr.empty()) + return inStr; + + const size_t variableBegin = inStr.find("${"); + const size_t variableEnd = inStr.find("}", variableBegin); + + if((variableBegin == std::string::npos) || (variableEnd == std::string::npos)) + return inStr; + + std::string prefix = inStr.substr(0, variableBegin); + std::string replace = inStr.substr(variableBegin + 2, variableEnd - (variableBegin + 2)); + std::string suffix = inStr.substr(variableEnd + 1); + + return prefix + mVariables[replace] + suffix; } ThemeData::ThemeData() diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index fb244e5ae..34e6a5c9d 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -4,8 +4,6 @@ #include "math/Vector2f.h" #include -#include -#include #include #include #include @@ -91,10 +89,33 @@ public: bool extra; std::string type; - std::map< std::string, boost::variant > properties; + struct Property + { + void operator= (const Vector2f& value) { v = value; } + void operator= (const std::string& value) { s = value; } + void operator= (const unsigned int& value) { i = value; } + void operator= (const float& value) { f = value; } + void operator= (const bool& value) { b = value; } + + Vector2f v; + std::string s; + unsigned int i; + float f; + bool b; + }; + + std::map< std::string, Property > properties; template - T get(const std::string& prop) const { return boost::get(properties.at(prop)); } + const T get(const std::string& prop) const + { + if( std::is_same::value) return *(const T*)&properties.at(prop).v; + else if(std::is_same::value) return *(const T*)&properties.at(prop).s; + else if(std::is_same::value) return *(const T*)&properties.at(prop).i; + else if(std::is_same::value) return *(const T*)&properties.at(prop).f; + else if(std::is_same::value) return *(const T*)&properties.at(prop).b; + return T(); + } inline bool has(const std::string& prop) const { return (properties.find(prop) != properties.cend()); } }; diff --git a/es-core/src/Util.cpp b/es-core/src/Util.cpp index 3a52d4843..ad2bec45f 100644 --- a/es-core/src/Util.cpp +++ b/es-core/src/Util.cpp @@ -1,8 +1,6 @@ #include "Util.h" #include "platform.h" -#include -#include #include namespace fs = boost::filesystem; @@ -248,8 +246,20 @@ std::vector commaStringToVector(std::string commaString) { // from a comma separated string, get a vector of strings std::vector strs; - boost::split(strs, commaString, boost::is_any_of(",")); - std::sort(strs.begin(), strs.end()); + size_t start = 0; + size_t comma = commaString.find(","); + strs.push_back(commaString.substr(start, comma)); + if(comma != std::string::npos) + { + start = comma + 1; + while((comma = commaString.find(",", start)) != std::string::npos) + { + strs.push_back(commaString.substr(start, comma - start)); + start = comma + 1; + } + strs.push_back(commaString.substr(start)); + std::sort(strs.begin(), strs.end()); + } return strs; } diff --git a/es-core/src/components/VideoPlayerComponent.cpp b/es-core/src/components/VideoPlayerComponent.cpp index dd2e950b6..64a67793f 100644 --- a/es-core/src/components/VideoPlayerComponent.cpp +++ b/es-core/src/components/VideoPlayerComponent.cpp @@ -1,9 +1,9 @@ #ifdef _RPI_ #include "components/VideoPlayerComponent.h" +#include "utils/StringUtil.h" #include "AudioManager.h" #include "Settings.h" -#include #include #include @@ -68,7 +68,7 @@ void VideoPlayerComponent::startVideo() mPlayingVideoPath = mVideoPath; // Disable AudioManager so video can play, in case we're requesting ALSA - if (boost::starts_with(Settings::getInstance()->getString("OMXAudioDev").c_str(), "alsa")) + if (Utils::String::startsWith(Settings::getInstance()->getString("OMXAudioDev").c_str(), "alsa")) { AudioManager::getInstance()->deinit(); } diff --git a/es-core/src/utils/StringUtil.cpp b/es-core/src/utils/StringUtil.cpp index 695695ab3..e1754e215 100644 --- a/es-core/src/utils/StringUtil.cpp +++ b/es-core/src/utils/StringUtil.cpp @@ -144,6 +144,18 @@ namespace Utils } // trim + bool startsWith(const std::string& _string, const std::string& _test) + { + return (_string.find(_test) == 0); + + } // startsWith + + bool endsWith(const std::string& _string, const std::string& _test) + { + return (_string.find(_test) == (_string.size() - _test.size())); + + } // endsWith + } // String:: } // Utils:: diff --git a/es-core/src/utils/StringUtil.h b/es-core/src/utils/StringUtil.h index 3649ae4d8..c745d82e4 100644 --- a/es-core/src/utils/StringUtil.h +++ b/es-core/src/utils/StringUtil.h @@ -14,6 +14,8 @@ namespace Utils size_t prevCursor (const std::string& _string, const size_t _cursor); size_t moveCursor (const std::string& _string, const size_t _cursor, const int _amount); std::string trim (const std::string& _path); + bool startsWith (const std::string& _string, const std::string& _test); + bool endsWith (const std::string& _string, const std::string& _test); } // Utils::String::