From 9ee5f75bfb812e11bc9ad966491d051946d1049a Mon Sep 17 00:00:00 2001 From: Sude Date: Thu, 25 Apr 2013 10:48:10 +0300 Subject: [PATCH] Rename global constants to better describe what they mean --- include/api.h | 2 +- include/globalconstants.h | 12 ++++++------ main.cpp | 8 ++++---- src/api.cpp | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/api.h b/include/api.h index 927d158..1480771 100644 --- a/include/api.h +++ b/include/api.h @@ -81,7 +81,7 @@ class API std::string getResponseOAuth(const std::string& url); int getUserDetails(); int getGames(); - gameDetails getGameDetails(const std::string& game_name, const unsigned int& type = GlobalConstants::INSTALLER_WINDOWS, const unsigned int& lang = GlobalConstants::LANGUAGE_EN); + gameDetails getGameDetails(const std::string& game_name, const unsigned int& type = GlobalConstants::PLATFORM_WINDOWS, const unsigned int& lang = GlobalConstants::LANGUAGE_EN); std::string getInstallerLink(const std::string& game_name, const std::string& id); std::string getExtraLink(const std::string& game_name, const std::string& id); std::string getXML(const std::string& game_name, const std::string& id); diff --git a/include/globalconstants.h b/include/globalconstants.h index b014a08..837b632 100644 --- a/include/globalconstants.h +++ b/include/globalconstants.h @@ -51,14 +51,14 @@ namespace GlobalConstants }; // Installer constants - const unsigned int INSTALLER_WINDOWS = 1; - const unsigned int INSTALLER_MAC = 2; + const unsigned int PLATFORM_WINDOWS = 1; + const unsigned int PLATFORM_MAC = 2; - struct installerStruct {const unsigned int installerId; const std::string installerCode; const std::string installerString;}; - const std::vector INSTALLERS = + struct platformStruct {const unsigned int platformId; const std::string platformCode; const std::string platformString;}; + const std::vector PLATFORMS = { - { INSTALLER_WINDOWS, "win", "Windows" }, - { INSTALLER_MAC, "mac", "Mac" } + { PLATFORM_WINDOWS, "win", "Windows" }, + { PLATFORM_MAC, "mac", "Mac" } }; }; diff --git a/main.cpp b/main.cpp index d8ac607..adacc75 100644 --- a/main.cpp +++ b/main.cpp @@ -52,9 +52,9 @@ int main(int argc, char *argv[]) // Create help text for --platform option std::string platform_text = "Select which installers are downloaded\n"; unsigned int platform_sum = 0; - for (unsigned int i = 0; i < GlobalConstants::INSTALLERS.size(); ++i) + for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i) { - platform_text += std::to_string(GlobalConstants::INSTALLERS[i].installerId) + " = " + GlobalConstants::INSTALLERS[i].installerString + "\n"; + platform_text += std::to_string(GlobalConstants::PLATFORMS[i].platformId) + " = " + GlobalConstants::PLATFORMS[i].platformString + "\n"; platform_sum += GlobalConstants::LANGUAGES[i].languageId; } platform_text += std::to_string(platform_sum) + " = All"; @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) ("xml-directory", bpo::value(&config.sXMLDirectory), "Set directory for GOG XML files") ("chunk-size", bpo::value(&config.iChunkSize)->default_value(10), "Chunk size (in MB) when creating XML") ("update-check", bpo::value(&config.bUpdateCheck)->zero_tokens()->default_value(false), "Check for update notifications") - ("platform", bpo::value(&config.iInstallerType)->default_value(GlobalConstants::INSTALLER_WINDOWS), platform_text.c_str()) + ("platform", bpo::value(&config.iInstallerType)->default_value(GlobalConstants::PLATFORM_WINDOWS), platform_text.c_str()) ("language", bpo::value(&config.iInstallerLanguage)->default_value(GlobalConstants::LANGUAGE_EN), language_text.c_str()) ("no-installers", bpo::value(&config.bNoInstallers)->zero_tokens()->default_value(false), "Don't download/list/repair installers") ("no-extras", bpo::value(&config.bNoExtras)->zero_tokens()->default_value(false), "Don't download/list/repair extras") @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) return 1; } - if (config.iInstallerType < GlobalConstants::INSTALLER_WINDOWS || config.iInstallerType > platform_sum) + if (config.iInstallerType < GlobalConstants::PLATFORM_WINDOWS || config.iInstallerType > platform_sum) { std::cout << "Invalid value for --platform" << std::endl; return 1; diff --git a/src/api.cpp b/src/api.cpp index f570aba..a0dd3ac 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -289,11 +289,11 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int // Installer details std::vector> installers; - for (unsigned int i = 0; i < GlobalConstants::INSTALLERS.size(); ++i) + for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i) { - if (type & GlobalConstants::INSTALLERS[i].installerId) + if (type & GlobalConstants::PLATFORMS[i].platformId) { - std::string installer = "installer_" + GlobalConstants::INSTALLERS[i].installerCode + "_"; + std::string installer = "installer_" + GlobalConstants::PLATFORMS[i].platformCode + "_"; for (unsigned int j = 0; j < GlobalConstants::LANGUAGES.size(); ++j) { if (lang & GlobalConstants::LANGUAGES[j].languageId)