mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Squashed 'src/univalue/' changes from 51d3ab34ba..7890db99d6
7890db99d6 Merge #11: Remove deprecated std pair wrappers 40e34852ac Merge #14: Cleaned up namespace imports to reduce symbol collisions 85052a4819 Remove deprecated std::pair wrappers d208f986dd Cleaned up namespace imports to reduce symbol collisions git-subtree-dir: src/univalue git-subtree-split: 7890db99d693572d27ade3e14268bd7236134529
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
|
||||
#include "univalue.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const UniValue NullUniValue;
|
||||
|
||||
void UniValue::clear()
|
||||
@@ -37,15 +35,15 @@ bool UniValue::setBool(bool val_)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool validNumStr(const string& s)
|
||||
static bool validNumStr(const std::string& s)
|
||||
{
|
||||
string tokenVal;
|
||||
std::string tokenVal;
|
||||
unsigned int consumed;
|
||||
enum jtokentype tt = getJsonToken(tokenVal, consumed, s.data(), s.data() + s.size());
|
||||
return (tt == JTOK_NUMBER);
|
||||
}
|
||||
|
||||
bool UniValue::setNumStr(const string& val_)
|
||||
bool UniValue::setNumStr(const std::string& val_)
|
||||
{
|
||||
if (!validNumStr(val_))
|
||||
return false;
|
||||
@@ -58,7 +56,7 @@ bool UniValue::setNumStr(const string& val_)
|
||||
|
||||
bool UniValue::setInt(uint64_t val_)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << val_;
|
||||
|
||||
@@ -67,7 +65,7 @@ bool UniValue::setInt(uint64_t val_)
|
||||
|
||||
bool UniValue::setInt(int64_t val_)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << val_;
|
||||
|
||||
@@ -76,7 +74,7 @@ bool UniValue::setInt(int64_t val_)
|
||||
|
||||
bool UniValue::setFloat(double val_)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << std::setprecision(16) << val_;
|
||||
|
||||
@@ -85,7 +83,7 @@ bool UniValue::setFloat(double val_)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool UniValue::setStr(const string& val_)
|
||||
bool UniValue::setStr(const std::string& val_)
|
||||
{
|
||||
clear();
|
||||
typ = VSTR;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "univalue.h"
|
||||
#include "univalue_utffilter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static bool json_isdigit(int ch)
|
||||
{
|
||||
return ((ch >= '0') && (ch <= '9'));
|
||||
@@ -42,7 +40,7 @@ static const char *hatoui(const char *first, const char *last,
|
||||
return first;
|
||||
}
|
||||
|
||||
enum jtokentype getJsonToken(string& tokenVal, unsigned int& consumed,
|
||||
enum jtokentype getJsonToken(std::string& tokenVal, unsigned int& consumed,
|
||||
const char *raw, const char *end)
|
||||
{
|
||||
tokenVal.clear();
|
||||
@@ -114,7 +112,7 @@ enum jtokentype getJsonToken(string& tokenVal, unsigned int& consumed,
|
||||
case '8':
|
||||
case '9': {
|
||||
// part 1: int
|
||||
string numStr;
|
||||
std::string numStr;
|
||||
|
||||
const char *first = raw;
|
||||
|
||||
@@ -174,7 +172,7 @@ enum jtokentype getJsonToken(string& tokenVal, unsigned int& consumed,
|
||||
case '"': {
|
||||
raw++; // skip "
|
||||
|
||||
string valStr;
|
||||
std::string valStr;
|
||||
JSONUTF8StringFilter writer(valStr);
|
||||
|
||||
while (true) {
|
||||
@@ -255,9 +253,9 @@ bool UniValue::read(const char *raw, size_t size)
|
||||
clear();
|
||||
|
||||
uint32_t expectMask = 0;
|
||||
vector<UniValue*> stack;
|
||||
std::vector<UniValue*> stack;
|
||||
|
||||
string tokenVal;
|
||||
std::string tokenVal;
|
||||
unsigned int consumed;
|
||||
enum jtokentype tok = JTOK_NONE;
|
||||
enum jtokentype last_tok = JTOK_NONE;
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
#include "univalue.h"
|
||||
#include "univalue_escapes.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static string json_escape(const string& inS)
|
||||
static std::string json_escape(const std::string& inS)
|
||||
{
|
||||
string outS;
|
||||
std::string outS;
|
||||
outS.reserve(inS.size() * 2);
|
||||
|
||||
for (unsigned int i = 0; i < inS.size(); i++) {
|
||||
@@ -28,10 +26,10 @@ static string json_escape(const string& inS)
|
||||
return outS;
|
||||
}
|
||||
|
||||
string UniValue::write(unsigned int prettyIndent,
|
||||
unsigned int indentLevel) const
|
||||
std::string UniValue::write(unsigned int prettyIndent,
|
||||
unsigned int indentLevel) const
|
||||
{
|
||||
string s;
|
||||
std::string s;
|
||||
s.reserve(1024);
|
||||
|
||||
unsigned int modIndent = indentLevel;
|
||||
@@ -62,12 +60,12 @@ string UniValue::write(unsigned int prettyIndent,
|
||||
return s;
|
||||
}
|
||||
|
||||
static void indentStr(unsigned int prettyIndent, unsigned int indentLevel, string& s)
|
||||
static void indentStr(unsigned int prettyIndent, unsigned int indentLevel, std::string& s)
|
||||
{
|
||||
s.append(prettyIndent * indentLevel, ' ');
|
||||
}
|
||||
|
||||
void UniValue::writeArray(unsigned int prettyIndent, unsigned int indentLevel, string& s) const
|
||||
void UniValue::writeArray(unsigned int prettyIndent, unsigned int indentLevel, std::string& s) const
|
||||
{
|
||||
s += "[";
|
||||
if (prettyIndent)
|
||||
@@ -89,7 +87,7 @@ void UniValue::writeArray(unsigned int prettyIndent, unsigned int indentLevel, s
|
||||
s += "]";
|
||||
}
|
||||
|
||||
void UniValue::writeObject(unsigned int prettyIndent, unsigned int indentLevel, string& s) const
|
||||
void UniValue::writeObject(unsigned int prettyIndent, unsigned int indentLevel, std::string& s) const
|
||||
{
|
||||
s += "{";
|
||||
if (prettyIndent)
|
||||
|
||||
Reference in New Issue
Block a user