mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
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
This commit is contained in:
parent
4e2929e987
commit
fafab147e7
1 changed files with 16 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue