13 #ifndef __STOUT_NUMIFY_HPP__ 14 #define __STOUT_NUMIFY_HPP__ 19 #include <boost/lexical_cast.hpp> 37 bool maybeHex =
false;
45 return Error(
"Failed to convert '" + s +
"' to number");
50 return boost::lexical_cast<T>(s);
51 }
catch (
const boost::bad_lexical_cast&) {
58 ss << std::hex << s.substr(1);
68 #pragma warning(disable:4146) 72 #pragma warning(default:4146) 79 if (!ss.fail() && ss.eof()) {
84 return Error(
"Failed to convert '" + s +
"' to number");
92 return numify<T>(std::string(s));
111 #endif // __STOUT_NUMIFY_HPP__ Definition: errorbase.hpp:36
T & get()&
Definition: try.hpp:80
bool isSome() const
Definition: option.hpp:116
Try< T > numify(const std::string &s)
Definition: numify.hpp:29
bool contains(const std::string &s, const std::string &substr)
Definition: strings.hpp:423
bool isSome() const
Definition: try.hpp:77
const T & get() const &
Definition: option.hpp:119
static Try error(const E &e)
Definition: try.hpp:43
bool isError() const
Definition: try.hpp:78
bool startsWith(const std::string &s, const std::string &prefix)
Definition: strings.hpp:381