diff options
author | MacroFake <falke.marco@gmail.com> | 2022-07-14 18:03:22 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-07-18 10:37:00 +0200 |
commit | fafab147e7ff41ab1b961349f20a364f6bf847d2 (patch) | |
tree | a54d15f179e54f278df62ef51421480ad793ef91 /src | |
parent | 4e2929e987fc71c1df9d109210bd2527ccefca34 (diff) |
move-only: Move UniValue::getInt definition to keep class with definitions only
Can be reviewed with the git options
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
Diffstat (limited to 'src')
-rw-r--r-- | src/univalue/include/univalue.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index 5cb8268472..b665954927 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -116,19 +116,7 @@ public: const std::vector<std::string>& getKeys() const; const std::vector<UniValue>& getValues() const; template <typename Int> - auto getInt() const - { - static_assert(std::is_integral<Int>::value); - if (typ != VNUM) { - throw std::runtime_error("JSON value is not an integer as expected"); - } - Int result; - const auto [first_nonmatching, error_condition] = std::from_chars(val.data(), val.data() + val.size(), result); - if (first_nonmatching != val.data() + val.size() || error_condition != std::errc{}) { - throw std::runtime_error("JSON integer out of range"); - } - return result; - } + Int getInt() const; bool get_bool() const; const std::string& get_str() const; double get_real() const; @@ -146,6 +134,21 @@ void UniValue::push_backV(It first, It last) values.insert(values.end(), first, last); } +template <typename Int> +Int UniValue::getInt() const +{ + static_assert(std::is_integral<Int>::value); + if (typ != VNUM) { + throw std::runtime_error("JSON value is not an integer as expected"); + } + Int result; + const auto [first_nonmatching, error_condition] = std::from_chars(val.data(), val.data() + val.size(), result); + if (first_nonmatching != val.data() + val.size() || error_condition != std::errc{}) { + throw std::runtime_error("JSON integer out of range"); + } + return result; +} + enum jtokentype { JTOK_ERR = -1, JTOK_NONE = 0, // eof |