Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-12 09:08:09

0001 #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0002 #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0003 
0004 #if defined(_MSC_VER) ||                                            \
0005     (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
0006      (__GNUC__ >= 4))  // GCC supports "pragma once" correctly since 3.4
0007 #pragma once
0008 #endif
0009 
0010 #include <cassert>
0011 #include <stack>
0012 
0013 namespace SHERPA_YAML {
0014 struct CollectionType {
0015   enum value { NoCollection, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap };
0016 };
0017 
0018 class CollectionStack {
0019  public:
0020   CollectionStack() : collectionStack{} {}
0021   CollectionType::value GetCurCollectionType() const {
0022     if (collectionStack.empty())
0023       return CollectionType::NoCollection;
0024     return collectionStack.top();
0025   }
0026 
0027   void PushCollectionType(CollectionType::value type) {
0028     collectionStack.push(type);
0029   }
0030   void PopCollectionType(CollectionType::value type) {
0031     assert(type == GetCurCollectionType());
0032     (void)type;
0033     collectionStack.pop();
0034   }
0035 
0036  private:
0037   std::stack<CollectionType::value> collectionStack;
0038 };
0039 }  // namespace SHERPA_YAML
0040 
0041 #endif  // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66