21 #ifndef RAPIDJSON_MEMORYBUFFER_H_ 22 #define RAPIDJSON_MEMORYBUFFER_H_ 25 #include "internal/stack.h" 42 template <
typename Allocator = CrtAllocator>
48 void Put(Ch c) { *stack_.template Push<Ch>() = c; }
51 void Clear() { stack_.Clear(); }
52 void ShrinkToFit() { stack_.ShrinkToFit(); }
53 Ch* Push(
size_t count) {
return stack_.template Push<Ch>(count); }
54 void Pop(
size_t count) { stack_.template Pop<Ch>(count); }
56 const Ch* GetBuffer()
const {
57 return stack_.template Bottom<Ch>();
60 size_t GetSize()
const {
return stack_.GetSize(); }
62 static const size_t kDefaultCapacity = 256;
63 mutable internal::Stack<Allocator> stack_;
70 inline void PutN(MemoryBuffer& memoryBuffer,
char c,
size_t n) {
71 std::memset(memoryBuffer.stack_.Push<
char>(n), c, n *
sizeof(c));
76 #endif // RAPIDJSON_MEMORYBUFFER_H_ Represents an in-memory output byte stream.
Definition: memorybuffer.h:43
main RapidJSON namespace
Definition: rapidjson.h:241
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:484