From 38499e84fc771b21db7764ff4e014f7c3939d4b0 Mon Sep 17 00:00:00 2001 From: Alex Astashyn Date: Thu, 8 Dec 2016 21:38:14 -0500 Subject: [PATCH] Removed unused struct; fixed comments --- src/json.hpp | 69 +++++++++-------------------------------------- src/json.hpp.re2c | 69 +++++++++-------------------------------------- 2 files changed, 24 insertions(+), 114 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 79d6bb024..867afbb35 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -9065,12 +9065,6 @@ basic_json_parser_66: @brief parse string into a built-in arithmetic type as if the current locale is POSIX. - e.g. const auto x = static_cast("123.4"); - - throw if can't parse the entire string as a number, - or if the destination type is integral and the value - is outside of the type's range. - note: in floating-point case strtod may parse past the token's end - this is not an error. @@ -9079,34 +9073,15 @@ basic_json_parser_66: struct strtonum { public: - template - struct maybe - { - T x; - bool valid; - - maybe(const T& xx) - : x(xx), valid(true) - {} - - maybe() : x(), valid(false) - {} - - operator bool() const - { - return valid; - } - - const T& operator*() const - { - return x; - } - }; - strtonum(const char* start, const char* end) : m_start(start), m_end(end) {} + /// return true iff parsed successfully as + /// number of type T. + /// + /// @val shall contain parsed value, or + /// undefined value if could not parse. template::value>::type > @@ -9115,33 +9090,13 @@ basic_json_parser_66: return parse(val, std::is_integral()); } - template::value>::type > - operator T() const - { - T val{0}; - - if (parse(val, std::is_integral())) - { - return val; - } - - throw std::invalid_argument( - std::string() - + "Can't parse '" - + std::string(m_start, m_end) - + "' as type " - + typeid(T).name()); - } - - // return true iff token matches ^[+-]\d+$ - // - // this is a helper to determine whether to - // parse the token into floating-point or - // integral type. We wouldn't need it if - // we had separate token types for integral - // and floating-point cases. + /// return true iff token matches ^[+-]\d+$ + /// + /// this is a helper to determine whether to + /// parse the token into floating-point or + /// integral type. We wouldn't need it if + /// we had separate token types for integral + /// and floating-point cases. bool is_integral() const { const char* p = m_start; diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 24c549755..5b2dc8d2d 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -8214,12 +8214,6 @@ class basic_json @brief parse string into a built-in arithmetic type as if the current locale is POSIX. - e.g. const auto x = static_cast("123.4"); - - throw if can't parse the entire string as a number, - or if the destination type is integral and the value - is outside of the type's range. - note: in floating-point case strtod may parse past the token's end - this is not an error. @@ -8228,34 +8222,15 @@ class basic_json struct strtonum { public: - template - struct maybe - { - T x; - bool valid; - - maybe(const T& xx) - : x(xx), valid(true) - {} - - maybe() : x(), valid(false) - {} - - operator bool() const - { - return valid; - } - - const T& operator*() const - { - return x; - } - }; - strtonum(const char* start, const char* end) : m_start(start), m_end(end) {} + /// return true iff parsed successfully as + /// number of type T. + /// + /// @val shall contain parsed value, or + /// undefined value if could not parse. template::value>::type > @@ -8264,33 +8239,13 @@ class basic_json return parse(val, std::is_integral()); } - template::value>::type > - operator T() const - { - T val{0}; - - if (parse(val, std::is_integral())) - { - return val; - } - - throw std::invalid_argument( - std::string() - + "Can't parse '" - + std::string(m_start, m_end) - + "' as type " - + typeid(T).name()); - } - - // return true iff token matches ^[+-]\d+$ - // - // this is a helper to determine whether to - // parse the token into floating-point or - // integral type. We wouldn't need it if - // we had separate token types for integral - // and floating-point cases. + /// return true iff token matches ^[+-]\d+$ + /// + /// this is a helper to determine whether to + /// parse the token into floating-point or + /// integral type. We wouldn't need it if + /// we had separate token types for integral + /// and floating-point cases. bool is_integral() const { const char* p = m_start;