15 #ifndef RAPIDJSON_STRINGBUFFER_H_
16 #define RAPIDJSON_STRINGBUFFER_H_
19 #include "internal/stack.h"
21 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
25 #include "internal/stack.h"
27 #if defined(__clang__)
29 RAPIDJSON_DIAG_OFF(c++98-compat)
40 template <
typename Encoding,
typename Allocator = CrtAllocator>
43 typedef typename Encoding::Ch Ch;
47 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
51 stack_ = std::move(rhs.stack_);
56 void Put(Ch c) { *stack_.template Push<Ch>() = c; }
57 void PutUnsafe(Ch c) { *stack_.template PushUnsafe<Ch>() = c; }
60 void Clear() { stack_.Clear(); }
63 *stack_.template Push<Ch>() =
'\0';
65 stack_.template Pop<Ch>(1);
68 void Reserve(
size_t count) { stack_.template Reserve<Ch>(count); }
69 Ch* Push(
size_t count) {
return stack_.template Push<Ch>(count); }
70 Ch* PushUnsafe(
size_t count) {
return stack_.template PushUnsafe<Ch>(count); }
71 void Pop(
size_t count) { stack_.template Pop<Ch>(count); }
73 const Ch* GetString()
const {
75 *stack_.template Push<Ch>() =
'\0';
76 stack_.template Pop<Ch>(1);
78 return stack_.template Bottom<Ch>();
81 size_t GetSize()
const {
return stack_.GetSize(); }
83 static const size_t kDefaultCapacity = 256;
95 template<
typename Encoding,
typename Allocator>
97 stream.Reserve(count);
100 template<
typename Encoding,
typename Allocator>
108 std::memset(stream.stack_.Push<
char>(n), c, n *
sizeof(c));
113 #if defined(__clang__)
Represents an in-memory output stream.
Definition: stringbuffer.h:41
A type-unsafe stack for storing different types of data.
Definition: stack.h:36
Concept for allocating, resizing and freeing memory block.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
UTF-8 encoding.
Definition: encodings.h:96