15 #ifndef RAPIDJSON_MEMORYBUFFER_H_ 16 #define RAPIDJSON_MEMORYBUFFER_H_ 19 #include "internal/stack.h" 36 template <
typename Allocator = CrtAllocator>
40 GenericMemoryBuffer(Allocator* allocator = 0,
size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
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;
64 inline void PutN(MemoryBuffer& memoryBuffer,
char c,
size_t n) {
65 std::memset(memoryBuffer.stack_.Push<
char>(n), c, n *
sizeof(c));
70 #endif // RAPIDJSON_MEMORYBUFFER_H_ #define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
Represents an in-memory output byte stream.
Definition: fwd.h:74
A type-unsafe stack for storing different types of data.
Definition: stack.h:37