aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-10 14:06:06 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitc99b24c16d1111a701d915832f24ac457aef697d (patch)
tree9e812538728c8c7bd11ce06f2907cf1850e21df2 /common
parente6242b0be8fc9f9abc4daf87f80675cca46df4d9 (diff)
downloadscummvm-rg350-c99b24c16d1111a701d915832f24ac457aef697d.tar.gz
scummvm-rg350-c99b24c16d1111a701d915832f24ac457aef697d.tar.bz2
scummvm-rg350-c99b24c16d1111a701d915832f24ac457aef697d.zip
COMMON: Add String::asUint64()
Instead of all these atoull() I've added everywhere.
Diffstat (limited to 'common')
-rw-r--r--common/str.cpp9
-rw-r--r--common/str.h3
2 files changed, 12 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp
index 3ff49a90c6..326b4a80d1 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -335,6 +335,15 @@ bool String::contains(char x) const {
return strchr(c_str(), x) != NULL;
}
+uint64 String::asUint64() const {
+ uint64 result = 0;
+ for (uint32 i = 0; i < _size; ++i) {
+ if (_str[i] < '0' || _str[i] > '9') break;
+ result = result * 10L + (_str[i] - '0');
+ }
+ return result;
+}
+
bool String::matchString(const char *pat, bool ignoreCase, bool pathMode) const {
return Common::matchString(c_str(), pat, ignoreCase, pathMode);
}
diff --git a/common/str.h b/common/str.h
index 9ada8aaaa0..89b832d57e 100644
--- a/common/str.h
+++ b/common/str.h
@@ -162,6 +162,9 @@ public:
bool contains(const char *x) const;
bool contains(char x) const;
+ /** Return uint64 corrensponding to String's contents. */
+ uint64 asUint64() const;
+
/**
* Simple DOS-style pattern matching function (understands * and ? like used in DOS).
* Taken from exult/files/listfiles.cc