25 if (str.size() != strlen(str.c_str()))
36 long int n = strtol(str.c_str(), &endp, 10);
41 return endp && *endp == 0 && !errno &&
42 n >= std::numeric_limits<int32_t>::min() &&
43 n <= std::numeric_limits<int32_t>::max();
52 long long int n = strtoll(str.c_str(), &endp, 10);
56 return endp && *endp == 0 && !errno &&
57 n >= std::numeric_limits<int64_t>::min() &&
58 n <= std::numeric_limits<int64_t>::max();
65 if (str.size() >= 2 && str[0] ==
'0' && str[1] ==
'x')
67 std::istringstream text(str);
68 text.imbue(std::locale::classic());
72 return text.eof() && !text.fail();
106 unsigned int consumed;
129 return setNumStr(oss.str());
139 return setNumStr(oss.str());
147 oss << std::setprecision(16) << val;
149 bool ret = setNumStr(oss.str());
181 values.push_back(val);
190 values.insert(values.end(), vec.begin(), vec.end());
201 values.push_back(val);
207 if (typ != VOBJ || obj.
typ != VOBJ)
210 for (
unsigned int i = 0; i < obj.
keys.size(); i++) {
211 keys.push_back(obj.
keys[i]);
212 values.push_back(obj.
values.at(i));
220 for (
unsigned int i = 0; i < keys.size(); i++) {
230 for (std::map<std::string,UniValue::VType>::const_iterator it = t.begin();
231 it != t.end(); it++) {
232 int idx = findKey(it->first);
236 if (values.at(idx).getType() != it->second)
248 int index = findKey(
key);
252 return values.at(index);
257 if (typ != VOBJ && typ != VARR)
259 if (index >= values.size())
262 return values.at(index);
282 for (
unsigned int i = 0; i < obj.
keys.size(); i++)
292 throw std::runtime_error(
"JSON value is not an object as expected");
298 if (typ != VOBJ && typ != VARR)
299 throw std::runtime_error(
"JSON value is not an object or array as expected");
306 throw std::runtime_error(
"JSON value is not a boolean as expected");
313 throw std::runtime_error(
"JSON value is not a string as expected");
320 throw std::runtime_error(
"JSON value is not an integer as expected");
323 throw std::runtime_error(
"JSON integer out of range");
330 throw std::runtime_error(
"JSON value is not an integer as expected");
333 throw std::runtime_error(
"JSON integer out of range");
340 throw std::runtime_error(
"JSON value is not a number as expected");
343 throw std::runtime_error(
"JSON double out of range");
350 throw std::runtime_error(
"JSON value is not an object as expected");
357 throw std::runtime_error(
"JSON value is not an array as expected");
bool push_backV(const std::vector< UniValue > &vec)
bool setFloat(double val)
const char * uvTypeName(UniValue::VType t)
bool ParseDouble(const std::string &str, double *out)
bool push_back(const UniValue &val)
bool pushKV(const std::string &key, const UniValue &val)
static bool json_isspace(int ch)
int64_t get_int64() const
bool setInt(uint64_t val)
bool ParseInt64(const std::string &str, int64_t *out)
const UniValue & get_obj() const
std::vector< std::string > getKeys() const
bool ParseInt32(const std::string &str, int32_t *out)
enum jtokentype getJsonToken(std::string &tokenVal, unsigned int &consumed, const char *raw)
int findKey(const std::string &key) const
std::vector< std::string > keys
bool setStr(const std::string &val)
const UniValue & operator[](const std::string &key) const
static bool ParsePrechecks(const std::string &str)
bool pushKVs(const UniValue &obj)
static bool validNumStr(const string &s)
const UniValue & find_value(const UniValue &obj, const std::string &name)
bool checkObject(const std::map< std::string, UniValue::VType > &memberTypes)
bool setNumStr(const std::string &val)
std::vector< UniValue > values
const UniValue & get_array() const
const UniValue NullUniValue
std::string get_str() const
std::vector< UniValue > getValues() const