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
62  :
63  stream_(stream), level_stack_(allocator, levelDepth * sizeof(Level))
64  {
65 #if _MSC_VER
66  (void) sprintf_s(double_format, sizeof(double_format), "%%0.%dg", precision);
67  (void) sprintf_s( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision );
68 #else
69  (void) snprintf(double_format, sizeof(double_format), "%%0.%dg", precision);
70  (void) snprintf( long_double_format, sizeof( long_double_format ), "%%0.%dLg", precision );
71 #endif
72 
73  }
char double_format[32]
Definition: writer.h:76
internal::Stack< Allocator > level_stack_
Definition: writer.h:342
Stream & stream_
Definition: writer.h:341
char long_double_format[32]
Definition: writer.h:77

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
84 { Prefix(b ? kTrueType : kFalseType); WriteBool_(b); return *this; }
void WriteBool_(bool b)
Definition: writer.h:151
void Prefix(Type type)
Definition: writer.h:323
@ kTrueType
true
Definition: rapidjson.h:541
@ kFalseType
false
Definition: rapidjson.h:540

References 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
233  { return c < 256; }

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
89 { Prefix(kNumberType); WriteDouble(d); return *this; }
void WriteDouble(double d)
Definition: writer.h:237
@ kNumberType
number
Definition: rapidjson.h:545

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
124  {
125  (void)elementCount;
126  RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));
127  RAPIDJSON_ASSERT(level_stack_.template Top<Level>()->inArray);
128  level_stack_.template Pop<Level>(1);
129  WriteEndArray();
130  return *this;
131  }
void WriteEndArray()
Definition: writer.h:321
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:105

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
108  {
109  (void)memberCount;
110  RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));
111  RAPIDJSON_ASSERT(!level_stack_.template Top<Level>()->inArray);
112  level_stack_.template Pop<Level>(1);
113  WriteEndObject();
114  return *this;
115  }
void WriteEndObject()
Definition: writer.h:319

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
85 { Prefix(kNumberType); WriteInt(i); return *this; }
void WriteInt(int i)
Definition: writer.h:160
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References constants::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
323  {
324  (void)type;
325  if (level_stack_.GetSize() != 0) { // this value is not at root
326  Level* level = level_stack_.template Top<Level>();
327  if (level->valueCount > 0) {
328  if (level->inArray)
329  stream_.Put(','); // add comma if it is not the first element in array
330  else // in object
331  stream_.Put((level->valueCount % 2 == 0) ? ',' : ':');
332  }
333  if (!level->inArray && level->valueCount % 2 == 0)
334  RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name
335  level->valueCount++;
336  }
337  else
338  RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);
339  }
@ kArrayType
array
Definition: rapidjson.h:543
@ kObjectType
object
Definition: rapidjson.h:542
@ kStringType
string
Definition: rapidjson.h:544

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_, 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.

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

References 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
94  {
95  (void)copy;
97  WriteString(str, length);
98  return *this;
99  }
void WriteString(const Ch *str, SizeType length)
Definition: writer.h:285

References rapidjson::kStringType, rapidjson::Writer< Stream, Encoding, Allocator >::Prefix(), 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)
inlinestaticconstexprprotected
221 { return 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
151  {
152  if (b) {
153  stream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e');
154  }
155  else {
156  stream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e');
157  }
158  }

References 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.
237  {
238  char buffer[100];
239 #if _MSC_VER
240  int ret = sprintf_s(buffer, sizeof(buffer), double_format, d);
241 #else
242  int ret = snprintf(buffer, sizeof(buffer), double_format, d);
243 #endif
244  RAPIDJSON_ASSERT(ret >= 1);
245  for (int i = 0; i < ret; i++)
246  stream_.Put(buffer[i]);
247  }

References rapidjson::Writer< Stream, Encoding, Allocator >::double_format, constants::i, RAPIDJSON_ASSERT, 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
249  {
250  char buffer[256];
251 #if _MSC_VER
252  int ret = sprintf_s(buffer, sizeof(buffer), long_double_format, d);
253 #else
254  int ret = snprintf(buffer, sizeof(buffer), long_double_format, d);
255 #endif
256  RAPIDJSON_ASSERT(ret >= 1);
257  for (int i = 0; i < ret; i++)
258  stream_.Put(buffer[i]);
259  }

References constants::i, rapidjson::Writer< Stream, Encoding, Allocator >::long_double_format, RAPIDJSON_ASSERT, 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
261  {
262  char buffer[256];
263 #if _MSC_VER
264  int ret = sprintf_s(buffer, sizeof(buffer), "%lld", d);
265 #else
266  int ret = snprintf(buffer, sizeof(buffer), "%lld", d);
267 #endif
268  RAPIDJSON_ASSERT(ret >= 1);
269  for (int i = 0; i < ret; i++)
270  stream_.Put(buffer[i]);
271  }

References constants::i, RAPIDJSON_ASSERT, 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
285  {
286  static const char hexDigits[] = "0123456789ABCDEF";
287  static const char escape[256] = {
288 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
289  //0 1 2 3 4 5 6 7 8 9 A B C D E F
290  'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00
291  'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10
292  0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20
293  Z16, Z16, // 30~4F
294  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0, // 50
295  Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16 // 60~FF
296 #undef Z16
297  };
298 
299  stream_.Put('\"');
300  for (const Ch* p = str; p != str + length; ++p) {
301  if ((sizeof(Ch) == 1 || characterOk(*p)) && escape[(unsigned char)*p]) {
302  //if ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p]) {
303  stream_.Put('\\');
304  stream_.Put(escape[(unsigned char)*p]);
305  if (escape[(unsigned char)*p] == 'u') {
306  stream_.Put('0');
307  stream_.Put('0');
308  stream_.Put(hexDigits[(*p) >> 4]);
309  stream_.Put(hexDigits[(*p) & 0xF]);
310  }
311  }
312  else
313  stream_.Put(*p);
314  }
315  stream_.Put('\"');
316  }
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:232
Encoding::Ch Ch
Definition: writer.h:60
#define Z16

References rapidjson::Writer< Stream, Encoding, Allocator >::characterOk(), 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
168  {
169  char buffer[10];
170  char *p = buffer;
171  do {
172  *p++ = (u % 10) + '0';
173  u /= 10;
174  } while (u > 0);
175 
176  do {
177  --p;
178  stream_.Put(*p);
179  } while (p != buffer);
180  }

References 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
190  {
191  char buffer[20];
192  char *p = buffer;
193  do {
194  *p++ = char(u64 % 10) + '0';
195  u64 /= 10;
196  } while (u64 > 0);
197 
198  do {
199  --p;
200  stream_.Put(*p);
201  } while (p != buffer);
202  }

References 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
273  {
274  char buffer[256];
275 #if _MSC_VER
276  int ret = sprintf_s(buffer, sizeof(buffer), "%llu", d);
277 #else
278  int ret = snprintf(buffer, sizeof(buffer), "%llu", d);
279 #endif
280  RAPIDJSON_ASSERT(ret >= 1);
281  for (int i = 0; i < ret; i++)
282  stream_.Put(buffer[i]);
283  }

References constants::i, RAPIDJSON_ASSERT, 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: