| 21 | }; |
| 22 | |
| 23 | leaf::result<int> convert(const std::string& str) noexcept |
| 24 | { |
| 25 | if (str.empty()) |
| 26 | return leaf::new_error(ConversionErrc::EmptyString); |
| 27 | |
| 28 | if (!std::all_of(str.begin(), str.end(), ::isdigit)) |
| 29 | return leaf::new_error(ConversionErrc::IllegalChar); |
| 30 | |
| 31 | if (str.length() > 9) |
| 32 | return leaf::new_error(ConversionErrc::TooLong); |
| 33 | |
| 34 | return atoi(str.c_str()); |
| 35 | } |
| 36 | |
| 37 | // Do not static_store BigInt to actually work -- it's a stub. |
| 38 | struct BigInt |
no test coverage detected