]> git.stg.codes - stg.git/blobdiff - stglibs/common.lib/include/stg/common.h
Merge branch 'naffanya-dev'
[stg.git] / stglibs / common.lib / include / stg / common.h
index 605b9951de2296df54a25b4c43e44343ecc257c5..6af1309fab77bbe101c80c36831fd38187230d43 100644 (file)
@@ -103,6 +103,7 @@ std::string     ToLower(const std::string & value);
 std::string     ToUpper(const std::string & value);
 
 template <typename C, typename F>
+inline
 C Split(const std::string & value, char delim, F conv)
 {
 C res;
@@ -112,13 +113,14 @@ while (pos != std::string::npos)
     {
     res.push_back(conv(value.substr(startPos, pos - startPos)));
     startPos = pos + 1;
-    pos = value.find_first_of(delim, pos);
+    pos = value.find_first_of(delim, pos + 1);
     }
 res.push_back(conv(value.substr(startPos, pos - startPos)));
 return res;
 }
 
 template <typename T>
+inline
 T FromString(const std::string & value)
 {
 T res;
@@ -127,10 +129,18 @@ stream >> res;
 return res;
 }
 
+template <>
+inline
+std::string FromString<std::string>(const std::string & value)
+{
+return value;
+}
+
 template <typename C>
+inline
 C Split(const std::string & value, char delim)
 {
-    return Split<C>(value, delim, FromString);
+    return Split<C>(value, delim, FromString<typename C::value_type>);
 }
 
 std::string IconvString(const std::string & source, const std::string & from, const std::string & to);