diff options
-rw-r--r-- | common/util.cpp | 21 | ||||
-rw-r--r-- | common/util.h | 12 |
2 files changed, 33 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp index 518c6a70b8..19e727d672 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -84,6 +84,27 @@ void hexdump(const byte * data, int len, int bytesPerLine, int startOffset) { #pragma mark - +bool parseBool(const Common::String &val, bool &valAsBool) { + if (val.equalsIgnoreCase("true") || + val.equalsIgnoreCase("yes") || + val.equals("1")) { + valAsBool = true; + return true; + } + if (val.equalsIgnoreCase("false") || + val.equalsIgnoreCase("no") || + val.equals("0")) { + valAsBool = false; + return true; + } + + return false; +} + + +#pragma mark - + + const LanguageDescription g_languages[] = { {"zh-cn", "Chinese (China)", ZH_CNA}, {"zh", "Chinese (Taiwan)", ZH_TWN}, diff --git a/common/util.h b/common/util.h index 3969945271..865f5e6217 100644 --- a/common/util.h +++ b/common/util.h @@ -77,6 +77,18 @@ extern void hexdump(const byte * data, int len, int bytesPerLine = 16, int start /** + * Parse a string for a boolean value. + * The strings "true", "yes", and "1" are interpreted as true. + * The strings "false", "no", and "0" are interpreted as false. + * This function ignores case. + * + * @param[in] val the string to parse + * @param[out] valAsBool the parsing result + * @return true if the string parsed correctly, false if an error occurred. + */ +bool parseBool(const Common::String &val, bool &valAsBool); + +/** * List of game language. */ enum Language { |