rapidjson::Writer< Stream, Encoding, Allocator > Class Template Reference

JSON writer. More...

#include <writer.h>

+ Inheritance diagram for rapidjson::Writer< Stream, Encoding, Allocator >:

Classes

struct  Level
 Information for each nested level. More...
 

Public Types

typedef Encoding::Ch Ch
 

Public Member Functions

 Writer (Stream &stream, int precision=20, Allocator *allocator=0, size_t levelDepth=kDefaultLevelDepth)
 
WriterNull_ ()
 
WriterBool_ (bool b)
 
WriterInt (int i)
 
WriterUint (unsigned u)
 
WriterInt64 (int64_t i64)
 
WriterUint64 (uint64_t u64)
 
WriterDouble (double d)
 
WriterLongDouble (long double d)
 
WriterLongLong (long long d)
 
WriterULongLong (unsigned long long d)
 
WriterString (const Ch *str, SizeType length, bool copy=false)
 
WriterStartObject ()
 
WriterEndObject (SizeType memberCount=0)
 
WriterStartArray ()
 
WriterEndArray (SizeType elementCount=0)
 
WriterString (const Ch *str)
 Simpler but slower overload. More...
 

Protected Member Functions

void WriteNull_ ()
 
void WriteBool_ (bool b)
 
void WriteInt (int i)
 
void WriteUint (unsigned u)
 
void WriteInt64 (int64_t i64)
 
void WriteUint64 (uint64_t u64)
 
template<class Ch >
std::enable_if< to_int(std::numeric_limits< Ch >::max())< to_int(256), bool >::type characterOk(Ch) { return true;} template< class Ch > typename std::enable_if< to_int(std::numeric_limits< Ch >::max()) >=to_int(256), bool >::type characterOk (Ch c)
 
void WriteDouble (double d)
 
void WriteLongDouble (long double d)
 
void WriteLongLong (long long d)
 
void WriteULongLong (unsigned long long d)
 
void WriteString (const Ch *str, SizeType length)
 
void WriteStartObject ()
 
void WriteEndObject ()
 
void WriteStartArray ()
 
void WriteEndArray ()
 
void Prefix (Type type)
 

Static Protected Member Functions

template<class T >
static constexpr int to_int (T t)
 

Protected Attributes

char double_format [32]
 
char long_double_format [32]
 
Streamstream_
 
internal::Stack< Allocatorlevel_stack_
 

Static Protected Attributes

static const size_t kDefaultLevelDepth = 32
 

Private Member Functions

Writeroperator= (const Writer &w)
 

Detailed Description

template<typename Stream, typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
class rapidjson::Writer< Stream, Encoding, Allocator >

JSON writer.

Writer implements the concept Handler. It generates JSON text by events to an output stream.

User may programmatically calls the functions of a writer to generate JSON text.

On the other side, a writer can also be passed to objects that generates events,

for example Reader::Parse() and Document::Accept().

Template Parameters
StreamType of ouptut stream.
EncodingEncoding of both source strings and output.

Member Typedef Documentation

◆ Ch

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
typedef Encoding::Ch rapidjson::Writer< Stream, Encoding, Allocator >::Ch

Constructor & Destructor Documentation

◆ Writer()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
rapidjson::Writer< Stream, Encoding, Allocator >::Writer ( Stream stream,
int  precision = 20,
Allocator allocator = 0,
size_t  levelDepth = kDefaultLevelDepth 
)
inline
37  :
38  stream_(stream), level_stack_(allocator, levelDepth * sizeof(Level))
39  {
40 #if _MSC_VER
41  (void) sprintf_s(double_format, sizeof(double_format), "%%0.%dg", precision);
42  (void) sprintf_s( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision );
43 #else
44  (void) snprintf(double_format, sizeof(double_format), "%%0.%dg", precision);
45  (void) snprintf( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision );
46 #endif
47 
48  }
char double_format[32]
Definition: writer.h:51
internal::Stack< Allocator > level_stack_
Definition: writer.h:317
Stream & stream_
Definition: writer.h:316
char long_double_format[32]
Definition: writer.h:52

References rapidjson::Writer< Stream, Encoding, Allocator >::double_format, and rapidjson::Writer< Stream, Encoding, Allocator >::long_double_format.

Member Function Documentation

◆ Bool_()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Bool_ ( bool  b)
inline
59 { Prefix(b ? kTrueType : kFalseType); WriteBool_(b); return *this; }
Scalar * b
Definition: benchVecAdd.cpp:17
void WriteBool_(bool b)
Definition: writer.h:126
void Prefix(Type type)
Definition: writer.h:298
@ kTrueType
true
Definition: rapidjson.h:516
@ kFalseType
false
Definition: rapidjson.h:515

References b, rapidjson::kFalseType, rapidjson::kTrueType, rapidjson::Writer< Stream, Encoding, Allocator >::Prefix(), and rapidjson::Writer< Stream, Encoding, Allocator >::WriteBool_().

◆ characterOk()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
template<class Ch >
std::enable_if< to_int(std::numeric_limits<Ch>::max()) < to_int(256), bool>::type characterOk( Ch ) { return true; } template<class Ch> typename std::enable_if< to_int(std::numeric_limits<Ch>::max()) >= to_int(256), bool>::type rapidjson::Writer< Stream, Encoding, Allocator >::characterOk ( Ch  c)
inlineprotected
208  { return c < 256; }
int c
Definition: calibrate.py:100

References calibrate::c.

Referenced by rapidjson::Writer< Stream, Encoding, Allocator >::WriteString().

◆ Double()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Double ( double  d)
inline
64 { Prefix(kNumberType); WriteDouble(d); return *this; }
void WriteDouble(double d)
Definition: writer.h:212
@ kNumberType
number
Definition: rapidjson.h:520

References rapidjson::kNumberType, rapidjson::Writer< Stream, Encoding, Allocator >::Prefix(), and rapidjson::Writer< Stream, Encoding, Allocator >::WriteDouble().

◆ EndArray()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::EndArray ( SizeType  elementCount = 0)
inline
99  {
100  (void)elementCount;
101  RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));
102  RAPIDJSON_ASSERT(level_stack_.template Top<Level>()->inArray);
103  level_stack_.template Pop<Level>(1);
104  WriteEndArray();
105  return *this;
106  }
void WriteEndArray()
Definition: writer.h:296
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:80

References rapidjson::Writer< Stream, Encoding, Allocator >::level_stack_, RAPIDJSON_ASSERT, and rapidjson::Writer< Stream, Encoding, Allocator >::WriteEndArray().

◆ EndObject()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::EndObject ( SizeType  memberCount = 0)
inline
83  {
84  (void)memberCount;
85  RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));
86  RAPIDJSON_ASSERT(!level_stack_.template Top<Level>()->inArray);
87  level_stack_.template Pop<Level>(1);
89  return *this;
90  }
void WriteEndObject()
Definition: writer.h:294

References rapidjson::Writer< Stream, Encoding, Allocator >::level_stack_, RAPIDJSON_ASSERT, and rapidjson::Writer< Stream, Encoding, Allocator >::WriteEndObject().

◆ Int()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Int ( int  i)
inline
60 { Prefix(kNumberType); WriteInt(i); return *this; }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
void WriteInt(int i)
Definition: writer.h:135

References i, rapidjson::kNumberType, rapidjson::Writer< Stream, Encoding, Allocator >::Prefix(), and rapidjson::Writer< Stream, Encoding, Allocator >::WriteInt().

◆ Int64()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Int64 ( int64_t  i64)
inline

◆ LongDouble()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::LongDouble ( long double  d)
inline

◆ LongLong()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::LongLong ( long long  d)
inline

◆ Null_()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Null_ ( )
inline

◆ operator=()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::operator= ( const Writer< Stream, Encoding, Allocator > &  w)
private

◆ Prefix()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::Prefix ( Type  type)
inlineprotected
298  {
299  (void)type;
300  if (level_stack_.GetSize() != 0) { // this value is not at root
301  Level* level = level_stack_.template Top<Level>();
302  if (level->valueCount > 0) {
303  if (level->inArray)
304  stream_.Put(','); // add comma if it is not the first element in array
305  else // in object
306  stream_.Put((level->valueCount % 2 == 0) ? ',' : ':');
307  }
308  if (!level->inArray && level->valueCount % 2 == 0)
309  RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name
310  level->valueCount++;
311  }
312  else
314  }
type
Definition: compute_granudrum_aor.py:141
@ kArrayType
array
Definition: rapidjson.h:518
@ kObjectType
object
Definition: rapidjson.h:517
@ kStringType
string
Definition: rapidjson.h:519

References rapidjson::Writer< Stream, Encoding, Allocator >::Level::inArray, rapidjson::kArrayType, rapidjson::kObjectType, rapidjson::kStringType, rapidjson::Writer< Stream, Encoding, Allocator >::level_stack_, RAPIDJSON_ASSERT, rapidjson::Writer< Stream, Encoding, Allocator >::stream_, compute_granudrum_aor::type, and rapidjson::Writer< Stream, Encoding, Allocator >::Level::valueCount.

Referenced by rapidjson::Writer< Stream, Encoding, Allocator >::Bool_(), rapidjson::Writer< Stream, Encoding, Allocator >::Double(), rapidjson::Writer< Stream, Encoding, Allocator >::Int(), rapidjson::Writer< Stream, Encoding, Allocator >::Int64(), rapidjson::Writer< Stream, Encoding, Allocator >::LongDouble(), rapidjson::Writer< Stream, Encoding, Allocator >::LongLong(), rapidjson::Writer< Stream, Encoding, Allocator >::Null_(), rapidjson::Writer< Stream, Encoding, Allocator >::StartArray(), rapidjson::Writer< Stream, Encoding, Allocator >::StartObject(), rapidjson::Writer< Stream, Encoding, Allocator >::String(), rapidjson::Writer< Stream, Encoding, Allocator >::Uint(), rapidjson::Writer< Stream, Encoding, Allocator >::Uint64(), and rapidjson::Writer< Stream, Encoding, Allocator >::ULongLong().

◆ StartArray()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::StartArray ( )
inline

◆ StartObject()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::StartObject ( )
inline

◆ String() [1/2]

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::String ( const Ch str)
inline

Simpler but slower overload.

110 { return String(str, internal::StrLen(str)); }
Writer & String(const Ch *str, SizeType length, bool copy=false)
Definition: writer.h:69
str
Definition: compute_granudrum_aor.py:141
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:14

References compute_granudrum_aor::str, rapidjson::Writer< Stream, Encoding, Allocator >::String(), and rapidjson::internal::StrLen().

Referenced by rapidjson::Writer< Stream, Encoding, Allocator >::String().

◆ String() [2/2]

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::String ( const Ch str,
SizeType  length,
bool  copy = false 
)
inline
69  {
70  (void)copy;
72  WriteString(str, length);
73  return *this;
74  }
void WriteString(const Ch *str, SizeType length)
Definition: writer.h:260
EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:32

References copy(), rapidjson::kStringType, rapidjson::Writer< Stream, Encoding, Allocator >::Prefix(), compute_granudrum_aor::str, and rapidjson::Writer< Stream, Encoding, Allocator >::WriteString().

◆ to_int()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
template<class T >
static constexpr int rapidjson::Writer< Stream, Encoding, Allocator >::to_int ( T  t)
inlinestaticconstexprprotected
196 { return t; }
t
Definition: plotPSD.py:36

References plotPSD::t.

◆ Uint()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Uint ( unsigned  u)
inline

◆ Uint64()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::Uint64 ( uint64_t  u64)
inline

◆ ULongLong()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Writer& rapidjson::Writer< Stream, Encoding, Allocator >::ULongLong ( unsigned long long  d)
inline

◆ WriteBool_()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteBool_ ( bool  b)
inlineprotected
126  {
127  if (b) {
128  stream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e');
129  }
130  else {
131  stream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e');
132  }
133  }

References b, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::PrettyWriter< Stream, Encoding, Allocator >::Bool_(), and rapidjson::Writer< Stream, Encoding, Allocator >::Bool_().

◆ WriteDouble()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteDouble ( double  d)
inlineprotected
Todo:
Optimization with custom double-to-string converter.
212  {
213  char buffer[100];
214 #if _MSC_VER
215  int ret = sprintf_s(buffer, sizeof(buffer), double_format, d);
216 #else
217  int ret = snprintf(buffer, sizeof(buffer), double_format, d);
218 #endif
219  RAPIDJSON_ASSERT(ret >= 1);
220  for (int i = 0; i < ret; i++)
221  stream_.Put(buffer[i]);
222  }
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43

References rapidjson::Writer< Stream, Encoding, Allocator >::double_format, i, RAPIDJSON_ASSERT, ret, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::PrettyWriter< Stream, Encoding, Allocator >::Double(), and rapidjson::Writer< Stream, Encoding, Allocator >::Double().

◆ WriteEndArray()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteEndArray ( )
inlineprotected

◆ WriteEndObject()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteEndObject ( )
inlineprotected

◆ WriteInt()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteInt ( int  i)
inlineprotected

◆ WriteInt64()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteInt64 ( int64_t  i64)
inlineprotected

◆ WriteLongDouble()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteLongDouble ( long double  d)
inlineprotected
224  {
225  char buffer[256];
226 #if _MSC_VER
227  int ret = sprintf_s(buffer, sizeof(buffer), long_double_format, d);
228 #else
229  int ret = snprintf(buffer, sizeof(buffer), long_double_format, d);
230 #endif
231  RAPIDJSON_ASSERT(ret >= 1);
232  for (int i = 0; i < ret; i++)
233  stream_.Put(buffer[i]);
234  }

References i, rapidjson::Writer< Stream, Encoding, Allocator >::long_double_format, RAPIDJSON_ASSERT, ret, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::Writer< Stream, Encoding, Allocator >::LongDouble().

◆ WriteLongLong()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteLongLong ( long long  d)
inlineprotected
236  {
237  char buffer[256];
238 #if _MSC_VER
239  int ret = sprintf_s(buffer, sizeof(buffer), "%lld", d);
240 #else
241  int ret = snprintf(buffer, sizeof(buffer), "%lld", d);
242 #endif
243  RAPIDJSON_ASSERT(ret >= 1);
244  for (int i = 0; i < ret; i++)
245  stream_.Put(buffer[i]);
246  }

References i, RAPIDJSON_ASSERT, ret, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::Writer< Stream, Encoding, Allocator >::LongLong().

◆ WriteNull_()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteNull_ ( )
inlineprotected

◆ WriteStartArray()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteStartArray ( )
inlineprotected

◆ WriteStartObject()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteStartObject ( )
inlineprotected

◆ WriteString()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteString ( const Ch str,
SizeType  length 
)
inlineprotected
260  {
261  static const char hexDigits[] = "0123456789ABCDEF";
262  static const char escape[256] = {
263 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
264  //0 1 2 3 4 5 6 7 8 9 A B C D E F
265  'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00
266  'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10
267  0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20
268  Z16, Z16, // 30~4F
269  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50
270  Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF
271 #undef Z16
272  };
273 
274  stream_.Put('\"');
275  for (const Ch* p = str; p != str + length; ++p) {
276  if ((sizeof(Ch) == 1 || characterOk(*p)) && escape[(unsigned char)*p]) {
277  //if ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p]) {
278  stream_.Put('\\');
279  stream_.Put(escape[(unsigned char)*p]);
280  if (escape[(unsigned char)*p] == 'u') {
281  stream_.Put('0');
282  stream_.Put('0');
283  stream_.Put(hexDigits[(*p) >> 4]);
284  stream_.Put(hexDigits[(*p) & 0xF]);
285  }
286  }
287  else
288  stream_.Put(*p);
289  }
290  stream_.Put('\"');
291  }
static void escape(void *p)
Definition: BenchTimer.h:30
float * p
Definition: Tutorial_Map_using.cpp:9
std::enable_if< to_int(std::numeric_limits< Ch >::max())< to_int(256), bool >::type characterOk(Ch) { return true;} template< class Ch > typename std::enable_if< to_int(std::numeric_limits< Ch >::max()) >=to_int(256), bool >::type characterOk(Ch c)
Definition: writer.h:207
Encoding::Ch Ch
Definition: writer.h:35
#define Z16

References rapidjson::Writer< Stream, Encoding, Allocator >::characterOk(), escape(), p, compute_granudrum_aor::str, rapidjson::Writer< Stream, Encoding, Allocator >::stream_, and Z16.

Referenced by rapidjson::PrettyWriter< Stream, Encoding, Allocator >::String(), and rapidjson::Writer< Stream, Encoding, Allocator >::String().

◆ WriteUint()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteUint ( unsigned  u)
inlineprotected
143  {
144  char buffer[10];
145  char *p = buffer;
146  do {
147  *p++ = (u % 10) + '0';
148  u /= 10;
149  } while (u > 0);
150 
151  do {
152  --p;
153  stream_.Put(*p);
154  } while (p != buffer);
155  }

References p, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::PrettyWriter< Stream, Encoding, Allocator >::Uint(), rapidjson::Writer< Stream, Encoding, Allocator >::Uint(), and rapidjson::Writer< Stream, Encoding, Allocator >::WriteInt().

◆ WriteUint64()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteUint64 ( uint64_t  u64)
inlineprotected
165  {
166  char buffer[20];
167  char *p = buffer;
168  do {
169  *p++ = char(u64 % 10) + '0';
170  u64 /= 10;
171  } while (u64 > 0);
172 
173  do {
174  --p;
175  stream_.Put(*p);
176  } while (p != buffer);
177  }

References p, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::PrettyWriter< Stream, Encoding, Allocator >::Uint64(), rapidjson::Writer< Stream, Encoding, Allocator >::Uint64(), and rapidjson::Writer< Stream, Encoding, Allocator >::WriteInt64().

◆ WriteULongLong()

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
void rapidjson::Writer< Stream, Encoding, Allocator >::WriteULongLong ( unsigned long long  d)
inlineprotected
248  {
249  char buffer[256];
250 #if _MSC_VER
251  int ret = sprintf_s(buffer, sizeof(buffer), "%llu", d);
252 #else
253  int ret = snprintf(buffer, sizeof(buffer), "%llu", d);
254 #endif
255  RAPIDJSON_ASSERT(ret >= 1);
256  for (int i = 0; i < ret; i++)
257  stream_.Put(buffer[i]);
258  }

References i, RAPIDJSON_ASSERT, ret, and rapidjson::Writer< Stream, Encoding, Allocator >::stream_.

Referenced by rapidjson::Writer< Stream, Encoding, Allocator >::ULongLong().

Member Data Documentation

◆ double_format

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
char rapidjson::Writer< Stream, Encoding, Allocator >::double_format[32]
protected

◆ kDefaultLevelDepth

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
const size_t rapidjson::Writer< Stream, Encoding, Allocator >::kDefaultLevelDepth = 32
staticprotected

◆ level_stack_

◆ long_double_format

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
char rapidjson::Writer< Stream, Encoding, Allocator >::long_double_format[32]
protected

◆ stream_

template<typename Stream , typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<>>
Stream& rapidjson::Writer< Stream, Encoding, Allocator >::stream_
protected

The documentation for this class was generated from the following file: