diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-01 00:58:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-01 00:58:39 +0300 |
commit | 4eeaa9b0aba548f8f4bd66c6f414884b8462a636 (patch) | |
tree | da5289ff16f1028b280f893b342b94bbc3810f23 /src/utils/stringutils.cpp | |
parent | e806fa54f2735bfb2587cb20f2836345384af070 (diff) | |
download | plus-4eeaa9b0aba548f8f4bd66c6f414884b8462a636.tar.gz plus-4eeaa9b0aba548f8f4bd66c6f414884b8462a636.tar.bz2 plus-4eeaa9b0aba548f8f4bd66c6f414884b8462a636.tar.xz plus-4eeaa9b0aba548f8f4bd66c6f414884b8462a636.zip |
Add string function for parse string into two strings.
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 13d6501da..d384ef28c 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -747,6 +747,24 @@ bool parse2Int(const std::string &args, int &x, int &y) return isValid; } +bool parse2Str(const std::string &args, std::string &str1, std::string &str2) +{ + bool isValid = false; + size_t pos = args.find(" "); + if (pos == std::string::npos) + pos = args.find(","); + if (pos != std::string::npos) + { + if (pos + 1 < args.length()) + { + str1 = args.substr(0, pos).c_str(); + str2 = args.substr(pos + 1, args.length()).c_str(); + isValid = true; + } + } + return isValid; +} + uint32_t parseNumber(const std::string &str) { uint32_t i = 0; |