File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -33,16 +33,22 @@ std::string sanitizeUTF8(const std::string &str)
33
33
return convert_string<char >(str.data (), str.data () + str.size ());
34
34
}
35
35
36
+ // / return true if the given string represents a number
37
+ bool isNumber (const std::string &str)
38
+ {
39
+ static auto isDigit = [](unsigned char c){ return std::isdigit (c); };
40
+
41
+ return std::all_of (str.begin (), str.end (), isDigit);
42
+ }
43
+
36
44
// TODO: This should not necessary! TScanProps should be able to contain
37
45
// any type so that no conversions here are needed.
38
46
object jsonSerializeScanProps (const TScanProps &scanProps)
39
47
{
40
- static auto isDigit = [](unsigned char c){ return std::isdigit (c); };
41
-
42
48
object scan;
43
49
for (const auto &prop : scanProps) {
44
50
const auto &val = prop.second ;
45
- if (std::all_of (val. begin (), val. end (), isDigit ))
51
+ if (isNumber (val))
46
52
scan[prop.first ] = boost::lexical_cast<int >(val);
47
53
else
48
54
scan[prop.first ] = val;
You can’t perform that action at this time.
0 commit comments