Electroneum
Loading...
Searching...
No Matches
internal::Stack< Allocator > Class Template Reference

A type-unsafe stack for storing different types of data. More...

#include <stack.h>

Public Member Functions

 Stack (Allocator *allocator, size_t stackCapacity)
 ~Stack ()
void Swap (Stack &rhs) RAPIDJSON_NOEXCEPT
void Clear ()
void ShrinkToFit ()
template<typename T>
RAPIDJSON_FORCEINLINE void Reserve (size_t count=1)
template<typename T>
RAPIDJSON_FORCEINLINE TPush (size_t count=1)
template<typename T>
RAPIDJSON_FORCEINLINE TPushUnsafe (size_t count=1)
template<typename T>
TPop (size_t count)
template<typename T>
TTop ()
template<typename T>
const TTop () const
template<typename T>
TEnd ()
template<typename T>
const TEnd () const
template<typename T>
TBottom ()
template<typename T>
const TBottom () const
bool HasAllocator () const
AllocatorGetAllocator ()
bool Empty () const
size_t GetSize () const
size_t GetCapacity () const

Detailed Description

template<typename Allocator>
class internal::Stack< Allocator >

A type-unsafe stack for storing different types of data.

Template Parameters
AllocatorAllocator for allocating stack memory.

Definition at line 36 of file stack.h.

Constructor & Destructor Documentation

◆ Stack()

template<typename Allocator>
internal::Stack< Allocator >::Stack ( Allocator * allocator,
size_t stackCapacity )
inline

Definition at line 40 of file stack.h.

40 : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
41 }
A type-unsafe stack for storing different types of data.
Definition stack.h:36
Here is the caller graph for this function:

◆ ~Stack()

template<typename Allocator>
internal::Stack< Allocator >::~Stack ( )
inline

Definition at line 61 of file stack.h.

61 {
62 Destroy();
63 }

Member Function Documentation

◆ Bottom() [1/2]

template<typename Allocator>
template<typename T>
T * internal::Stack< Allocator >::Bottom ( )
inline

Definition at line 162 of file stack.h.

162{ return reinterpret_cast<T*>(stack_); }

◆ Bottom() [2/2]

template<typename Allocator>
template<typename T>
const T * internal::Stack< Allocator >::Bottom ( ) const
inline

Definition at line 165 of file stack.h.

165{ return reinterpret_cast<T*>(stack_); }

◆ Clear()

template<typename Allocator>
void internal::Stack< Allocator >::Clear ( )
inline

Definition at line 98 of file stack.h.

98{ stackTop_ = stack_; }

◆ Empty()

template<typename Allocator>
bool internal::Stack< Allocator >::Empty ( ) const
inline

Definition at line 176 of file stack.h.

176{ return stackTop_ == stack_; }
Here is the caller graph for this function:

◆ End() [1/2]

template<typename Allocator>
template<typename T>
T * internal::Stack< Allocator >::End ( )
inline

Definition at line 156 of file stack.h.

156{ return reinterpret_cast<T*>(stackTop_); }

◆ End() [2/2]

template<typename Allocator>
template<typename T>
const T * internal::Stack< Allocator >::End ( ) const
inline

Definition at line 159 of file stack.h.

159{ return reinterpret_cast<T*>(stackTop_); }

◆ GetAllocator()

template<typename Allocator>
Allocator & internal::Stack< Allocator >::GetAllocator ( )
inline

Definition at line 171 of file stack.h.

171 {
172 RAPIDJSON_ASSERT(allocator_);
173 return *allocator_;
174 }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:411

◆ GetCapacity()

template<typename Allocator>
size_t internal::Stack< Allocator >::GetCapacity ( ) const
inline

Definition at line 178 of file stack.h.

178{ return static_cast<size_t>(stackEnd_ - stack_); }

◆ GetSize()

template<typename Allocator>
size_t internal::Stack< Allocator >::GetSize ( ) const
inline

Definition at line 177 of file stack.h.

177{ return static_cast<size_t>(stackTop_ - stack_); }
Here is the caller graph for this function:

◆ HasAllocator()

template<typename Allocator>
bool internal::Stack< Allocator >::HasAllocator ( ) const
inline

Definition at line 167 of file stack.h.

167 {
168 return allocator_ != 0;
169 }

◆ Pop()

template<typename Allocator>
template<typename T>
T * internal::Stack< Allocator >::Pop ( size_t count)
inline

Definition at line 137 of file stack.h.

137 {
138 RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));
139 stackTop_ -= count * sizeof(T);
140 return reinterpret_cast<T*>(stackTop_);
141 }
size_t GetSize() const
Definition stack.h:177
Here is the call graph for this function:

◆ Push()

template<typename Allocator>
template<typename T>
RAPIDJSON_FORCEINLINE T * internal::Stack< Allocator >::Push ( size_t count = 1)
inline

Definition at line 122 of file stack.h.

122 {
124 return PushUnsafe<T>(count);
125 }
RAPIDJSON_FORCEINLINE void Reserve(size_t count=1)
Definition stack.h:115
RAPIDJSON_FORCEINLINE T * PushUnsafe(size_t count=1)
Definition stack.h:128
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PushUnsafe()

template<typename Allocator>
template<typename T>
RAPIDJSON_FORCEINLINE T * internal::Stack< Allocator >::PushUnsafe ( size_t count = 1)
inline

Definition at line 128 of file stack.h.

128 {
129 RAPIDJSON_ASSERT(stackTop_);
130 RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_);
131 T* ret = reinterpret_cast<T*>(stackTop_);
132 stackTop_ += sizeof(T) * count;
133 return ret;
134 }
Here is the caller graph for this function:

◆ Reserve()

template<typename Allocator>
template<typename T>
RAPIDJSON_FORCEINLINE void internal::Stack< Allocator >::Reserve ( size_t count = 1)
inline

Definition at line 115 of file stack.h.

115 {
116 // Expand the stack if needed
117 if (RAPIDJSON_UNLIKELY(stackTop_ + sizeof(T) * count > stackEnd_))
118 Expand<T>(count);
119 }
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition rapidjson.h:481
Here is the caller graph for this function:

◆ ShrinkToFit()

template<typename Allocator>
void internal::Stack< Allocator >::ShrinkToFit ( )
inline

Definition at line 100 of file stack.h.

100 {
101 if (Empty()) {
102 // If the stack is empty, completely deallocate the memory.
103 Allocator::Free(stack_); // NOLINT (+clang-analyzer-unix.Malloc)
104 stack_ = 0;
105 stackTop_ = 0;
106 stackEnd_ = 0;
107 }
108 else
109 Resize(GetSize());
110 }
bool Empty() const
Definition stack.h:176
Here is the call graph for this function:

◆ Swap()

template<typename Allocator>
void internal::Stack< Allocator >::Swap ( Stack< Allocator > & rhs)
inline

Definition at line 89 of file stack.h.

89 {
90 internal::Swap(allocator_, rhs.allocator_);
91 internal::Swap(ownAllocator_, rhs.ownAllocator_);
92 internal::Swap(stack_, rhs.stack_);
93 internal::Swap(stackTop_, rhs.stackTop_);
94 internal::Swap(stackEnd_, rhs.stackEnd_);
95 internal::Swap(initialCapacity_, rhs.initialCapacity_);
96 }
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition swap.h:33
Here is the call graph for this function:

◆ Top() [1/2]

template<typename Allocator>
template<typename T>
T * internal::Stack< Allocator >::Top ( )
inline

Definition at line 144 of file stack.h.

144 {
145 RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
146 return reinterpret_cast<T*>(stackTop_ - sizeof(T));
147 }
Here is the call graph for this function:

◆ Top() [2/2]

template<typename Allocator>
template<typename T>
const T * internal::Stack< Allocator >::Top ( ) const
inline

Definition at line 150 of file stack.h.

150 {
151 RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
152 return reinterpret_cast<T*>(stackTop_ - sizeof(T));
153 }
Here is the call graph for this function:

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/external/rapidjson/include/rapidjson/internal/stack.h