yaml-cpp

FORK: A YAML parser and emitter in C++
git clone https://git.neptards.moe/neptards/yaml-cpp.git
Log | Files | Refs | README | LICENSE

singledocparser.h (2168B)


      1 #ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
      2 #define SINGLEDOCPARSER_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 <map>
     11 #include <memory>
     12 #include <string>
     13 
     14 #include "yaml-cpp/anchor.h"
     15 
     16 namespace YAML {
     17 class CollectionStack;
     18 template <int> class DepthGuard; // depthguard.h
     19 class EventHandler;
     20 class Node;
     21 class Scanner;
     22 struct Directives;
     23 struct Mark;
     24 struct Token;
     25 
     26 class SingleDocParser {
     27  public:
     28   SingleDocParser(Scanner& scanner, const Directives& directives);
     29   SingleDocParser(const SingleDocParser&) = delete;
     30   SingleDocParser(SingleDocParser&&) = delete;
     31   SingleDocParser& operator=(const SingleDocParser&) = delete;
     32   SingleDocParser& operator=(SingleDocParser&&) = delete;
     33   ~SingleDocParser();
     34 
     35   void HandleDocument(EventHandler& eventHandler);
     36 
     37  private:
     38   void HandleNode(EventHandler& eventHandler);
     39 
     40   void HandleSequence(EventHandler& eventHandler);
     41   void HandleBlockSequence(EventHandler& eventHandler);
     42   void HandleFlowSequence(EventHandler& eventHandler);
     43 
     44   void HandleMap(EventHandler& eventHandler);
     45   void HandleBlockMap(EventHandler& eventHandler);
     46   void HandleFlowMap(EventHandler& eventHandler);
     47   void HandleCompactMap(EventHandler& eventHandler);
     48   void HandleCompactMapWithNoKey(EventHandler& eventHandler);
     49 
     50   void ParseProperties(std::string& tag, anchor_t& anchor,
     51                        std::string& anchor_name);
     52   void ParseTag(std::string& tag);
     53   void ParseAnchor(anchor_t& anchor, std::string& anchor_name);
     54 
     55   anchor_t RegisterAnchor(const std::string& name);
     56   anchor_t LookupAnchor(const Mark& mark, const std::string& name) const;
     57 
     58  private:
     59   int depth = 0;
     60   Scanner& m_scanner;
     61   const Directives& m_directives;
     62   std::unique_ptr<CollectionStack> m_pCollectionStack;
     63 
     64   using Anchors = std::map<std::string, anchor_t>;
     65   Anchors m_anchors;
     66 
     67   anchor_t m_curAnchor;
     68 };
     69 }  // namespace YAML
     70 
     71 #endif  // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66