15 #ifndef RAPIDJSON_INTERNAL_STACK_H_ 16 #define RAPIDJSON_INTERNAL_STACK_H_ 18 #include "../allocators.h" 21 #if defined(__clang__) 23 RAPIDJSON_DIAG_OFF(c++98-compat)
35 template <
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) {
124 return PushUnsafe<T>(count);
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__) 231 #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