15 #ifndef RAPIDJSON_MEMORYBUFFER_H_
16 #define RAPIDJSON_MEMORYBUFFER_H_
19 #include "internal/stack.h"
21 RAPIDJSON_NAMESPACE_BEGIN
36 template <
typename Allocator = CrtAllocator>
42 void Put(Ch c) { *stack_.template Push<Ch>() = c; }
45 void Clear() { stack_.Clear(); }
46 void ShrinkToFit() { stack_.ShrinkToFit(); }
47 Ch* Push(
size_t count) {
return stack_.template Push<Ch>(count); }
48 void Pop(
size_t count) { stack_.template Pop<Ch>(count); }
50 const Ch* GetBuffer()
const {
51 return stack_.template Bottom<Ch>();
54 size_t GetSize()
const {
return stack_.GetSize(); }
56 static const size_t kDefaultCapacity = 256;
57 mutable internal::Stack<Allocator> stack_;
65 std::memset(memoryBuffer.stack_.Push<
char>(n), c, n *
sizeof(c));
68 RAPIDJSON_NAMESPACE_END
70 #endif // RAPIDJSON_MEMORYBUFFER_H_
Represents an in-memory output byte stream.
Definition: memorybuffer.h:37
common definitions and configuration
Concept for allocating, resizing and freeing memory block.
void PutN(Stream &stream, Ch c, size_t n)
Put N copies of a character to a stream.
Definition: rapidjson.h:559