File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 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)
3333 return convert_string<char >(str.data (), str.data () + str.size ());
3434}
3535
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+
3644// TODO: This should not necessary! TScanProps should be able to contain
3745// any type so that no conversions here are needed.
3846object jsonSerializeScanProps (const TScanProps &scanProps)
3947{
40- static auto isDigit = [](unsigned char c){ return std::isdigit (c); };
41-
4248 object scan;
4349 for (const auto &prop : scanProps) {
4450 const auto &val = prop.second ;
45- if (std::all_of (val. begin (), val. end (), isDigit ))
51+ if (isNumber (val))
4652 scan[prop.first ] = boost::lexical_cast<int >(val);
4753 else
4854 scan[prop.first ] = val;
You can’t perform that action at this time.
0 commit comments