diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index 0b79e6b88..79cd155cd 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -11,7 +11,6 @@ #include "Settings.h" #include "SystemData.h" #include "ThemeData.h" -#include "Util.h" #include #include #include @@ -422,7 +421,7 @@ void CollectionSystemManager::setEditMode(std::string collectionName) // if it's bundled, this needs to be the bundle system mEditingCollectionSystemData = sysData; - GuiInfoPopup* s = new GuiInfoPopup(mWindow, "Editing the '" + strToUpper(collectionName) + "' Collection. Add/remove games with Y.", 10000); + GuiInfoPopup* s = new GuiInfoPopup(mWindow, "Editing the '" + Utils::String::toUpper(collectionName) + "' Collection. Add/remove games with Y.", 10000); mWindow->setInfoPopup(s); } @@ -509,11 +508,11 @@ bool CollectionSystemManager::toggleGameInCollection(FileData* file) } if (adding) { - s = new GuiInfoPopup(mWindow, "Added '" + Utils::String::removeParenthesis(name) + "' to '" + strToUpper(sysName) + "'", 4000); + s = new GuiInfoPopup(mWindow, "Added '" + Utils::String::removeParenthesis(name) + "' to '" + Utils::String::toUpper(sysName) + "'", 4000); } else { - s = new GuiInfoPopup(mWindow, "Removed '" + Utils::String::removeParenthesis(name) + "' from '" + strToUpper(sysName) + "'", 4000); + s = new GuiInfoPopup(mWindow, "Removed '" + Utils::String::removeParenthesis(name) + "' from '" + Utils::String::toUpper(sysName) + "'", 4000); } mWindow->setInfoPopup(s); return true; diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 399df7e81..035932bd4 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -10,7 +10,6 @@ #include "Log.h" #include "platform.h" #include "SystemData.h" -#include "Util.h" #include "VolumeControl.h" #include "Window.h" @@ -259,9 +258,9 @@ void FileData::launchGame(Window* window) const std::string basename = getPath().stem().string(); const std::string rom_raw = boost::filesystem::path(getPath()).make_preferred().string(); - command = strreplace(command, "%ROM%", rom); - command = strreplace(command, "%BASENAME%", basename); - command = strreplace(command, "%ROM_RAW%", rom_raw); + command = Utils::String::replace(command, "%ROM%", rom); + command = Utils::String::replace(command, "%BASENAME%", basename); + command = Utils::String::replace(command, "%ROM_RAW%", rom_raw); LOG(LogInfo) << " " << command; int exitCode = runSystemCommand(command); @@ -325,7 +324,7 @@ const std::string& CollectionFileData::getName() { if (mDirty) { mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name")); - mCollectionFileName += " [" + strToUpper(mSourceFileData->getSystem()->getName()) + "]"; + mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]"; mDirty = false; } return mCollectionFileName; diff --git a/es-app/src/FileFilterIndex.cpp b/es-app/src/FileFilterIndex.cpp index f10c1c659..b7998a52f 100644 --- a/es-app/src/FileFilterIndex.cpp +++ b/es-app/src/FileFilterIndex.cpp @@ -5,7 +5,6 @@ #include "FileData.h" #include "Log.h" #include "Settings.h" -#include "Util.h" #define UNKNOWN_LABEL "UNKNOWN" #define INCLUDE_UNKNOWN false; @@ -93,7 +92,7 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ { case GENRE_FILTER: { - key = strToUpper(game->metadata.get("genre")); + key = Utils::String::toUpper(game->metadata.get("genre")); key = Utils::String::trim(key); if (getSecondary && !key.empty()) { std::istringstream f(key); @@ -120,13 +119,13 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ } case PUBDEV_FILTER: { - key = strToUpper(game->metadata.get("publisher")); + key = Utils::String::toUpper(game->metadata.get("publisher")); key = Utils::String::trim(key); if ((getSecondary && !key.empty()) || (!getSecondary && key.empty())) - key = strToUpper(game->metadata.get("developer")); + key = Utils::String::toUpper(game->metadata.get("developer")); else - key = strToUpper(game->metadata.get("publisher")); + key = Utils::String::toUpper(game->metadata.get("publisher")); break; } case RATINGS_FILTER: @@ -155,21 +154,21 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ { if (game->getType() != GAME) return "FALSE"; - key = strToUpper(game->metadata.get("favorite")); + key = Utils::String::toUpper(game->metadata.get("favorite")); break; } case HIDDEN_FILTER: { if (game->getType() != GAME) return "FALSE"; - key = strToUpper(game->metadata.get("hidden")); + key = Utils::String::toUpper(game->metadata.get("hidden")); break; } case KIDGAME_FILTER: { if (game->getType() != GAME) return "FALSE"; - key = strToUpper(game->metadata.get("kidgame")); + key = Utils::String::toUpper(game->metadata.get("kidgame")); break; } } diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index 9a4bb7b08..ecbafffe0 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -6,7 +6,6 @@ #include "Log.h" #include "Settings.h" #include "SystemData.h" -#include "Util.h" #include #include diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 5b9aceac1..7732ac16b 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -2,7 +2,6 @@ #include "utils/FileSystemUtil.h" #include "Log.h" -#include "Util.h" #include MetaDataDecl gameDecls[] = { diff --git a/es-app/src/SystemScreenSaver.cpp b/es-app/src/SystemScreenSaver.cpp index 929decf7c..afe995edc 100644 --- a/es-app/src/SystemScreenSaver.cpp +++ b/es-app/src/SystemScreenSaver.cpp @@ -14,7 +14,6 @@ #include "Renderer.h" #include "Sound.h" #include "SystemData.h" -#include "Util.h" #include #include #include diff --git a/es-app/src/components/ScraperSearchComponent.cpp b/es-app/src/components/ScraperSearchComponent.cpp index 62802c248..3cffa40ec 100644 --- a/es-app/src/components/ScraperSearchComponent.cpp +++ b/es-app/src/components/ScraperSearchComponent.cpp @@ -9,9 +9,9 @@ #include "guis/GuiMsgBox.h" #include "guis/GuiTextEditPopup.h" #include "resources/Font.h" +#include "utils/StringUtil.h" #include "FileData.h" #include "Log.h" -#include "Util.h" #include "Window.h" ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window), @@ -244,7 +244,7 @@ void ScraperSearchComponent::onSearchDone(const std::vector for(size_t i = 0; i < results.size(); i++) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, strToUpper(results.at(i).mdl.get("name")), font, color), true); + row.addElement(std::make_shared(mWindow, Utils::String::toUpper(results.at(i).mdl.get("name")), font, color), true); row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); }); mResultList->addRow(row); } @@ -269,7 +269,7 @@ void ScraperSearchComponent::onSearchDone(const std::vector void ScraperSearchComponent::onSearchError(const std::string& error) { LOG(LogInfo) << "ScraperSearchComponent search error: " << error; - mWindow->pushGui(new GuiMsgBox(mWindow, strToUpper(error), + mWindow->pushGui(new GuiMsgBox(mWindow, Utils::String::toUpper(error), "RETRY", std::bind(&ScraperSearchComponent::search, this, mLastSearch), "SKIP", mSkipCallback, "CANCEL", mCancelCallback)); @@ -294,8 +294,8 @@ void ScraperSearchComponent::updateInfoPane() if(i != -1 && (int)mScraperResults.size() > i) { ScraperSearchResult& res = mScraperResults.at(i); - mResultName->setText(strToUpper(res.mdl.get("name"))); - mResultDesc->setText(strToUpper(res.mdl.get("desc"))); + mResultName->setText(Utils::String::toUpper(res.mdl.get("name"))); + mResultDesc->setText(Utils::String::toUpper(res.mdl.get("desc"))); mDescContainer->reset(); mResultThumbnail->setImage(""); @@ -308,12 +308,12 @@ void ScraperSearchComponent::updateInfoPane() } // metadata - mMD_Rating->setValue(strToUpper(res.mdl.get("rating"))); - mMD_ReleaseDate->setValue(strToUpper(res.mdl.get("releasedate"))); - mMD_Developer->setText(strToUpper(res.mdl.get("developer"))); - mMD_Publisher->setText(strToUpper(res.mdl.get("publisher"))); - mMD_Genre->setText(strToUpper(res.mdl.get("genre"))); - mMD_Players->setText(strToUpper(res.mdl.get("players"))); + mMD_Rating->setValue(Utils::String::toUpper(res.mdl.get("rating"))); + mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate"))); + mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer"))); + mMD_Publisher->setText(Utils::String::toUpper(res.mdl.get("publisher"))); + mMD_Genre->setText(Utils::String::toUpper(res.mdl.get("genre"))); + mMD_Players->setText(Utils::String::toUpper(res.mdl.get("players"))); mGrid.onSizeChanged(); }else{ mResultName->setText(""); diff --git a/es-app/src/components/TextListComponent.h b/es-app/src/components/TextListComponent.h index 8e8e7d4d6..42ab9501b 100644 --- a/es-app/src/components/TextListComponent.h +++ b/es-app/src/components/TextListComponent.h @@ -4,9 +4,9 @@ #include "components/IList.h" #include "math/Misc.h" +#include "utils/StringUtil.h" #include "Log.h" #include "Sound.h" -#include "Util.h" #include class TextCache; @@ -188,7 +188,7 @@ void TextListComponent::render(const Transform4x4f& parentTrans) color = mColors[entry.data.colorId]; if(!entry.data.textCache) - entry.data.textCache = std::unique_ptr(font->buildTextCache(mUppercase ? strToUpper(entry.name) : entry.name, 0, 0, 0x000000FF)); + entry.data.textCache = std::unique_ptr(font->buildTextCache(mUppercase ? Utils::String::toUpper(entry.name) : entry.name, 0, 0, 0x000000FF)); entry.data.textCache->setColor(color); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index fcb0c4c26..27df3082e 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -43,7 +43,7 @@ void GuiCollectionSystemsOptions::initializeMenu() }; row.makeAcceptInputHandler(createCollectionCall); - auto themeFolder = std::make_shared(mWindow, strToUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); + auto themeFolder = std::make_shared(mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); row.addElement(themeFolder, true); s->addRow(row); } @@ -78,7 +78,7 @@ void GuiCollectionSystemsOptions::initializeMenu() if(CollectionSystemManager::get()->isEditing()) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, "FINISH EDITING '" + strToUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); + row.addElement(std::make_shared(mWindow, "FINISH EDITING '" + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.makeAcceptInputHandler(std::bind(&GuiCollectionSystemsOptions::exitEditMode, this)); mMenu.addRow(row); } diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index 6fd067096..b2674a78b 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -19,13 +19,13 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std:: // row 0 is a spacer - mGameName = std::make_shared(mWindow, strToUpper(mSearchParams.game->getPath().filename().generic_string()), + mGameName = std::make_shared(mWindow, Utils::String::toUpper(mSearchParams.game->getPath().filename().generic_string()), Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); mGrid.setEntry(mGameName, Vector2i(0, 1), false, true); // row 2 is a spacer - mSystemName = std::make_shared(mWindow, strToUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL), + mSystemName = std::make_shared(mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); mGrid.setEntry(mSystemName, Vector2i(0, 3), false, true); diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index 82eab49b1..52950bcf6 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -98,7 +98,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui if(UIModeController::getInstance()->isUIModeFull() && CollectionSystemManager::get()->isEditing()) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, "FINISH EDITING '" + strToUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); + row.addElement(std::make_shared(mWindow, "FINISH EDITING '" + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::exitEditMode, this)); mMenu.addRow(row); } diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 2b04b3897..d5ce19585 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -466,7 +466,7 @@ void GuiMenu::addVersionInfo() { mVersion.setFont(Font::get(FONT_SIZE_SMALL)); mVersion.setColor(0x5E5E5EFF); - mVersion.setText("EMULATIONSTATION V" + strToUpper(PROGRAM_VERSION_STRING)); + mVersion.setText("EMULATIONSTATION V" + Utils::String::toUpper(PROGRAM_VERSION_STRING)); mVersion.setHorizontalAlignment(ALIGN_CENTER); addChild(&mVersion); } diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index 0412d9566..d7021f090 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -11,12 +11,12 @@ #include "guis/GuiMsgBox.h" #include "guis/GuiTextEditPopup.h" #include "resources/Font.h" +#include "utils/StringUtil.h" #include "views/ViewController.h" #include "CollectionSystemManager.h" #include "FileData.h" #include "FileFilterIndex.h" #include "SystemData.h" -#include "Util.h" #include "Window.h" GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector& mdd, ScraperSearchParams scraperParams, @@ -36,7 +36,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector mHeaderGrid = std::make_shared(mWindow, Vector2i(1, 5)); mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mSubtitle = std::make_shared(mWindow, strToUpper(scraperParams.game->getPath().filename().generic_string()), + mSubtitle = std::make_shared(mWindow, Utils::String::toUpper(scraperParams.game->getPath().filename().generic_string()), Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true); mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true); @@ -58,7 +58,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector // create ed and add it (and any related components) to mMenu // ed's value will be set below ComponentListRow row; - auto lbl = std::make_shared(mWindow, strToUpper(iter->displayName), Font::get(FONT_SIZE_SMALL), 0x777777FF); + auto lbl = std::make_shared(mWindow, Utils::String::toUpper(iter->displayName), Font::get(FONT_SIZE_SMALL), 0x777777FF); row.addElement(lbl, true); // label switch(iter->type) diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 0e05492e9..3dc546d83 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -99,11 +99,11 @@ void GuiScraperMulti::doNextSearch() // update title std::stringstream ss; - mSystem->setText(strToUpper(mSearchQueue.front().system->getFullName())); + mSystem->setText(Utils::String::toUpper(mSearchQueue.front().system->getFullName())); // update subtitle ss.str(""); // clear - ss << "GAME " << (mCurrentGame + 1) << " OF " << mTotalGames << " - " << strToUpper(mSearchQueue.front().game->getPath().filename().string()); + ss << "GAME " << (mCurrentGame + 1) << " OF " << mTotalGames << " - " << Utils::String::toUpper(mSearchQueue.front().game->getPath().filename().string()); mSubtitle->setText(ss.str()); mSearchComp->search(mSearchQueue.front()); diff --git a/es-app/src/guis/GuiScraperStart.cpp b/es-app/src/guis/GuiScraperStart.cpp index 75649d5af..10c2a9b86 100644 --- a/es-app/src/guis/GuiScraperStart.cpp +++ b/es-app/src/guis/GuiScraperStart.cpp @@ -48,7 +48,7 @@ void GuiScraperStart::pressedStart() if((*it)->getPlatformIds().empty()) { mWindow->pushGui(new GuiMsgBox(mWindow, - strToUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"), + Utils::String::toUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"), "YES", std::bind(&GuiScraperStart::start, this), "NO", nullptr)); return; diff --git a/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp b/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp index 57cc6cb17..e29b3e2e9 100644 --- a/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp +++ b/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp @@ -3,6 +3,7 @@ #include "components/SliderComponent.h" #include "components/SwitchComponent.h" #include "guis/GuiTextEditPopup.h" +#include "utils/StringUtil.h" #include "Settings.h" #include "Window.h" @@ -72,7 +73,7 @@ void GuiSlideshowScreensaverOptions::addWithLabel(ComponentListRow row, const st { row.elements.clear(); - auto lbl = std::make_shared(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + auto lbl = std::make_shared(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); row.addElement(lbl, true); // label row.addElement(component, false, true); @@ -84,7 +85,7 @@ void GuiSlideshowScreensaverOptions::addEditableTextComponent(ComponentListRow r { row.elements.clear(); - auto lbl = std::make_shared(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + auto lbl = std::make_shared(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); row.addElement(lbl, true); // label row.addElement(ed, true); diff --git a/es-app/src/scrapers/GamesDBScraper.cpp b/es-app/src/scrapers/GamesDBScraper.cpp index 164570e40..4ccc591af 100644 --- a/es-app/src/scrapers/GamesDBScraper.cpp +++ b/es-app/src/scrapers/GamesDBScraper.cpp @@ -6,7 +6,6 @@ #include "PlatformId.h" #include "Settings.h" #include "SystemData.h" -#include "Util.h" #include using namespace PlatformIds; diff --git a/es-core/CMakeLists.txt b/es-core/CMakeLists.txt index 5c140cf26..c1c0b6477 100644 --- a/es-core/CMakeLists.txt +++ b/es-core/CMakeLists.txt @@ -17,7 +17,6 @@ set(CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/Settings.h ${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.h ${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/Util.h ${CMAKE_CURRENT_SOURCE_DIR}/src/Window.h # Animations @@ -95,7 +94,6 @@ set(CORE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/Settings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/Util.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp # Animations diff --git a/es-core/src/Util.cpp b/es-core/src/Util.cpp deleted file mode 100644 index 246af37f0..000000000 --- a/es-core/src/Util.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "Util.h" - -std::string strToUpper(const char* from) -{ - std::string str(from); - for(unsigned int i = 0; i < str.size(); i++) - str[i] = (char)toupper(from[i]); - return str; -} - -std::string& strToUpper(std::string& str) -{ - for(unsigned int i = 0; i < str.size(); i++) - str[i] = (char)toupper(str[i]); - - return str; -} - -std::string strToUpper(const std::string& str) -{ - return strToUpper(str.c_str()); -} - -std::string strreplace(std::string str, const std::string& replace, const std::string& with) -{ - size_t pos; - while((pos = str.find(replace)) != std::string::npos) - str = str.replace(pos, replace.length(), with.c_str(), with.length()); - - return str; -} diff --git a/es-core/src/Util.h b/es-core/src/Util.h deleted file mode 100644 index 19e84d98e..000000000 --- a/es-core/src/Util.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#ifndef ES_CORE_UTIL_H -#define ES_CORE_UTIL_H - -#include - -std::string strToUpper(const char* from); -std::string& strToUpper(std::string& str); -std::string strToUpper(const std::string& str); - -std::string strreplace(std::string str, const std::string& replace, const std::string& with); - -#endif // ES_CORE_UTIL_H diff --git a/es-core/src/components/ButtonComponent.cpp b/es-core/src/components/ButtonComponent.cpp index a04592898..949604641 100644 --- a/es-core/src/components/ButtonComponent.cpp +++ b/es-core/src/components/ButtonComponent.cpp @@ -1,8 +1,8 @@ #include "components/ButtonComponent.h" #include "resources/Font.h" +#include "utils/StringUtil.h" #include "Renderer.h" -#include "Util.h" ButtonComponent::ButtonComponent(Window* window, const std::string& text, const std::string& helpText, const std::function& func) : GuiComponent(window), mBox(window, ":/button.png"), @@ -40,7 +40,7 @@ bool ButtonComponent::input(InputConfig* config, Input input) void ButtonComponent::setText(const std::string& text, const std::string& helpText) { - mText = strToUpper(text); + mText = Utils::String::toUpper(text); mHelpText = helpText; mTextCache = std::unique_ptr(mFont->buildTextCache(mText, 0, 0, getCurTextColor())); diff --git a/es-core/src/components/DateTimeComponent.cpp b/es-core/src/components/DateTimeComponent.cpp index aba383f5a..644fd4f7e 100644 --- a/es-core/src/components/DateTimeComponent.cpp +++ b/es-core/src/components/DateTimeComponent.cpp @@ -1,8 +1,8 @@ #include "components/DateTimeComponent.h" #include "resources/Font.h" +#include "utils/StringUtil.h" #include "Renderer.h" -#include "Util.h" DateTimeComponent::DateTimeComponent(Window* window, DisplayMode dispMode) : GuiComponent(window), mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0), @@ -245,7 +245,7 @@ std::shared_ptr DateTimeComponent::getFont() const void DateTimeComponent::updateTextCache() { DisplayMode mode = getCurrentDisplayMode(); - const std::string dispString = mUppercase ? strToUpper(getDisplayString(mode)) : getDisplayString(mode); + const std::string dispString = mUppercase ? Utils::String::toUpper(getDisplayString(mode)) : getDisplayString(mode); std::shared_ptr font = getFont(); mTextCache = std::unique_ptr(font->buildTextCache(dispString, 0, 0, mColor)); diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 57c945fb2..55a97a37f 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -4,9 +4,9 @@ #include "components/ImageComponent.h" #include "components/TextComponent.h" #include "resources/TextureResource.h" +#include "utils/StringUtil.h" #include "Log.h" #include "Settings.h" -#include "Util.h" #define OFFSET_X 12 // move the entire thing right by this amount (px) #define OFFSET_Y 12 // move the entire thing up by this amount (px) @@ -76,7 +76,7 @@ void HelpComponent::updateGrid() icon->setResize(0, height); icons.push_back(icon); - auto lbl = std::make_shared(mWindow, strToUpper(it->second), font, mStyle.textColor); + auto lbl = std::make_shared(mWindow, Utils::String::toUpper(it->second), font, mStyle.textColor); labels.push_back(lbl); width += icon->getSize().x() + lbl->getSize().x() + ICON_TEXT_SPACING + ENTRY_SPACING; diff --git a/es-core/src/components/MenuComponent.cpp b/es-core/src/components/MenuComponent.cpp index 7921cab0c..2e60b5945 100644 --- a/es-core/src/components/MenuComponent.cpp +++ b/es-core/src/components/MenuComponent.cpp @@ -34,7 +34,7 @@ MenuComponent::MenuComponent(Window* window, const char* title, const std::share void MenuComponent::setTitle(const char* title, const std::shared_ptr& font) { - mTitle->setText(strToUpper(title)); + mTitle->setText(Utils::String::toUpper(title)); mTitle->setFont(font); } @@ -79,7 +79,7 @@ void MenuComponent::onSizeChanged() void MenuComponent::addButton(const std::string& name, const std::string& helpText, const std::function& callback) { - mButtons.push_back(std::make_shared(mWindow, strToUpper(name), helpText, callback)); + mButtons.push_back(std::make_shared(mWindow, Utils::String::toUpper(name), helpText, callback)); updateGrid(); updateSize(); } diff --git a/es-core/src/components/MenuComponent.h b/es-core/src/components/MenuComponent.h index 8574d8823..7babd2d3a 100644 --- a/es-core/src/components/MenuComponent.h +++ b/es-core/src/components/MenuComponent.h @@ -6,8 +6,8 @@ #include "components/ComponentList.h" #include "components/NinePatchComponent.h" #include "components/TextComponent.h" +#include "utils/StringUtil.h" #include "Renderer.h" -#include "Util.h" class ButtonComponent; class ImageComponent; @@ -29,7 +29,7 @@ public: inline void addWithLabel(const std::string& label, const std::shared_ptr& comp, bool setCursorHere = false, bool invert_when_selected = true) { ComponentListRow row; - row.addElement(std::make_shared(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); + row.addElement(std::make_shared(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.addElement(comp, false, invert_when_selected); addRow(row, setCursorHere); } diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index 919f27f4c..7a4bf72c3 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -48,7 +48,7 @@ private: for(auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); it++) { row.elements.clear(); - row.addElement(std::make_shared(mWindow, strToUpper(it->name), font, 0x777777FF), true); + row.addElement(std::make_shared(mWindow, Utils::String::toUpper(it->name), font, 0x777777FF), true); OptionListData& e = *it; @@ -302,7 +302,7 @@ private: { if(it->selected) { - mText.setText(strToUpper(it->name)); + mText.setText(Utils::String::toUpper(it->name)); mText.setSize(0, mText.getSize().y()); setSize(mText.getSize().x() + mLeftArrow.getSize().x() + mRightArrow.getSize().x() + 24, mText.getSize().y()); if(mParent) // hack since theres no "on child size changed" callback atm... diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index 7356efe45..d1fc995f4 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -4,7 +4,6 @@ #include "Log.h" #include "Renderer.h" #include "Settings.h" -#include "Util.h" TextComponent::TextComponent(Window* window) : GuiComponent(window), mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true), @@ -157,11 +156,11 @@ void TextComponent::calculateExtent() { if(mAutoCalcExtent.x()) { - mSize = mFont->sizeText(mUppercase ? strToUpper(mText) : mText, mLineSpacing); + mSize = mFont->sizeText(mUppercase ? Utils::String::toUpper(mText) : mText, mLineSpacing); }else{ if(mAutoCalcExtent.y()) { - mSize[1] = mFont->sizeWrappedText(mUppercase ? strToUpper(mText) : mText, getSize().x(), mLineSpacing).y(); + mSize[1] = mFont->sizeWrappedText(mUppercase ? Utils::String::toUpper(mText) : mText, getSize().x(), mLineSpacing).y(); } } } @@ -176,7 +175,7 @@ void TextComponent::onTextChanged() return; } - std::string text = mUppercase ? strToUpper(mText) : mText; + std::string text = mUppercase ? Utils::String::toUpper(mText) : mText; std::shared_ptr f = mFont; const bool isMultiline = (mSize.y() == 0 || mSize.y() > f->getHeight()*1.2f); diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 0968fcc6a..41ccbdb6d 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -5,7 +5,6 @@ #include "PowerSaver.h" #include "Renderer.h" #include "ThemeData.h" -#include "Util.h" #include "Window.h" #include diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index a8555f8bd..faadbf4ac 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -3,10 +3,10 @@ #include "components/TextComponent.h" #include "guis/GuiInputConfig.h" #include "utils/FileSystemUtil.h" +#include "utils/StringUtil.h" #include "InputManager.h" #include "PowerSaver.h" #include "Renderer.h" -#include "Util.h" #include "Window.h" #define HOLD_TIME 1000 @@ -85,7 +85,7 @@ bool GuiDetectDevice::input(InputConfig* config, Input input) // started holding mHoldingConfig = config; mHoldTime = HOLD_TIME; - mDeviceHeld->setText(strToUpper(config->getDeviceName())); + mDeviceHeld->setText(Utils::String::toUpper(config->getDeviceName())); }else if(!input.value && mHoldingConfig == config) { // cancel diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index cd7536558..2ec414c55 100644 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -162,7 +162,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi ss << "CEC"; else ss << "GAMEPAD " << (target->getDeviceId() + 1); - mSubtitle1 = std::make_shared(mWindow, strToUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); + mSubtitle1 = std::make_shared(mWindow, Utils::String::toUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); mGrid.setEntry(mSubtitle1, Vector2i(0, 2), false, true); mSubtitle2 = std::make_shared(mWindow, "HOLD ANY BUTTON TO SKIP", Font::get(FONT_SIZE_SMALL), 0x99999900, ALIGN_CENTER); @@ -379,7 +379,7 @@ void GuiInputConfig::setNotDefined(const std::shared_ptr& text) void GuiInputConfig::setAssignedTo(const std::shared_ptr& text, Input input) { - text->setText(strToUpper(input.string())); + text->setText(Utils::String::toUpper(input.string())); text->setColor(0x777777FF); } diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 2a39f5f90..7f0560320 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -31,7 +31,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text, }else{ for(auto it = mButtons.cbegin(); it != mButtons.cend(); it++) { - if(strToUpper((*it)->getText()) == "OK" || strToUpper((*it)->getText()) == "NO") + if(Utils::String::toUpper((*it)->getText()) == "OK" || Utils::String::toUpper((*it)->getText()) == "NO") { mAcceleratorFunc = (*it)->getPressedFunc(); break; diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index a96dfddab..267939430 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -11,7 +11,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, con addChild(&mBackground); addChild(&mGrid); - mTitle = std::make_shared(mWindow, strToUpper(title), Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); + mTitle = std::make_shared(mWindow, Utils::String::toUpper(title), Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mText = std::make_shared(mWindow); mText->setValue(initValue); diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index dfded5c8e..f0e93e61c 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -4,7 +4,6 @@ #include "utils/StringUtil.h" #include "Log.h" #include "Renderer.h" -#include "Util.h" FT_Library Font::sLibrary = NULL; diff --git a/es-core/src/resources/TextureResource.cpp b/es-core/src/resources/TextureResource.cpp index 76fa1239a..c3d9eff0b 100644 --- a/es-core/src/resources/TextureResource.cpp +++ b/es-core/src/resources/TextureResource.cpp @@ -2,7 +2,6 @@ #include "utils/FileSystemUtil.h" #include "resources/TextureData.h" -#include "Util.h" TextureDataManager TextureResource::sTextureDataManager; std::map< TextureResource::TextureKeyType, std::weak_ptr > TextureResource::sTextureMap; diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index b19fbf699..15f7bf8e8 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -7,6 +7,7 @@ // because windows... #include #include +#define getcwd _getcwd #define mkdir(x,y) _mkdir(x) #define snprintf _snprintf #define unlink _unlink @@ -245,7 +246,7 @@ namespace Utils else path = getParent(path) + "/" + resolved; - for( ++it; it != pathList.cend(); ++it) + for(++it; it != pathList.cend(); ++it) path += (path.size() == 0) ? (*it) : ("/" + (*it)); scan = true; @@ -335,19 +336,19 @@ namespace Utils std::string resolveRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome) { - std::string path = getGenericPath(_path); + std::string path = getGenericPath(_path); std::string relativeTo = isDirectory(_relativeTo) ? getGenericPath(_relativeTo) : getParent(_relativeTo); // nothing to resolve - if (!path.length()) + if(!path.length()) return path; // replace '.' with relativeTo - if (path[0] == '.') + if(path[0] == '.') return (relativeTo + "/" + &(path[1])); // replace '~' with homePath - if (_allowHome && (path[0] == '~')) + if(_allowHome && (path[0] == '~')) return (getHomePath() + "/" + &(path[1])); // nothing to resolve @@ -357,21 +358,20 @@ namespace Utils std::string createRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome) { - bool contains = false; - std::string path = removeCommonPath(_path, _relativeTo, contains); + bool contains = false; + std::string path = removeCommonPath(_path, _relativeTo, contains); - if (contains) + if(contains) { // success return ("." + path); } - if (_allowHome) + if(_allowHome) { - contains = false; - std::string path = removeCommonPath(_path, getHomePath(), contains); + path = removeCommonPath(_path, getHomePath(), contains); - if (contains) + if(contains) { // success return ("~" + path); @@ -385,11 +385,11 @@ namespace Utils std::string removeCommonPath(const std::string& _path, const std::string& _common, bool& _contains) { - std::string path = getGenericPath(_path); + std::string path = getGenericPath(_path); std::string common = isDirectory(_common) ? getGenericPath(_common) : getParent(_common); // check if path contains common - if (path.find_first_of(common) == 0) + if(path.find_first_of(common) == 0) { _contains = true; return path.substr(common.length() + 1); @@ -409,10 +409,10 @@ namespace Utils #if defined(_WIN32) HANDLE hFile = CreateFile(path.c_str(), FILE_READ_ATTRIBUTES, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); - if (hFile != INVALID_HANDLE_VALUE) + if(hFile != INVALID_HANDLE_VALUE) { resolved.resize(GetFinalPathNameByHandle(hFile, nullptr, 0, FILE_NAME_NORMALIZED) + 1); - if (GetFinalPathNameByHandle(hFile, (LPSTR)resolved.data(), (DWORD)resolved.size(), FILE_NAME_NORMALIZED) > 0) + if(GetFinalPathNameByHandle(hFile, (LPSTR)resolved.data(), (DWORD)resolved.size(), FILE_NAME_NORMALIZED) > 0) { resolved.resize(resolved.size() - 1); resolved = getGenericPath(resolved); @@ -423,10 +423,10 @@ namespace Utils struct stat info; // check if lstat succeeded - if (lstat(path.c_str(), &info) == 0) + if(lstat(path.c_str(), &info) == 0) { resolved.resize(info.st_size); - if (readlink(path.c_str(), (char*)resolved.data(), resolved.size()) > 0) + if(readlink(path.c_str(), (char*)resolved.data(), resolved.size()) > 0) resolved = getGenericPath(resolved); } #endif // _WIN32 diff --git a/es-core/src/utils/TimeUtil.cpp b/es-core/src/utils/TimeUtil.cpp index 5ae3690cb..2b10eeb4a 100644 --- a/es-core/src/utils/TimeUtil.cpp +++ b/es-core/src/utils/TimeUtil.cpp @@ -39,8 +39,7 @@ namespace Utils void DateTime::setTime(const time_t& _time) { - if(_time < 0) mTime = 0; - else mTime = _time; + mTime = (_time < 0) ? 0 : _time; mTimeStruct = *localtime(&mTime); mIsoString = timeToString(mTime);