MCPcopy Create free account
hub / github.com/SOCI/soci / parse10

Function parse10

src/core/common.cpp:19–40  ·  view source on GitHub ↗

helper function for parsing decimal data (for std::tm)

Source from the content-addressed store, hash-verified

17
18// helper function for parsing decimal data (for std::tm)
19int parse10(char const * & p1, char * & p2)
20{
21 long v = std::strtol(p1, &p2, 10);
22 if (p2 != p1)
23 {
24 if (v < 0)
25 throw soci::soci_error("Negative date/time field component.");
26
27 if (v > INT_MAX)
28 throw soci::soci_error("Out of range date/time field component.");
29
30 p1 = p2 + 1;
31
32 // Cast is safe due to check above.
33 return static_cast<int>(v);
34 }
35 else
36 {
37 throw soci::soci_error("Cannot parse date/time field component.");
38
39 }
40}
41
42} // namespace anonymous
43

Callers 1

parse_std_tmMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected