13struct UniValueStreamWriter {
16 UniValueStreamWriter() { str.reserve(1024); }
19#if __cplusplus >= 201103L
20 return std::move(str);
28 void put(
char c) { str.push_back(
c); }
30 void write(
const char *s) { str.append(s); }
31 void write(
const std::string &s) { str.append(s); }
46void UniValueStreamWriter::escapeJson(
const std::string &
inS) {
48 for (
size_t i = 0; i <
len; i++) {
49 const char ch =
inS[i];
60void UniValueStreamWriter::writeAny(
unsigned int prettyIndent,
87 write(
obj.val ==
"1" ?
"true" :
"false");
92void UniValueStreamWriter::writeArray(
unsigned int prettyIndent,
101 for (
size_t i = 0; i <
nValues; ++i) {
120void UniValueStreamWriter::writeObject(
unsigned int prettyIndent,
132 for (
size_t i = 0; i <
nItems; ++i) {
163 return ss.getString();
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
friend struct ::UniValueStreamWriter
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static const char * escapes[256]