00001 #ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM 00002 #define SINGLEDOCPARSER_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 "yaml-cpp-pm/anchor.h" 00010 #include "yaml-cpp-pm/noncopyable.h" 00011 #include <string> 00012 #include <map> 00013 #include <memory> 00014 00015 namespace YAML_PM 00016 { 00017 struct Directives; 00018 struct Mark; 00019 struct Token; 00020 class CollectionStack; 00021 class EventHandler; 00022 class Node; 00023 class Scanner; 00024 00025 class SingleDocParser: private noncopyable 00026 { 00027 public: 00028 SingleDocParser(Scanner& scanner, const Directives& directives); 00029 ~SingleDocParser(); 00030 00031 void HandleDocument(EventHandler& eventHandler); 00032 00033 private: 00034 void HandleNode(EventHandler& eventHandler); 00035 00036 void HandleSequence(EventHandler& eventHandler); 00037 void HandleBlockSequence(EventHandler& eventHandler); 00038 void HandleFlowSequence(EventHandler& eventHandler); 00039 00040 void HandleMap(EventHandler& eventHandler); 00041 void HandleBlockMap(EventHandler& eventHandler); 00042 void HandleFlowMap(EventHandler& eventHandler); 00043 void HandleCompactMap(EventHandler& eventHandler); 00044 void HandleCompactMapWithNoKey(EventHandler& eventHandler); 00045 00046 void ParseProperties(std::string& tag, anchor_t& anchor); 00047 void ParseTag(std::string& tag); 00048 void ParseAnchor(anchor_t& anchor); 00049 00050 anchor_t RegisterAnchor(const std::string& name); 00051 anchor_t LookupAnchor(const Mark& mark, const std::string& name) const; 00052 00053 private: 00054 Scanner& m_scanner; 00055 const Directives& m_directives; 00056 std::auto_ptr<CollectionStack> m_pCollectionStack; 00057 00058 typedef std::map<std::string, anchor_t> Anchors; 00059 Anchors m_anchors; 00060 00061 anchor_t m_curAnchor; 00062 }; 00063 } 00064 00065 #endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM