NPOS macro
This commit is contained in:
@@ -13,10 +13,10 @@ std::string ConfigParser::_pre_set_val_check(const std::string key, \
|
||||
// check values for ; at end and right number of words depending on key
|
||||
|
||||
// std::cout << "pre check\n";
|
||||
if (key.find_first_of(";") != std::string::npos)
|
||||
if (key.find_first_of(";") != NPOS)
|
||||
throw std::invalid_argument("bad config file arguments 2");
|
||||
|
||||
if (value.find_first_of("\t") != std::string::npos)
|
||||
if (value.find_first_of("\t") != NPOS)
|
||||
throw std::invalid_argument("why would you put tabs between values");
|
||||
|
||||
size_t i = value.find_first_of(";");
|
||||
@@ -24,7 +24,7 @@ std::string ConfigParser::_pre_set_val_check(const std::string key, \
|
||||
// you can't have just ;
|
||||
// and you can't have a ; not at the end or several ;
|
||||
// in theory value_find_last_of should find the only ;
|
||||
if (i == std::string::npos || (value.find_last_not_of(" \n")) != i \
|
||||
if (i == NPOS || (value.find_last_not_of(" \n")) != i \
|
||||
|| value.compare(";") == 0)
|
||||
throw std::invalid_argument("bad config file arguments 4");
|
||||
|
||||
@@ -38,9 +38,9 @@ std::string ConfigParser::_get_first_word(size_t *curr)
|
||||
{
|
||||
size_t start;
|
||||
|
||||
if ((start = _content.find_first_not_of(" \t\n", *curr)) == std::string::npos)
|
||||
if ((start = _content.find_first_not_of(" \t\n", *curr)) == NPOS)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
if ((*curr = _content.find_first_of(" \t\n", start)) == std::string::npos)
|
||||
if ((*curr = _content.find_first_of(" \t\n", start)) == NPOS)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
|
||||
std::string key = _content.substr(start, *curr - start);
|
||||
@@ -53,9 +53,9 @@ std::string ConfigParser::_get_rest_of_line(size_t *curr)
|
||||
{
|
||||
size_t start;
|
||||
|
||||
if ((start = _content.find_first_not_of(" \t\n", *curr)) == std::string::npos)
|
||||
if ((start = _content.find_first_not_of(" \t\n", *curr)) == NPOS)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
if ((*curr = _content.find_first_of("\n", start)) == std::string::npos)
|
||||
if ((*curr = _content.find_first_of("\n", start)) == NPOS)
|
||||
throw std::invalid_argument("bad config file arguments");
|
||||
|
||||
std::string values = _content.substr(start, *curr - start);
|
||||
|
||||
Reference in New Issue
Block a user