]> git.stg.codes - stg.git/blobdiff - stglibs/common.lib/common.cpp
Добавлена специализация функций str2x для long и unsigned long (на
[stg.git] / stglibs / common.lib / common.cpp
index a5899dd2c2fdaaea9311b2ef3b1a81a648ab7ca9..eb39da6a8138d6611406ca76956416a7dc2a5491 100644 (file)
@@ -728,6 +728,26 @@ int str2x(const std::string & str, unsigned & x)
 {
 x = strtoul(str.c_str(), NULL, 10);
 
+if (errno == ERANGE)
+    return -1;
+
+return 0;
+}
+//---------------------------------------------------------------------------
+int str2x(const std::string & str, long & x)
+{
+x = strtol(str.c_str(), NULL, 10);
+
+if (errno == ERANGE)
+    return -1;
+
+return 0;
+}
+//---------------------------------------------------------------------------
+int str2x(const std::string & str, unsigned long & x)
+{
+x = strtoul(str.c_str(), NULL, 10);
+
 if (errno == ERANGE)
     return -1;