00001 #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM 00002 #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM 00003 00004 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 00005 #pragma once 00006 #endif 00007 00008 00009 #include <stack> 00010 #include <cassert> 00011 00012 namespace YAML_PM 00013 { 00014 struct CollectionType { 00015 enum value { None, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap }; 00016 }; 00017 00018 class CollectionStack 00019 { 00020 public: 00021 CollectionType::value GetCurCollectionType() const { 00022 if(collectionStack.empty()) 00023 return CollectionType::None; 00024 return collectionStack.top(); 00025 } 00026 00027 void PushCollectionType(CollectionType::value type) { collectionStack.push(type); } 00028 void PopCollectionType(CollectionType::value type) { assert(type == GetCurCollectionType()); collectionStack.pop(); } 00029 00030 private: 00031 std::stack<CollectionType::value> collectionStack; 00032 }; 00033 } 00034 00035 #endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM