mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-13 10:18:53 +01:00
Moving comment filtering to Utils class. Adding comment filtering to collection basic lists (include.txt, exclude.txt, etc).
This commit is contained in:
parent
f91fc16c6e
commit
b95c7c44f0
@ -203,12 +203,13 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
std::string line;
|
||||
|
||||
while(std::getline(includeStream, line))
|
||||
{
|
||||
|
||||
if(list.find(line) == list.end())
|
||||
line = Utils::FilterComments(line);
|
||||
|
||||
if(!line.empty() && list.find(line) == list.end())
|
||||
{
|
||||
Item *i = new Item();
|
||||
|
||||
|
||||
@ -117,12 +117,8 @@ bool Configuration::ParseLine(std::string keyPrefix, std::string line, int lineC
|
||||
std::string delimiter = "=";
|
||||
|
||||
// strip out any comments
|
||||
if((position = line.find("#")) != std::string::npos)
|
||||
{
|
||||
line = line.substr(0, position);
|
||||
}
|
||||
// unix only wants \n. Windows uses \r\n. Strip off the \r for unix.
|
||||
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
|
||||
line = Utils::FilterComments(line);
|
||||
|
||||
if(line.empty() || (line.find_first_not_of(" \t\r") == std::string::npos))
|
||||
{
|
||||
retVal = true;
|
||||
|
||||
@ -54,6 +54,20 @@ std::string Utils::UppercaseFirst(std::string str)
|
||||
|
||||
return str;
|
||||
}
|
||||
std::string Utils::FilterComments(std:;string line)
|
||||
{
|
||||
size_t position;
|
||||
|
||||
// strip out any comments
|
||||
if((position = line.find("#")) != std::string::npos)
|
||||
{
|
||||
line = line.substr(0, position);
|
||||
}
|
||||
// unix only wants \n. Windows uses \r\n. Strip off the \r for unix.
|
||||
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
std::string Utils::CombinePath(std::list<std::string> &paths)
|
||||
{
|
||||
|
||||
@ -33,6 +33,7 @@ public:
|
||||
static bool FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file);
|
||||
static std::string ToLower(std::string str);
|
||||
static std::string UppercaseFirst(std::string str);
|
||||
static std::string FilterComments(std::string line);
|
||||
|
||||
//todo: there has to be a better way to do this
|
||||
static std::string CombinePath(std::list<std::string> &paths);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user