All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TagStack.h
1 #pragma once
2 
3 // simple in-place stack designed to avoid allocations (as it is used inside the memory allocation debugging).
4 // See the comment on https://github.com/eegeo/eegeo-mobile/commit/e31e67e0da5f46043d33366dbe73e7b92dcec8c5 for a discussion
5 // of why this isn't an STL stack.
6 template <int TMaxDepth>
7 class TagStack
8 {
9 public:
10 
11  TagStack() :
12  m_currentIndex(0)
13  {
14  m_tags[0] = "";
15  }
16 
17  void PushTag(const char* tag) { m_tags[++m_currentIndex] = tag; }
18  void PopTag() { --m_currentIndex; }
19  const char* Peek() const { return m_tags[m_currentIndex]; }
20 
21 private:
22 
23  int m_currentIndex;
24  const char* m_tags[TMaxDepth];
25 };
26