21 #ifndef RAPIDJSON_STRINGBUFFER_H_
22 #define RAPIDJSON_STRINGBUFFER_H_
25 #include "internal/stack.h"
35 template <
typename Encoding,
typename Allocator = CrtAllocator>
37 typedef typename Encoding::Ch Ch;
41 void Put(Ch c) { *stack_.template Push<Ch>() = c; }
44 void Clear() { stack_.Clear(); }
47 *stack_.template Push<Ch>() =
'\0';
49 stack_.template Pop<Ch>(1);
51 Ch* Push(
size_t count) {
return stack_.template Push<Ch>(count); }
52 void Pop(
size_t count) { stack_.template Pop<Ch>(count); }
54 const Ch* GetString()
const {
56 *stack_.template Push<Ch>() =
'\0';
57 stack_.template Pop<Ch>(1);
59 return stack_.template Bottom<Ch>();
62 size_t GetSize()
const {
return stack_.GetSize(); }
64 static const size_t kDefaultCapacity = 256;
65 mutable internal::Stack<Allocator> stack_;
74 std::memset(stream.stack_.Push<
char>(n), c, n *
sizeof(c));
79 #endif // RAPIDJSON_STRINGBUFFER_H_
Represents an in-memory output stream.
Definition: stringbuffer.h:36
main RapidJSON namespace
Definition: rapidjson.h:241
common definitions and configuration
UTF-8 encoding.
Definition: encodings.h:101
Concept for allocating, resizing and freeing memory block.
GenericStringBuffer< UTF8<> > StringBuffer
String buffer with UTF8 encoding.
Definition: stringbuffer.h:69
void PutN(Stream &stream, Ch c, size_t n)
Put N copies of a character to a stream.
Definition: rapidjson.h:484