Moved some data and functions from the global to anonymous namespace.

This commit is contained in:
Leon Styhre 2021-11-13 14:27:26 +01:00
parent 187115a9e6
commit fa17d8df66
3 changed files with 232 additions and 226 deletions

View file

@ -36,7 +36,6 @@ using namespace rapidjson;
namespace namespace
{ {
TheGamesDBJSONRequestResources resources; TheGamesDBJSONRequestResources resources;
}
const std::map<PlatformId, std::string> gamesdb_new_platformid_map{ const std::map<PlatformId, std::string> gamesdb_new_platformid_map{
{THREEDO, "25"}, {THREEDO, "25"},
@ -124,8 +123,9 @@ const std::map<PlatformId, std::string> gamesdb_new_platformid_map{
{VIDEOPAC_ODYSSEY2, "4927"}, {VIDEOPAC_ODYSSEY2, "4927"},
{VECTREX, "4939"}, {VECTREX, "4939"},
{TANDY_COLOR_COMPUTER, "4941"}, {TANDY_COLOR_COMPUTER, "4941"},
{TANDY_TRS80, "4941"}, {TANDY_TRS80, "4941"}};
};
} // namespace
void thegamesdb_generate_json_scraper_requests( void thegamesdb_generate_json_scraper_requests(
const ScraperSearchParams& params, const ScraperSearchParams& params,

View file

@ -26,9 +26,12 @@
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
namespace
{
const std::map<std::string, generate_scraper_requests_func> scraper_request_funcs{ const std::map<std::string, generate_scraper_requests_func> scraper_request_funcs{
{"thegamesdb", &thegamesdb_generate_json_scraper_requests}, {"thegamesdb", &thegamesdb_generate_json_scraper_requests},
{"screenscraper", &screenscraper_generate_scraper_requests}}; {"screenscraper", &screenscraper_generate_scraper_requests}};
}
std::unique_ptr<ScraperSearchHandle> startScraperSearch(const ScraperSearchParams& params) std::unique_ptr<ScraperSearchHandle> startScraperSearch(const ScraperSearchParams& params)
{ {

View file

@ -23,6 +23,8 @@
using namespace PlatformIds; using namespace PlatformIds;
namespace
{
// List of systems and their IDs from: // List of systems and their IDs from:
// https://www.screenscraper.fr/api/systemesListe.php?devid=xxx&devpassword=yyy&softname=zzz&output=XML // https://www.screenscraper.fr/api/systemesListe.php?devid=xxx&devpassword=yyy&softname=zzz&output=XML
const std::map<PlatformId, unsigned short> screenscraper_platformid_map{ const std::map<PlatformId, unsigned short> screenscraper_platformid_map{
@ -131,21 +133,20 @@ const std::map<PlatformId, unsigned short> screenscraper_platformid_map{
{SPECTRAVIDEO, 218}, {SPECTRAVIDEO, 218},
{PALM_OS, 219}}; {PALM_OS, 219}};
// Helper XML parsing method, finding a node-by-name recursively. // Helper XML parsing method, finding a node-by-name recursively. Not currently used.
pugi::xml_node find_node_by_name_re(const pugi::xml_node& node, // pugi::xml_node find_node_by_name_re(const pugi::xml_node& node,
const std::vector<std::string> node_names) // const std::vector<std::string> node_names)
{ // {
// for (const std::string& _val : node_names) {
for (const std::string& _val : node_names) { // pugi::xpath_query query_node_name((static_cast<std::string>("//") +
pugi::xpath_query query_node_name((static_cast<std::string>("//") + _val).c_str()); // _val).c_str()); pugi::xpath_node_set results = node.select_nodes(query_node_name);
pugi::xpath_node_set results = node.select_nodes(query_node_name); //
// if (results.size() > 0)
if (results.size() > 0) // return results.first().node();
return results.first().node(); // }
} //
// return pugi::xml_node();
return pugi::xml_node(); // }
}
// Help XML parsing method, finding an direct child XML node starting from the parent and // Help XML parsing method, finding an direct child XML node starting from the parent and
// filtering by an attribute value list. // filtering by an attribute value list.
@ -164,6 +165,8 @@ pugi::xml_node find_child_by_attribute_list(const pugi::xml_node& node_parent,
return pugi::xml_node(nullptr); return pugi::xml_node(nullptr);
} }
} // namespace
void screenscraper_generate_scraper_requests(const ScraperSearchParams& params, void screenscraper_generate_scraper_requests(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)