15#ifndef RAPIDJSON_INTERNAL_STACK_H_
16#define RAPIDJSON_INTERNAL_STACK_H_
23RAPIDJSON_DIAG_OFF(c++98-compat)
35template <
typename Allocator>
43#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
53 rhs.ownAllocator_ = 0;
57 rhs.initialCapacity_ = 0;
65#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
79 rhs.ownAllocator_ = 0;
83 rhs.initialCapacity_ = 0;
115 RAPIDJSON_FORCEINLINE
void Reserve(
size_t count = 1) {
122 RAPIDJSON_FORCEINLINE
T*
Push(
size_t count = 1) {
146 return reinterpret_cast<T*
>(
stackTop_ -
sizeof(
T));
152 return reinterpret_cast<T*
>(
stackTop_ -
sizeof(
T));
191 newCapacity += (newCapacity + 1) / 2;
193 size_t newSize =
GetSize() +
sizeof(
T) * count;
194 if (newCapacity < newSize)
195 newCapacity = newSize;
227#if defined(__clang__)
A type-unsafe stack for storing different types of data.
Definition stack.h:36
Allocator * allocator_
Definition stack.h:216
void Clear()
Definition stack.h:98
void Resize(size_t newCapacity)
Definition stack.h:200
const T * Top() const
Definition stack.h:150
T * Pop(size_t count)
Definition stack.h:137
size_t initialCapacity_
Definition stack.h:221
const T * End() const
Definition stack.h:159
bool Empty() const
Definition stack.h:176
RAPIDJSON_FORCEINLINE T * Push(size_t count=1)
Definition stack.h:122
void ShrinkToFit()
Definition stack.h:100
Stack & operator=(const Stack &)
void Expand(size_t count)
Definition stack.h:182
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
Definition stack.h:89
void Destroy()
Definition stack.h:207
bool HasAllocator() const
Definition stack.h:167
size_t GetCapacity() const
Definition stack.h:178
T * Bottom()
Definition stack.h:162
Allocator * ownAllocator_
Definition stack.h:217
RAPIDJSON_FORCEINLINE void Reserve(size_t count=1)
Definition stack.h:115
RAPIDJSON_FORCEINLINE T * PushUnsafe(size_t count=1)
Definition stack.h:128
T * Top()
Definition stack.h:144
Allocator & GetAllocator()
Definition stack.h:171
char * stackTop_
Definition stack.h:219
size_t GetSize() const
Definition stack.h:177
T * End()
Definition stack.h:156
char * stack_
Definition stack.h:218
const T * Bottom() const
Definition stack.h:165
Stack(Allocator *allocator, size_t stackCapacity)
Definition stack.h:40
char * stackEnd_
Definition stack.h:220
~Stack()
Definition stack.h:61
Concept for allocating, resizing and freeing memory block.
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition rapidjson.h:481
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:411
#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
Definition document.h:406
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition swap.h:33
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition rapidjson.h:610
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition rapidjson.h:606