KrisLibrary  1.0.0
ContextStack.h
1 #ifndef UTILS_CONTEXT_STACK_H
2 #define UTILS_CONTEXT_STACK_H
3 
4 #include <KrisLibrary/Logger.h>
5 #include <string>
6 #include <list>
7 
15 {
16  public:
17  void Push(const std::string& item) {
18  frames.push_back(item);
19  str += delim;
20  str += item;
21  }
22  void Pop() {
23  frames.erase(--frames.end());
24  str.clear();
25  for(std::list::const_iterator i=frames.begin();i!=frames.end();i++) {
26  if(i!=frames.begin()) str+=delim;
27  str += *i;
28  }
29  }
30  const std::string& GetLocal() const { return frames.back(); }
31  operator const std::string& () const { return str; }
32 
33  private:
34  char delim;
35  std::list<std::string> frames;
36  std::string str;
37 };
38 
39 #endif
A helper for maintaining and printing context.
Definition: ContextStack.h:14
The logging system used in KrisLibrary.