mirror of https://github.com/libAthena/athena.git
* Parsebool
This commit is contained in:
parent
428438cf89
commit
164dff3926
|
@ -45,7 +45,7 @@ std::vector<std::string> split(const std::string &s, char delim);
|
|||
void tolower(std::string& str);
|
||||
void toupper(std::string& str);
|
||||
std::string sprintf(const char* fmt, ...);
|
||||
bool parseBool(const std::string& boolean, bool &valid);
|
||||
bool parseBool(const std::string& boolean, bool* valid = NULL);
|
||||
|
||||
int countChar(const std::string& str, const char chr, int* lastOccur = NULL);
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ std::string sprintf(const char* fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool parseBool(const std::string& boolean, bool &valid)
|
||||
bool parseBool(const std::string& boolean, bool* valid)
|
||||
{
|
||||
std::string val = boolean;
|
||||
// compare must be case insensitive
|
||||
|
@ -172,18 +172,26 @@ bool parseBool(const std::string& boolean, bool &valid)
|
|||
|
||||
// Check for true first
|
||||
if (!val.compare("true") || !val.compare("1") || !val.compare("yes") || !val.compare("on"))
|
||||
return (valid = true);
|
||||
{
|
||||
if (valid)
|
||||
*valid = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Now false
|
||||
if (!val.compare("false") || !val.compare("0") || !val.compare("no") || !val.compare("off"))
|
||||
{
|
||||
valid = true;
|
||||
if (valid)
|
||||
*valid = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Well that could've gone better
|
||||
|
||||
return (valid = false);
|
||||
if (valid)
|
||||
*valid = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int countChar(const std::string& str, const char chr, int* lastOccur)
|
||||
|
|
Loading…
Reference in New Issue