15 #ifndef RAPIDJSON_INTERNAL_STACK_H_
16 #define RAPIDJSON_INTERNAL_STACK_H_
18 #include "../rapidjson.h"
29 template <
typename Allocator>
38 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
48 rhs.ownAllocator_ = 0;
52 rhs.initialCapacity_ = 0;
60 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
74 rhs.ownAllocator_ = 0;
78 rhs.initialCapacity_ = 0;
101 RAPIDJSON_FORCEINLINE T*
Push(
size_t count = 1) {
106 T* ret =
reinterpret_cast<T*
>(
stackTop_);
121 return reinterpret_cast<T*
>(
stackTop_ -
sizeof(T));
143 newCapacity += (newCapacity + 1) / 2;
145 size_t newSize =
GetSize() +
sizeof(T) * count;
146 if (newCapacity < newSize)
147 newCapacity = newSize;
179 #endif // RAPIDJSON_STACK_H_
char * stack_
Definition: stack.h:170
~Stack()
Definition: stack.h:56
Allocator * ownAllocator_
Definition: stack.h:169
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
void Expand(size_t count)
Definition: stack.h:134
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
void Resize(size_t newCapacity)
Definition: stack.h:152
A type-unsafe stack for storing different types of data.
Definition: stack.h:30
bool Empty() const
Definition: stack.h:128
void Clear()
Definition: stack.h:84
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
Stack & operator=(const Stack &)
RAPIDJSON_FORCEINLINE T * Push(size_t count=1)
Definition: stack.h:101
void Destroy()
Definition: stack.h:159
char * stackEnd_
Definition: stack.h:172
#define RAPIDJSON_NEW(x)
! customization point for global new
Definition: rapidjson.h:480
size_t GetSize() const
Definition: stack.h:129
size_t initialCapacity_
Definition: stack.h:173
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:484
Allocator * allocator_
Definition: stack.h:168
Allocator & GetAllocator()
Definition: stack.h:127
T * Bottom()
Definition: stack.h:125
Definition: document.h:390
char * stackTop_
Definition: stack.h:171
void ShrinkToFit()
Definition: stack.h:86
size_t GetCapacity() const
Definition: stack.h:130
Stack(Allocator *allocator, size_t stackCapacity)
Definition: stack.h:34
T * Pop(size_t count)
Definition: stack.h:112
T * Top()
Definition: stack.h:119