mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-07-08 01:30:39 +08:00
Add parse bool
This commit is contained in:
@@ -131,3 +131,12 @@ std::string str_util::str_join(std::list<std::string> input, std::string pattern
|
|||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool str_util::parse_bool(std::string input) {
|
||||||
|
input = tolower(input);
|
||||||
|
if (input == "true" || input == "yes" || input == "on" || input == "1") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -79,5 +79,11 @@ namespace str_util {
|
|||||||
* @return Result
|
* @return Result
|
||||||
*/
|
*/
|
||||||
std::string str_join(std::list<std::string> input, std::string pattern);
|
std::string str_join(std::list<std::string> input, std::string pattern);
|
||||||
|
/**
|
||||||
|
* @brief Parse a string to a boolean
|
||||||
|
* @param input Input string
|
||||||
|
* @return Result
|
||||||
|
*/
|
||||||
|
bool parse_bool(std::string input);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user