aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-04-06 09:27:13 +0000
committerMax Horn2010-04-06 09:27:13 +0000
commit7c510f2dfa1191ea76633e667ef302a6b6ed949b (patch)
treeacda4f602d6a1fc50df25ce2cd99e35a55e806b4
parent77c1e0dfe1185bd4f807436480a944ef7da2bbf2 (diff)
downloadscummvm-rg350-7c510f2dfa1191ea76633e667ef302a6b6ed949b.tar.gz
scummvm-rg350-7c510f2dfa1191ea76633e667ef302a6b6ed949b.tar.bz2
scummvm-rg350-7c510f2dfa1191ea76633e667ef302a6b6ed949b.zip
COMMON: Add Common::parseBool
svn-id: r48566
-rw-r--r--common/util.cpp21
-rw-r--r--common/util.h12
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 {