Commits

dirtycold  committed 0b8d805

modified: update int conversion

  • Participants
  • Parent commits abf20a0

Comments (0)

Files changed (2)

File IniConfig/iniconfig.cpp

 double IniConfig::doubleValue(const std::string &key)
 {
     std::string s = value(key);
-    if (s.empty())
-        return RP::NaN;
-    else
+    if (!s.empty())
         return RP::toDouble(s);
+    else
+        return RP::NaN;
 }
 
 int IniConfig::intValue(const std::string &key)
 {
-    double r = doubleValue(key);
-    if (r != RP::NaN)
-        return RP::round(r);
+    std::string s = value(key);
+    if (!s.empty())
+        return toInt(s);
     else
         return int(RP::NaN);
 }

File IniConfig/iniconfig.h

     return d;
 }
 
-static inline int toInt(const std::string &s)
+static inline int toInt(const std::string &s, unsigned int base = 10)
 {
-    return int(toDouble(s));
+    int i = strtol(s.c_str(),NULL,base);
+    return i;
 }
 
 static inline std::vector<double> toDataSeries(const std::string &s)