Changeset View
Changeset View
Standalone View
Standalone View
src/univalue/include/univalue.h
Show All 9 Lines | |||||
#include <string.h> | #include <string.h> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
#include <map> | #include <map> | ||||
#include <cassert> | #include <cassert> | ||||
#include <sstream> // .get_int64() | #include <sstream> // .get_int64() | ||||
#include <utility> // std::pair | |||||
class UniValue { | class UniValue { | ||||
public: | public: | ||||
enum VType { VNULL, VOBJ, VARR, VSTR, VNUM, VBOOL, }; | enum VType { VNULL, VOBJ, VARR, VSTR, VNUM, VBOOL, }; | ||||
UniValue() { typ = VNULL; } | UniValue() { typ = VNULL; } | ||||
UniValue(UniValue::VType initialType, const std::string& initialStr = "") { | UniValue(UniValue::VType initialType, const std::string& initialStr = "") { | ||||
typ = initialType; | typ = initialType; | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | public: | ||||
const std::string& get_str() const; | const std::string& get_str() const; | ||||
int get_int() const; | int get_int() const; | ||||
int64_t get_int64() const; | int64_t get_int64() const; | ||||
double get_real() const; | double get_real() const; | ||||
const UniValue& get_obj() const; | const UniValue& get_obj() const; | ||||
const UniValue& get_array() const; | const UniValue& get_array() const; | ||||
enum VType type() const { return getType(); } | enum VType type() const { return getType(); } | ||||
bool push_back(std::pair<std::string,UniValue> pear) { | |||||
return pushKV(pear.first, pear.second); | |||||
} | |||||
friend const UniValue& find_value( const UniValue& obj, const std::string& name); | friend const UniValue& find_value( const UniValue& obj, const std::string& name); | ||||
}; | }; | ||||
// | |||||
// The following were added for compatibility with json_spirit. | |||||
// Most duplicate other methods, and should be removed. | |||||
// | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, const char *cVal) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(cVal); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, std::string strVal) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(strVal); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, uint64_t u64Val) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(u64Val); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, int64_t i64Val) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(i64Val); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, bool iVal) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(iVal); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, int iVal) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(iVal); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, double dVal) | |||||
{ | |||||
std::string key(cKey); | |||||
UniValue uVal(dVal); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(const char *cKey, const UniValue& uVal) | |||||
{ | |||||
std::string key(cKey); | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
static inline std::pair<std::string,UniValue> Pair(std::string key, const UniValue& uVal) | |||||
{ | |||||
return std::make_pair(key, uVal); | |||||
} | |||||
enum jtokentype { | enum jtokentype { | ||||
JTOK_ERR = -1, | JTOK_ERR = -1, | ||||
JTOK_NONE = 0, // eof | JTOK_NONE = 0, // eof | ||||
JTOK_OBJ_OPEN, | JTOK_OBJ_OPEN, | ||||
JTOK_OBJ_CLOSE, | JTOK_OBJ_CLOSE, | ||||
JTOK_ARR_OPEN, | JTOK_ARR_OPEN, | ||||
JTOK_ARR_CLOSE, | JTOK_ARR_CLOSE, | ||||
JTOK_COLON, | JTOK_COLON, | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |