77#define __UNIVALUE_H__
88
99#include < stdint.h>
10+ #include < string.h>
1011
1112#include < string>
1213#include < vector>
1314#include < map>
1415#include < cassert>
1516
1617#include < sstream> // .get_int64()
17- #include < utility> // std::pair
1818
1919class UniValue {
2020public:
@@ -47,7 +47,6 @@ class UniValue {
4747 std::string s (val_);
4848 setStr (s);
4949 }
50- ~UniValue () {}
5150
5251 void clear ();
5352
@@ -69,7 +68,8 @@ class UniValue {
6968 size_t size () const { return values.size (); }
7069
7170 bool getBool () const { return isTrue (); }
72- bool checkObject (const std::map<std::string,UniValue::VType>& memberTypes);
71+ void getObjMap (std::map<std::string,UniValue>& kv) const ;
72+ bool checkObject (const std::map<std::string,UniValue::VType>& memberTypes) const ;
7373 const UniValue& operator [](const std::string& key) const ;
7474 const UniValue& operator [](size_t index) const ;
7575 bool exists (const std::string& key) const { size_t i; return findKey (key, i); }
@@ -104,8 +104,13 @@ class UniValue {
104104 UniValue tmpVal (val_);
105105 return push_back (tmpVal);
106106 }
107+ bool push_back (double val_) {
108+ UniValue tmpVal (val_);
109+ return push_back (tmpVal);
110+ }
107111 bool push_backV (const std::vector<UniValue>& vec);
108112
113+ void __pushKV (const std::string& key, const UniValue& val);
109114 bool pushKV (const std::string& key, const UniValue& val);
110115 bool pushKV (const std::string& key, const std::string& val_) {
111116 UniValue tmpVal (VSTR, val_);
@@ -123,6 +128,10 @@ class UniValue {
123128 UniValue tmpVal (val_);
124129 return pushKV (key, tmpVal);
125130 }
131+ bool pushKV (const std::string& key, bool val_) {
132+ UniValue tmpVal ((bool )val_);
133+ return pushKV (key, tmpVal);
134+ }
126135 bool pushKV (const std::string& key, int val_) {
127136 UniValue tmpVal ((int64_t )val_);
128137 return pushKV (key, tmpVal);
@@ -137,7 +146,7 @@ class UniValue {
137146 unsigned int indentLevel = 0 ) const ;
138147
139148 bool read (const char *raw, size_t len);
140- bool read (const char *raw);
149+ bool read (const char *raw) { return read (raw, strlen (raw)); }
141150 bool read (const std::string& rawStr) {
142151 return read (rawStr.data (), rawStr.size ());
143152 }
@@ -166,76 +175,9 @@ class UniValue {
166175 const UniValue& get_array () const ;
167176
168177 enum VType type () const { return getType (); }
169- bool push_back (std::pair<std::string,UniValue> pear) {
170- return pushKV (pear.first , pear.second );
171- }
172178 friend const UniValue& find_value ( const UniValue& obj, const std::string& name);
173179};
174180
175- //
176- // The following were added for compatibility with json_spirit.
177- // Most duplicate other methods, and should be removed.
178- //
179- static inline std::pair<std::string,UniValue> Pair (const char *cKey, const char *cVal)
180- {
181- std::string key (cKey);
182- UniValue uVal (cVal);
183- return std::make_pair (key, uVal);
184- }
185-
186- static inline std::pair<std::string,UniValue> Pair (const char *cKey, std::string strVal)
187- {
188- std::string key (cKey);
189- UniValue uVal (strVal);
190- return std::make_pair (key, uVal);
191- }
192-
193- static inline std::pair<std::string,UniValue> Pair (const char *cKey, uint64_t u64Val)
194- {
195- std::string key (cKey);
196- UniValue uVal (u64Val);
197- return std::make_pair (key, uVal);
198- }
199-
200- static inline std::pair<std::string,UniValue> Pair (const char *cKey, int64_t i64Val)
201- {
202- std::string key (cKey);
203- UniValue uVal (i64Val);
204- return std::make_pair (key, uVal);
205- }
206-
207- static inline std::pair<std::string,UniValue> Pair (const char *cKey, bool iVal)
208- {
209- std::string key (cKey);
210- UniValue uVal (iVal);
211- return std::make_pair (key, uVal);
212- }
213-
214- static inline std::pair<std::string,UniValue> Pair (const char *cKey, int iVal)
215- {
216- std::string key (cKey);
217- UniValue uVal (iVal);
218- return std::make_pair (key, uVal);
219- }
220-
221- static inline std::pair<std::string,UniValue> Pair (const char *cKey, double dVal)
222- {
223- std::string key (cKey);
224- UniValue uVal (dVal);
225- return std::make_pair (key, uVal);
226- }
227-
228- static inline std::pair<std::string,UniValue> Pair (const char *cKey, const UniValue& uVal)
229- {
230- std::string key (cKey);
231- return std::make_pair (key, uVal);
232- }
233-
234- static inline std::pair<std::string,UniValue> Pair (std::string key, const UniValue& uVal)
235- {
236- return std::make_pair (key, uVal);
237- }
238-
239181enum jtokentype {
240182 JTOK_ERR = -1 ,
241183 JTOK_NONE = 0 , // eof
0 commit comments