15 #ifndef RAPIDJSON_INTERNAL_STACK_H_ 16 #define RAPIDJSON_INTERNAL_STACK_H_ 18 #include "../allocators.h" 22 #if defined(__clang__) 24 RAPIDJSON_DIAG_OFF(c++ 98 - compat)
36 template <
typename Allocator>
42 Stack(Allocator* allocator,
size_t stackCapacity)
47 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 57 rhs.ownAllocator_ = 0;
61 rhs.initialCapacity_ = 0;
70 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 85 rhs.ownAllocator_ = 0;
89 rhs.initialCapacity_ = 0;
126 template <
typename T>
134 template <
typename T>
138 return PushUnsafe<T>(
count);
141 template <
typename T>
146 T* ret =
reinterpret_cast<T*
>(
stackTop_);
151 template <
typename T>
159 template <
typename T>
163 return reinterpret_cast<T*
>(
stackTop_ -
sizeof(T));
166 template <
typename T>
170 return reinterpret_cast<T*
>(
stackTop_ -
sizeof(T));
173 template <
typename T>
179 template <
typename T>
185 template <
typename T>
188 return reinterpret_cast<T*
>(
stack_);
191 template <
typename T>
194 return reinterpret_cast<T*
>(
stack_);
222 template <
typename T>
236 newCapacity += (newCapacity + 1) / 2;
238 size_t newSize =
GetSize() +
sizeof(T) * count;
239 if (newCapacity < newSize)
240 newCapacity = newSize;
274 #if defined(__clang__) 278 #endif // RAPIDJSON_STACK_H_
Allocator * ownAllocator_
#define RAPIDJSON_ASSERT(x)
Assertion.
RAPIDJSON_FORCEINLINE T * PushUnsafe(size_t count=1)
void Expand(size_t count)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
void Resize(size_t newCapacity)
A type-unsafe stack for storing different types of data.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Stack & operator=(const Stack &)
RAPIDJSON_FORCEINLINE T * Push(size_t count=1)
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
RAPIDJSON_FORCEINLINE void Reserve(size_t count=1)
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Allocator & GetAllocator()
bool HasAllocator() const
size_t GetCapacity() const
Stack(Allocator *allocator, size_t stackCapacity)
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT