MCPcopy Create free account
hub / github.com/PRBonn/depth_clustering / num_from_string

Function num_from_string

src/utils/folder_reader.cpp:35–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33using boost::algorithm::starts_with;
34
35int num_from_string(const std::string& query_str) {
36 if (query_str.empty()) {
37 return 0;
38 }
39 const char* pattern = "\\d+";
40 boost::regex re(pattern);
41 boost::match_results<std::string::const_iterator> what;
42 auto start = query_str.begin();
43 auto end = query_str.end();
44 int found_num = 0;
45 while (boost::regex_search(start, end, what, re)) {
46 start = what[0].second;
47 found_num = std::stoi(what[0].str());
48 }
49 return found_num;
50}
51
52bool numeric_string_compare(const std::string& s1, const std::string& s2) {
53 return num_from_string(s1) < num_from_string(s2);

Callers 1

numeric_string_compareFunction · 0.85

Calls 3

beginMethod · 0.80
endMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected