26 #ifndef STACK_INCLUDED
27 #define STACK_INCLUDED
34 #include "../base/ver.h"
38 #include "../base/str.h"
41 #ifndef CHECK_INCLUDED
42 #include "../base/check.h"
54 static const long STACK_MAGIC = 0x53544B0AL;
70 template<
class T,
int STACK_SIZE = 10000>
class stack_c {
81 CHECK(name !=
STR_NULL,
"stack_c::constructor: name is null");
121 inline bool push(T elem) {
127 if(NumElems >= STACK_SIZE) {
147 CHECK(NumElems > 0,
"stack_c::pop: Stack is empty");
158 inline bool is_empty()
const {
164 return NumElems == 0;
171 inline int num_elems()
const {
191 str_t check()
const {
194 if(Magic != STACK_MAGIC)
195 return "wrong magic number";
199 return "NumElems is negative";
200 if(NumElems > STACK_SIZE)
201 return "NumElems is greater than the stack size";
204 if(StackPtr == static_cast<T*>(0))
205 return "StackPtr is null";
206 if(StackPtr != Stack + NumElems)
207 return "StackPtr has wrong value";
258 for(
int i = 0; i < NumElems; i++) {
#define CHECK_CODE(CODE)
Definition: check.h:167
static void dump_ptr(const void *p)
Definition: err.cpp:791
static void dump_str(str_t str)
Definition: err.cpp:705
static void stack_overflow(str_t name, int curr_limit)
Definition: err.cpp:164
str_t str_fill(int n, int field_width)
Definition: str.cpp:286
#define CHECK_VALID(EX)
Definition: check.h:85
static void dump_begin(str_t headline)
Definition: err.cpp:685
const char * str_t
Definition: str.h:41
#define STR_NULL
Definition: str.h:52
static void dump_end()
Definition: err.cpp:811
static void dump_int(int n)
Definition: err.cpp:739
static void dump_nl()
Definition: err.cpp:717
#define CHECK(EX, MSG)
Definition: check.h:69