Changed naming conventions for rest of files

This commit is contained in:
Don Honerbrink
2015-06-25 11:27:52 -05:00
parent 4e046aecec
commit bcf35a954d
79 changed files with 2865 additions and 2939 deletions

View File

@@ -25,50 +25,50 @@ CollectionInfo::CollectionInfo(std::string name,
std::string extensions,
std::string metadataType,
std::string metadataPath)
: Name(name)
, ListPath(listPath)
, Extensions(extensions)
, MetadataType(metadataType)
, MetadataPath(metadataPath)
: name(name)
, listpath(listPath)
, metadataType(metadataType)
, metadataPath_(metadataPath)
, extensions_(extensions)
{
}
CollectionInfo::~CollectionInfo()
{
std::vector<Item *>::iterator it = Items.begin();
std::vector<Item *>::iterator it = items.begin();
while(it != Items.end())
while(it != items.end())
{
delete *it;
Items.erase(it);
it = Items.begin();
items.erase(it);
it = items.begin();
}
}
std::string CollectionInfo::GetSettingsPath() const
std::string CollectionInfo::settingsPath() const
{
return Utils::CombinePath(Configuration::AbsolutePath, "collections", Name);
return Utils::combinePath(Configuration::absolutePath, "collections", name);
}
void CollectionInfo::GetExtensions(std::vector<std::string> &extensions)
void CollectionInfo::extensionList(std::vector<std::string> &extensionlist)
{
std::istringstream ss(Extensions);
std::istringstream ss(extensions_);
std::string token;
while(std::getline(ss, token, ','))
{
extensions.push_back(token);
extensionlist.push_back(token);
}
}
bool CollectionInfo::ItemIsLess(Item *lhs, Item *rhs)
bool CollectionInfo::itemIsLess(Item *lhs, Item *rhs)
{
return lhs->LCFullTitle() < rhs->LCFullTitle();
return lhs->lowercaseFullTitle() < rhs->lowercaseFullTitle();
}
void CollectionInfo::SortItems()
void CollectionInfo::sortItems()
{
std::sort(Items.begin(), Items.end(), ItemIsLess);
std::sort(items.begin(), items.end(), itemIsLess);
}

View File

@@ -25,17 +25,17 @@ class CollectionInfo
public:
CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath);
virtual ~CollectionInfo();
std::string GetSettingsPath() const;
void SortItems();
void GetExtensions(std::vector<std::string> &extensions);
std::string Name;
std::string ListPath;
std::string Extensions;
std::string MetadataType;
std::string MetadataPath;
std::vector<Item *> Items;
std::string settingsPath() const;
void sortItems();
void extensionList(std::vector<std::string> &extensions);
std::string name;
std::string listpath;
std::string metadataType;
std::vector<Item *> items;
private:
static bool ItemIsLess(Item *lhs, Item *rhs);
std::string metadataPath_;
std::string extensions_;
static bool itemIsLess(Item *lhs, Item *rhs);
};

View File

@@ -36,8 +36,8 @@
#include <algorithm>
CollectionInfoBuilder::CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb)
: Conf(c)
, MetaDB(mdb)
: conf_(c)
, metaDB_(mdb)
{
}
@@ -45,24 +45,24 @@ CollectionInfoBuilder::~CollectionInfoBuilder()
{
}
bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
{
std::string collectionPath = Utils::CombinePath(Configuration::AbsolutePath, "collections", name);
std::string collectionPath = Utils::combinePath(Configuration::absolutePath, "collections", name);
std::vector<std::string> paths;
paths.push_back(collectionPath);
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "artwork_back"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "artwork_front"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "bezel"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "logo"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "medium_back"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "medium_front"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "screenshot"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "screentitle"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "video"));
paths.push_back(Utils::CombinePath(collectionPath, "roms"));
paths.push_back(Utils::CombinePath(collectionPath, "system_artwork"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "artwork_back"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "artwork_front"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "bezel"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "logo"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "medium_back"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "medium_front"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "screenshot"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "screentitle"));
paths.push_back(Utils::combinePath(collectionPath, "medium_artwork", "video"));
paths.push_back(Utils::combinePath(collectionPath, "roms"));
paths.push_back(Utils::combinePath(collectionPath, "system_artwork"));
for(std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); it++)
{
@@ -89,7 +89,7 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
#endif
}
std::string filename = Utils::CombinePath(collectionPath, "include.txt");
std::string filename = Utils::combinePath(collectionPath, "include.txt");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream includeFile;
@@ -99,7 +99,7 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
includeFile << "# by settings.conf will be used" << std::endl;
includeFile.close();
filename = Utils::CombinePath(collectionPath, "exclude.txt");
filename = Utils::combinePath(collectionPath, "exclude.txt");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream excludeFile;
excludeFile.open(filename.c_str());
@@ -107,31 +107,31 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
includeFile << "# Add a list of files to hide on the menu (one filename per line, without the extension)." << std::endl;
excludeFile.close();
filename = Utils::CombinePath(collectionPath, "settings.conf");
filename = Utils::combinePath(collectionPath, "settings.conf");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream settingsFile;
settingsFile.open(filename.c_str());
settingsFile << "# Uncomment and edit the following line to use a different ROM path." << std::endl;
settingsFile << "#list.path = " << Utils::CombinePath("%BASE_ITEM_PATH%", "%ITEM_COLLECTION_NAME%", "roms") << std::endl;
settingsFile << "#list.path = " << Utils::combinePath("%BASE_ITEM_PATH%", "%ITEM_COLLECTION_NAME%", "roms") << std::endl;
settingsFile << "list.includeMissingItems = false" << std::endl;
settingsFile << "list.extensions = zip" << std::endl;
settingsFile << "launcher = mame" << std::endl;
settingsFile << "metadata.type = MAME" << std::endl;
settingsFile << std::endl;
settingsFile << "#media.screenshot = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.artwork_back = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_back") << std::endl;
settingsFile << "#media.artwork_front = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_front") << std::endl;
settingsFile << "#media.logo = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "logo") << std::endl;
settingsFile << "#media.medium_back = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_back") << std::endl;
settingsFile << "#media.medium_front = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_front") << std::endl;
settingsFile << "#media.screenshot = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.video = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "video") << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.artwork_back = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_back") << std::endl;
settingsFile << "#media.artwork_front = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_front") << std::endl;
settingsFile << "#media.logo = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "logo") << std::endl;
settingsFile << "#media.medium_back = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_back") << std::endl;
settingsFile << "#media.medium_front = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_front") << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.video = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "video") << std::endl;
settingsFile.close();
filename = Utils::CombinePath(collectionPath, "menu.xml");
filename = Utils::combinePath(collectionPath, "menu.xml");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream menuFile;
menuFile.open(filename.c_str());
@@ -151,7 +151,7 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
return true;
}
CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name)
{
std::string listItemsPathKey = "collections." + name + ".list.path";
std::string listFilterKey = "collections." + name + ".list.filter";
@@ -168,12 +168,12 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
std::string metadataType = name;
std::string metadataPath;
Conf.GetCollectionAbsolutePath(name, listItemsPath);
(void)Conf.GetProperty(extensionsKey, extensions);
(void)Conf.GetProperty(metadataTypeKey, metadataType);
(void)Conf.GetProperty(metadataPathKey, metadataPath);
conf_.getCollectionAbsolutePath(name, listItemsPath);
(void)conf_.getProperty(extensionsKey, extensions);
(void)conf_.getProperty(metadataTypeKey, metadataType);
(void)conf_.getProperty(metadataPathKey, metadataPath);
if(!Conf.GetProperty(launcherKey, launcherName))
if(!conf_.getProperty(launcherKey, launcherName))
{
std::stringstream ss;
ss << "\""
@@ -183,7 +183,7 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
<< "). Your collection will be viewable, however you will not be able to "
<< "launch any of the items in your collection.";
Logger::Write(Logger::ZONE_NOTICE, "Collections", ss.str());
Logger::write(Logger::ZONE_NOTICE, "Collections", ss.str());
}
CollectionInfo *collection = new CollectionInfo(name, listItemsPath, extensions, metadataType, metadataPath);
@@ -207,7 +207,7 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
while(std::getline(includeStream, line))
{
line = Utils::FilterComments(line);
line = Utils::filterComments(line);
if(!line.empty() && list.find(line) == list.end())
{
@@ -215,10 +215,10 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
i->FullTitle = line;
i->Name = line;
i->Title = line;
i->Launcher = launcher;
i->fullTitle = line;
i->name = line;
i->title = line;
i->launcher = launcher;
list[line] = i;
}
@@ -231,16 +231,16 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
{
DIR *dp;
struct dirent *dirp;
std::string path = info->ListPath;
std::string path = info->listpath;
std::map<std::string, Item *> includeFilter;
std::map<std::string, Item *> excludeFilter;
std::string includeFile = Utils::CombinePath(Configuration::AbsolutePath, "collections", info->Name, "include.txt");
std::string excludeFile = Utils::CombinePath(Configuration::AbsolutePath, "collections", info->Name, "exclude.txt");
std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "include.txt");
std::string excludeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "exclude.txt");
std::string launcher;
bool showMissing = false;
(void)Conf.GetProperty("collections." + info->Name + ".launcher", launcher);
(void)Conf.GetProperty("collections." + info->Name + ".list.includeMissingItems", showMissing);
(void)conf_.getProperty("collections." + info->name + ".launcher", launcher);
(void)conf_.getProperty("collections." + info->name + ".list.includeMissingItems", showMissing);
ImportBasicList(info, includeFile, launcher, includeFilter);
ImportBasicList(info, excludeFile, launcher, excludeFilter);
@@ -248,15 +248,15 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
std::vector<std::string> extensions;
std::vector<std::string>::iterator extensionsIt;
info->GetExtensions(extensions);
info->extensionList(extensions);
Logger::Write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\"");
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\"");
dp = opendir(path.c_str());
if(dp == NULL)
{
Logger::Write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Could not read directory \"" + path + "\". Ignore if this is a menu.");
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Could not read directory \"" + path + "\". Ignore if this is a menu.");
return false;
}
@@ -266,7 +266,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
{
if(excludeFilter.find(it->first) == excludeFilter.end())
{
info->Items.push_back(it->second);
info->items.push_back(it->second);
}
}
}
@@ -294,11 +294,11 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
if(file.compare(start, comparator.length(), *extensionsIt) == 0)
{
Item *i = new Item();
i->Name = basename;
i->FullTitle = basename;
i->Title = basename;
i->Launcher = launcher;
info->Items.push_back(i);
i->name = basename;
i->fullTitle = basename;
i->title = basename;
i->launcher = launcher;
info->items.push_back(i);
}
}
}
@@ -324,9 +324,9 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
excludeFilter.erase(it);
}
MetaDB.InjectMetadata(info);
metaDB_.injectMetadata(info);
info->SortItems();
info->sortItems();
return true;
}

View File

@@ -29,12 +29,12 @@ class CollectionInfoBuilder
public:
CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb);
virtual ~CollectionInfoBuilder();
CollectionInfo *BuildCollection(std::string collectionName);
static bool CreateCollectionDirectory(std::string collectionName);
CollectionInfo *buildCollection(std::string collectionName);
static bool createCollectionDirectory(std::string collectionName);
private:
Configuration &Conf;
MetadataDatabase &MetaDB;
Configuration &conf_;
MetadataDatabase &metaDB_;
bool ImportBasicList(CollectionInfo *info, std::string file, std::string launcher, std::map<std::string, Item *> &list);
bool ImportDirectory(CollectionInfo *info);
};

View File

@@ -20,7 +20,7 @@
#include <algorithm>
Item::Item()
: Leaf(true)
: leaf(true)
{
}
@@ -28,23 +28,23 @@ Item::~Item()
{
}
std::string Item::FileName()
std::string Item::filename()
{
return Utils::GetFileName(FilePath);
return Utils::getFileName(filepath);
}
std::string Item::LCTitle()
std::string Item::lowercaseTitle()
{
std::string lcstr = Title;
std::string lcstr = title;
std::transform(lcstr.begin(), lcstr.end(), lcstr.begin(), ::tolower);
return lcstr;
}
std::string Item::LCFullTitle()
std::string Item::lowercaseFullTitle()
{
std::string lcstr = FullTitle;
std::string lcstr = fullTitle;
std::transform(lcstr.begin(), lcstr.end(), lcstr.begin(), ::tolower);
return lcstr;
}

View File

@@ -22,20 +22,20 @@ class Item
public:
Item();
virtual ~Item();
std::string FileName();
std::string LCTitle() ;
std::string LCFullTitle();
std::string Name;
std::string Launcher;
std::string FilePath;
std::string Title;
std::string FullTitle;
std::string Year;
std::string Manufacturer;
std::string Genre;
std::string CloneOf;
std::string NumberPlayers;
std::string NumberButtons;
bool Leaf;
std::string filename();
std::string lowercaseTitle() ;
std::string lowercaseFullTitle();
std::string name;
std::string launcher;
std::string filepath;
std::string title;
std::string fullTitle;
std::string year;
std::string manufacturer;
std::string genre;
std::string cloneof;
std::string numberPlayers;
std::string numberButtons;
bool leaf;
};

View File

@@ -28,7 +28,7 @@
bool VectorSort(Item *d1, Item *d2)
{
return d1->LCTitle() < d2->LCTitle();
return d1->lowercaseTitle() < d2->lowercaseTitle();
}
MenuParser::MenuParser()
@@ -40,15 +40,15 @@ MenuParser::~MenuParser()
}
//todo: clean up this method, too much nesting
bool MenuParser::GetMenuItems(CollectionInfo *collection)
bool MenuParser::menuItems(CollectionInfo *collection)
{
bool retVal = false;
//todo: magic string
std::string menuFilename = Utils::CombinePath(Configuration::AbsolutePath, "collections", collection->Name, "menu.xml");
std::string menuFilename = Utils::combinePath(Configuration::absolutePath, "collections", collection->name, "menu.xml");
rapidxml::xml_document<> doc;
rapidxml::xml_node<> * rootNode;
Logger::Write(Logger::ZONE_INFO, "Menu", "Checking if menu exists at \"" + menuFilename + "\"");
Logger::write(Logger::ZONE_INFO, "Menu", "Checking if menu exists at \"" + menuFilename + "\"");
try
{
@@ -73,7 +73,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
if(!collectionAttribute)
{
retVal = false;
Logger::Write(Logger::ZONE_ERROR, "Menu", "Menu item tag is missing collection attribute");
Logger::write(Logger::ZONE_ERROR, "Menu", "Menu item tag is missing collection attribute");
break;
}
//todo: too much nesting! Ack!
@@ -88,17 +88,17 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
//todo, check for empty string
std::string title = collectionAttribute->value();
Item *item = new Item();
item->Title = title;
item->FullTitle = title;
item->Name = collectionAttribute->value();
item->Leaf = false;
collection->Items.push_back(item);
item->title = title;
item->fullTitle = title;
item->name = collectionAttribute->value();
item->leaf = false;
collection->items.push_back(item);
}
else
{
std::string collectionName = collectionAttribute->value();
Logger::Write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName);
Logger::write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName);
//todo: unsupported option with this refactor
// need to append the collection
@@ -106,7 +106,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
}
// todo: sorting should occur within the collection itself, not externally
std::vector<Item *> *items = &collection->Items;
std::vector<Item *> *items = &collection->items;
std::sort( items->begin(), items->end(), VectorSort);
retVal = true;
@@ -116,7 +116,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
{
std::stringstream ss;
ss << "Unable to open menu file \"" << menuFilename << "\": " << e.what();
Logger::Write(Logger::ZONE_ERROR, "Menu", ss.str());
Logger::write(Logger::ZONE_ERROR, "Menu", ss.str());
}
return retVal;

View File

@@ -22,6 +22,6 @@ class MenuParser
public:
MenuParser();
virtual ~MenuParser();
bool GetMenuItems(CollectionInfo *cdb);
bool menuItems(CollectionInfo *cdb);
};