Free Electron
collectionstack.h
1 #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
3 
4 #if defined(_MSC_VER) || \
5  (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
6  (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
7 #pragma once
8 #endif
9 
10 #include <cassert>
11 #include <stack>
12 
13 namespace YAML {
14 struct CollectionType {
15  enum value { NoCollection, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap };
16 };
17 
18 class CollectionStack {
19  public:
20  CollectionStack() : collectionStack{} {}
21  CollectionType::value GetCurCollectionType() const {
22  if (collectionStack.empty())
23  return CollectionType::NoCollection;
24  return collectionStack.top();
25  }
26 
27  void PushCollectionType(CollectionType::value type) {
28  collectionStack.push(type);
29  }
30  void PopCollectionType(CollectionType::value type) {
31  assert(type == GetCurCollectionType());
32  (void)type;
33  collectionStack.pop();
34  }
35 
36  private:
37  std::stack<CollectionType::value> collectionStack;
38 };
39 } // namespace YAML
40 
41 #endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
Definition: anchor.h:12