Squashed 'src/univalue/' changes from f32df99..daf1285

daf1285 Merge pull request #2 from jgarzik/master
d9e62d3 Merge pull request #24 from MarcoFalke/Mf1608-cleanup
faf260f Rem unused vars and prefer prefix operator for non-primitive type
09a2693 Merge pull request #22 from laanwj/2016_04_unicode
c74a04c Merge pull request #23 from paveljanik/20160527_Wshadow
fceb4f8 Do not shadow variables

git-subtree-dir: src/univalue
git-subtree-split: daf1285af60c2c73801c0f41469c9802c849343d
This commit is contained in:
MarcoFalke 2016-09-25 15:19:23 +02:00
parent 60ab9b2006
commit 3650668cdb
2 changed files with 24 additions and 27 deletions

View file

@ -56,7 +56,7 @@ public:
bool setNumStr(const std::string& val);
bool setInt(uint64_t val);
bool setInt(int64_t val);
bool setInt(int val) { return setInt((int64_t)val); }
bool setInt(int val_) { return setInt((int64_t)val_); }
bool setFloat(double val);
bool setStr(const std::string& val);
bool setArray();
@ -95,28 +95,28 @@ public:
bool push_backV(const std::vector<UniValue>& vec);
bool pushKV(const std::string& key, const UniValue& val);
bool pushKV(const std::string& key, const std::string& val) {
UniValue tmpVal(VSTR, val);
bool pushKV(const std::string& key, const std::string& val_) {
UniValue tmpVal(VSTR, val_);
return pushKV(key, tmpVal);
}
bool pushKV(const std::string& key, const char *val_) {
std::string val(val_);
return pushKV(key, val);
std::string _val(val_);
return pushKV(key, _val);
}
bool pushKV(const std::string& key, int64_t val) {
UniValue tmpVal(val);
bool pushKV(const std::string& key, int64_t val_) {
UniValue tmpVal(val_);
return pushKV(key, tmpVal);
}
bool pushKV(const std::string& key, uint64_t val) {
UniValue tmpVal(val);
bool pushKV(const std::string& key, uint64_t val_) {
UniValue tmpVal(val_);
return pushKV(key, tmpVal);
}
bool pushKV(const std::string& key, int val) {
UniValue tmpVal((int64_t)val);
bool pushKV(const std::string& key, int val_) {
UniValue tmpVal((int64_t)val_);
return pushKV(key, tmpVal);
}
bool pushKV(const std::string& key, double val) {
UniValue tmpVal(val);
bool pushKV(const std::string& key, double val_) {
UniValue tmpVal(val_);
return pushKV(key, tmpVal);
}
bool pushKVs(const UniValue& obj);

View file

@ -119,32 +119,29 @@ bool UniValue::setNumStr(const string& val_)
return true;
}
bool UniValue::setInt(uint64_t val)
bool UniValue::setInt(uint64_t val_)
{
string s;
ostringstream oss;
oss << val;
oss << val_;
return setNumStr(oss.str());
}
bool UniValue::setInt(int64_t val)
bool UniValue::setInt(int64_t val_)
{
string s;
ostringstream oss;
oss << val;
oss << val_;
return setNumStr(oss.str());
}
bool UniValue::setFloat(double val)
bool UniValue::setFloat(double val_)
{
string s;
ostringstream oss;
oss << std::setprecision(16) << val;
oss << std::setprecision(16) << val_;
bool ret = setNumStr(oss.str());
typ = VNUM;
@ -173,12 +170,12 @@ bool UniValue::setObject()
return true;
}
bool UniValue::push_back(const UniValue& val)
bool UniValue::push_back(const UniValue& val_)
{
if (typ != VARR)
return false;
values.push_back(val);
values.push_back(val_);
return true;
}
@ -192,13 +189,13 @@ bool UniValue::push_backV(const std::vector<UniValue>& vec)
return true;
}
bool UniValue::pushKV(const std::string& key, const UniValue& val)
bool UniValue::pushKV(const std::string& key, const UniValue& val_)
{
if (typ != VOBJ)
return false;
keys.push_back(key);
values.push_back(val);
values.push_back(val_);
return true;
}
@ -228,7 +225,7 @@ int UniValue::findKey(const std::string& key) const
bool UniValue::checkObject(const std::map<std::string,UniValue::VType>& t)
{
for (std::map<std::string,UniValue::VType>::const_iterator it = t.begin();
it != t.end(); it++) {
it != t.end(); ++it) {
int idx = findKey(it->first);
if (idx < 0)
return false;