Removed some unnecessary typedefs and replaced the remaining ones with the more modern 'using' keyword.

Also harmonized the names of some user defined types and made some other minor cleanup.
This commit is contained in:
Leon Styhre 2022-01-11 21:57:00 +01:00
parent c477c12dde
commit a233b96c2a
20 changed files with 44 additions and 49 deletions

View file

@ -1366,9 +1366,9 @@ std::vector<std::string> CollectionSystemsManager::getSystemsFromTheme()
std::string themePath = set->second.path; std::string themePath = set->second.path;
if (Utils::FileSystem::exists(themePath)) { if (Utils::FileSystem::exists(themePath)) {
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(themePath); Utils::FileSystem::StringList dirContent = Utils::FileSystem::getDirContent(themePath);
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); for (Utils::FileSystem::StringList::const_iterator it = dirContent.cbegin();
it != dirContent.cend(); ++it) { it != dirContent.cend(); ++it) {
if (Utils::FileSystem::isDirectory(*it)) { if (Utils::FileSystem::isDirectory(*it)) {
// ... here you have a directory. // ... here you have a directory.
@ -1390,8 +1390,8 @@ std::vector<std::string> CollectionSystemsManager::getCollectionsFromConfigFolde
std::string configPath = getCollectionsFolder(); std::string configPath = getCollectionsFolder();
if (Utils::FileSystem::exists(configPath)) { if (Utils::FileSystem::exists(configPath)) {
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(configPath); Utils::FileSystem::StringList dirContent = Utils::FileSystem::getDirContent(configPath);
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); for (Utils::FileSystem::StringList::const_iterator it = dirContent.cbegin();
it != dirContent.cend(); ++it) { it != dirContent.cend(); ++it) {
if (Utils::FileSystem::isRegularFile(*it)) { if (Utils::FileSystem::isRegularFile(*it)) {
// It's a file. // It's a file.

View file

@ -108,7 +108,7 @@ public:
void launchGame(Window* window); void launchGame(Window* window);
const std::string findEmulatorPath(std::string& command); const std::string findEmulatorPath(std::string& command);
typedef bool ComparisonFunction(const FileData* a, const FileData* b); using ComparisonFunction = bool(const FileData* a, const FileData* b);
struct SortType { struct SortType {
ComparisonFunction* comparisonFunction; ComparisonFunction* comparisonFunction;
std::string description; std::string description;

View file

@ -30,7 +30,7 @@ FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType
return nullptr; return nullptr;
} }
Utils::FileSystem::stringList pathList = Utils::FileSystem::getPathList(relative); Utils::FileSystem::StringList pathList = Utils::FileSystem::getPathList(relative);
auto path_it = pathList.begin(); auto path_it = pathList.begin();
FileData* treeNode = root; FileData* treeNode = root;
bool found = false; bool found = false;

View file

@ -265,13 +265,13 @@ bool SystemData::populateFolder(FileData* folder)
std::string extension; std::string extension;
bool isGame; bool isGame;
bool showHiddenFiles = Settings::getInstance()->getBool("ShowHiddenFiles"); bool showHiddenFiles = Settings::getInstance()->getBool("ShowHiddenFiles");
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(folderPath); Utils::FileSystem::StringList dirContent = Utils::FileSystem::getDirContent(folderPath);
// If system directory exists but contains no games, return as error. // If system directory exists but contains no games, return as error.
if (dirContent.size() == 0) if (dirContent.size() == 0)
return false; return false;
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); for (Utils::FileSystem::StringList::const_iterator it = dirContent.cbegin();
it != dirContent.cend(); ++it) { it != dirContent.cend(); ++it) {
filePath = *it; filePath = *it;

View file

@ -465,7 +465,7 @@ void SystemScreensaver::generateCustomImageList()
if (imageDir != "" && Utils::FileSystem::isDirectory(imageDir)) { if (imageDir != "" && Utils::FileSystem::isDirectory(imageDir)) {
std::string imageFilter = ".jpg, .JPG, .png, .PNG"; std::string imageFilter = ".jpg, .JPG, .png, .PNG";
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent( Utils::FileSystem::StringList dirContent = Utils::FileSystem::getDirContent(
imageDir, Settings::getInstance()->getBool("ScreensaverSlideshowRecurse")); imageDir, Settings::getInstance()->getBool("ScreensaverSlideshowRecurse"));
for (auto it = dirContent.begin(); it != dirContent.end(); ++it) { for (auto it = dirContent.begin(); it != dirContent.end(); ++it) {

View file

@ -43,10 +43,10 @@ private:
MenuComponent mMenu; MenuComponent mMenu;
typedef OptionListComponent<std::string> LetterList; using LetterList = OptionListComponent<std::string>;
std::shared_ptr<LetterList> mJumpToLetterList; std::shared_ptr<LetterList> mJumpToLetterList;
typedef OptionListComponent<const FileData::SortType*> SortList; using SortList = OptionListComponent<const FileData::SortType*>;
std::shared_ptr<SortList> mListSort; std::shared_ptr<SortList> mListSort;
SystemData* mSystem; SystemData* mSystem;

View file

@ -296,10 +296,9 @@ void GuiMenu::openUIOptions()
}); });
// Default gamelist sort order. // Default gamelist sort order.
typedef OptionListComponent<const FileData::SortType*> SortList;
std::string sortOrder; std::string sortOrder;
auto default_sort_order = auto default_sort_order = std::make_shared<OptionListComponent<const FileData::SortType*>>(
std::make_shared<SortList>(mWindow, getHelpStyle(), "DEFAULT SORT ORDER", false); mWindow, getHelpStyle(), "DEFAULT SORT ORDER", false);
// Exclude the System sort options. // Exclude the System sort options.
unsigned int numSortTypes = static_cast<unsigned int>(FileSorts::SortTypes.size() - 2); unsigned int numSortTypes = static_cast<unsigned int>(FileSorts::SortTypes.size() - 2);
for (unsigned int i = 0; i < numSortTypes; ++i) { for (unsigned int i = 0; i < numSortTypes; ++i) {

View file

@ -20,7 +20,7 @@ class SwitchComponent;
class SystemData; class SystemData;
template <typename T> class OptionListComponent; template <typename T> class OptionListComponent;
typedef std::function<bool(SystemData*, FileData*)> GameFilterFunc; using GameFilterFunc = std::function<bool(SystemData*, FileData*)>;
class GuiScraperMenu : public GuiComponent class GuiScraperMenu : public GuiComponent
{ {

View file

@ -151,10 +151,10 @@ std::vector<std::string> getScraperList();
// Returns true if the scraper configured in the settings is still valid. // Returns true if the scraper configured in the settings is still valid.
bool isValidConfiguredScraper(); bool isValidConfiguredScraper();
typedef void (*generate_scraper_requests_func)( using generate_scraper_requests_func =
const ScraperSearchParams& params, void (*)(const ScraperSearchParams& params,
std::queue<std::unique_ptr<ScraperRequest>>& requests, std::queue<std::unique_ptr<ScraperRequest>>& requests,
std::vector<ScraperSearchResult>& results); std::vector<ScraperSearchResult>& results);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -175,7 +175,7 @@ public:
private: private:
ScraperSearchResult mResult; ScraperSearchResult mResult;
typedef std::pair<std::unique_ptr<AsyncHandle>, std::function<void()>> ResolvePair; using ResolvePair = std::pair<std::unique_ptr<AsyncHandle>, std::function<void()>>;
std::vector<ResolvePair> mFuncs; std::vector<ResolvePair> mFuncs;
}; };

View file

@ -11,6 +11,6 @@
#include <string> #include <string>
typedef std::pair<std::string, std::string> HelpPrompt; using HelpPrompt = std::pair<std::string, std::string>;
#endif // ES_CORE_HELP_PROMPT_H #endif // ES_CORE_HELP_PROMPT_H

View file

@ -120,8 +120,7 @@ std::vector<std::string> InputConfig::getMappedTo(Input input)
{ {
std::vector<std::string> maps; std::vector<std::string> maps;
typedef std::map<std::string, Input>::const_iterator it_type; for (auto it = mNameMap.cbegin(); it != mNameMap.cend(); ++it) {
for (it_type it = mNameMap.cbegin(); it != mNameMap.cend(); ++it) {
Input chk = it->second; Input chk = it->second;
if (!chk.configured) if (!chk.configured)
@ -204,8 +203,7 @@ void InputConfig::writeToXML(pugi::xml_node& parent)
cfg.append_attribute("deviceGUID") = mDeviceGUID.c_str(); cfg.append_attribute("deviceGUID") = mDeviceGUID.c_str();
typedef std::map<std::string, Input>::const_iterator it_type; for (auto it = mNameMap.cbegin(); it != mNameMap.cend(); ++it) {
for (it_type it = mNameMap.cbegin(); it != mNameMap.cend(); ++it) {
if (!it->second.configured) if (!it->second.configured)
continue; continue;

View file

@ -702,9 +702,9 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
if (!Utils::FileSystem::isDirectory(paths[i])) if (!Utils::FileSystem::isDirectory(paths[i]))
continue; continue;
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(paths[i]); Utils::FileSystem::StringList dirContent = Utils::FileSystem::getDirContent(paths[i]);
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin(); for (Utils::FileSystem::StringList::const_iterator it = dirContent.cbegin();
it != dirContent.cend(); ++it) { it != dirContent.cend(); ++it) {
if (Utils::FileSystem::isDirectory(*it)) { if (Utils::FileSystem::isDirectory(*it)) {
ThemeSet set = {*it}; ThemeSet set = {*it};

View file

@ -39,7 +39,7 @@ public:
void onSizeChanged() override; void onSizeChanged() override;
private: private:
typedef std::pair<std::unique_ptr<ImageComponent>, int> ImageFrame; using ImageFrame = std::pair<std::unique_ptr<ImageComponent>, int>;
std::vector<ImageFrame> mFrames; std::vector<ImageFrame> mFrames;

View file

@ -85,7 +85,7 @@ private:
glm::vec2 mSourceSize; glm::vec2 mSourceSize;
bool mForceLoad; bool mForceLoad;
typedef std::pair<std::string, bool> TextureKeyType; using TextureKeyType = std::pair<std::string, bool>;
// Map of textures, used to prevent duplicate textures. // Map of textures, used to prevent duplicate textures.
static std::map<TextureKeyType, std::weak_ptr<TextureResource>> sTextureMap; static std::map<TextureKeyType, std::weak_ptr<TextureResource>> sTextureMap;
// Set of all textures, used for memory management. // Set of all textures, used for memory management.

View file

@ -33,6 +33,7 @@ namespace Utils
unsigned int shadowDistance, unsigned int shadowDistance,
float transparency, float transparency,
unsigned int iterations); unsigned int iterations);
} // namespace CImg } // namespace CImg
} // namespace Utils } // namespace Utils

View file

@ -63,10 +63,10 @@ namespace Utils
static std::string homePath = ""; static std::string homePath = "";
static std::string exePath = ""; static std::string exePath = "";
stringList getDirContent(const std::string& path, const bool recursive) StringList getDirContent(const std::string& path, const bool recursive)
{ {
std::string genericPath = getGenericPath(path); std::string genericPath = getGenericPath(path);
stringList contentList; StringList contentList;
// Only parse the directory, if it's a directory. // Only parse the directory, if it's a directory.
if (isDirectory(genericPath)) { if (isDirectory(genericPath)) {
@ -121,9 +121,9 @@ namespace Utils
return contentList; return contentList;
} }
stringList getPathList(const std::string& path) StringList getPathList(const std::string& path)
{ {
stringList pathList; StringList pathList;
std::string genericPath = getGenericPath(path); std::string genericPath = getGenericPath(path);
size_t start = 0; size_t start = 0;
size_t end = 0; size_t end = 0;
@ -337,12 +337,12 @@ namespace Utils
// Cleanup path. // Cleanup path.
bool scan = true; bool scan = true;
while (scan) { while (scan) {
stringList pathList = getPathList(canonicalPath); StringList pathList = getPathList(canonicalPath);
canonicalPath.clear(); canonicalPath.clear();
scan = false; scan = false;
for (stringList::const_iterator it = pathList.cbegin(); it != pathList.cend(); for (StringList::const_iterator it = pathList.cbegin(); it != pathList.cend();
++it) { ++it) {
// Ignore empty. // Ignore empty.
if ((*it).empty()) if ((*it).empty())

View file

@ -18,10 +18,10 @@ namespace Utils
{ {
namespace FileSystem namespace FileSystem
{ {
typedef std::list<std::string> stringList; using StringList = std::list<std::string>;
stringList getDirContent(const std::string& path, const bool recursive = false); StringList getDirContent(const std::string& path, const bool recursive = false);
stringList getPathList(const std::string& path); StringList getPathList(const std::string& path);
void setHomePath(const std::string& path); void setHomePath(const std::string& path);
std::string getHomePath(); std::string getHomePath();
std::string getCWDPath(); std::string getCWDPath();
@ -66,6 +66,7 @@ namespace Utils
bool isDirectory(const std::string& path); bool isDirectory(const std::string& path);
bool isSymlink(const std::string& path); bool isSymlink(const std::string& path);
bool isHidden(const std::string& path); bool isHidden(const std::string& path);
} // namespace FileSystem } // namespace FileSystem
} // namespace Utils } // namespace Utils

View file

@ -14,7 +14,6 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include <algorithm> #include <algorithm>
#include <codecvt>
#include <locale> #include <locale>
namespace Utils namespace Utils
@ -470,8 +469,7 @@ namespace Utils
if (charIndex != nullptr) { if (charIndex != nullptr) {
wchar_t lowerChar = *(unicodeLowercase + (charIndex - unicodeUppercase)); wchar_t lowerChar = *(unicodeLowercase + (charIndex - unicodeUppercase));
// Convert back to string format. // Convert back to string format.
typedef std::codecvt_utf8<wchar_t> convert_type; std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> byteConverter;
std::wstring_convert<convert_type, wchar_t> byteConverter;
stringLower += byteConverter.to_bytes(lowerChar); stringLower += byteConverter.to_bytes(lowerChar);
} }
@ -523,8 +521,7 @@ namespace Utils
if (charIndex != nullptr) { if (charIndex != nullptr) {
wchar_t upperChar = *(unicodeUppercase + (charIndex - unicodeLowercase)); wchar_t upperChar = *(unicodeUppercase + (charIndex - unicodeLowercase));
// Convert back to string format. // Convert back to string format.
typedef std::codecvt_utf8<wchar_t> convert_type; std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> byteConverter;
std::wstring_convert<convert_type, wchar_t> byteConverter;
stringUpper += byteConverter.to_bytes(upperChar); stringUpper += byteConverter.to_bytes(upperChar);
} }
@ -596,17 +593,13 @@ namespace Utils
std::wstring stringToWideString(const std::string& stringArg) std::wstring stringToWideString(const std::string& stringArg)
{ {
typedef std::codecvt_utf8<wchar_t> convert_type; std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> stringConverter;
std::wstring_convert<convert_type, wchar_t> stringConverter;
return stringConverter.from_bytes(stringArg); return stringConverter.from_bytes(stringArg);
} }
std::string wideStringToString(const std::wstring& stringArg) std::string wideStringToString(const std::wstring& stringArg)
{ {
typedef std::codecvt_utf8<wchar_t> convert_type; std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> stringConverter;
std::wstring_convert<convert_type, wchar_t> stringConverter;
return stringConverter.to_bytes(stringArg); return stringConverter.to_bytes(stringArg);
} }

View file

@ -10,6 +10,7 @@
#ifndef ES_CORE_UTILS_STRING_UTIL_H #ifndef ES_CORE_UTILS_STRING_UTIL_H
#define ES_CORE_UTILS_STRING_UTIL_H #define ES_CORE_UTILS_STRING_UTIL_H
#include <codecvt>
#include <string> #include <string>
#include <vector> #include <vector>
@ -44,6 +45,7 @@ namespace Utils
const std::string& delimiter, const std::string& delimiter,
bool caseInsensitive = false); bool caseInsensitive = false);
std::string scramble(const std::string& input, const std::string& key); std::string scramble(const std::string& input, const std::string& key);
} // namespace String } // namespace String
} // namespace Utils } // namespace Utils

View file

@ -71,6 +71,7 @@ namespace Utils
std::string timeToString(const time_t& time, const std::string& format = "%Y%m%dT%H%M%S"); std::string timeToString(const time_t& time, const std::string& format = "%Y%m%dT%H%M%S");
int daysInMonth(const int year, const int month); int daysInMonth(const int year, const int month);
int daysInYear(const int year); int daysInYear(const int year);
} // namespace Time } // namespace Time
} // namespace Utils } // namespace Utils