graphbuilderadapter.h
Go to the documentation of this file.
1 #ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
3 
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
5 #pragma once
6 #endif
7 
8 #include <cstdlib>
9 #include <map>
10 #include <stack>
12 #include "yaml-cpp-pm/contrib/anchordict.h"
13 #include "yaml-cpp-pm/contrib/graphbuilder.h"
14 
15 namespace YAML_PM
16 {
18  {
19  public:
20  GraphBuilderAdapter(GraphBuilderInterface& builder)
21  : m_builder(builder), m_pRootNode(NULL), m_pKeyNode(NULL)
22  {
23  }
24 
25  virtual void OnDocumentStart(const Mark& mark) {(void)mark;}
26  virtual void OnDocumentEnd() {}
27 
28  virtual void OnNull(const Mark& mark, anchor_t anchor);
29  virtual void OnAlias(const Mark& mark, anchor_t anchor);
30  virtual void OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value);
31 
32  virtual void OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor);
33  virtual void OnSequenceEnd();
34 
35  virtual void OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor);
36  virtual void OnMapEnd();
37 
38  void *RootNode() const {return m_pRootNode;}
39 
40  private:
42  {
43  ContainerFrame(void *pSequence)
44  : pContainer(pSequence), pPrevKeyNode(&sequenceMarker)
45  {}
46  ContainerFrame(void *pMap, void* pPrevKeyNode)
47  : pContainer(pMap), pPrevKeyNode(pPrevKeyNode)
48  {}
49 
50  void *pContainer;
51  void *pPrevKeyNode;
52 
53  bool isMap() const {return pPrevKeyNode != &sequenceMarker;}
54 
55  private:
56  static int sequenceMarker;
57  };
58  typedef std::stack<ContainerFrame> ContainerStack;
59  typedef AnchorDict<void*> AnchorMap;
60 
61  GraphBuilderInterface& m_builder;
62  ContainerStack m_containers;
63  AnchorMap m_anchors;
64  void *m_pRootNode;
65  void *m_pKeyNode;
66 
67  void *GetCurrentParent() const;
68  void RegisterAnchor(anchor_t anchor, void *pNode);
69  void DispositionNode(void *pNode);
70  };
71 }
72 
73 #endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
std::stack< ContainerFrame > ContainerStack
virtual void OnSequenceStart(const Mark &mark, const std::string &tag, anchor_t anchor)
std::size_t anchor_t
Definition: anchor.h:12
::std::string string
Definition: gtest.h:1979
ContainerFrame(void *pMap, void *pPrevKeyNode)
virtual void OnScalar(const Mark &mark, const std::string &tag, anchor_t anchor, const std::string &value)
AnchorDict< void * > AnchorMap
void RegisterAnchor(anchor_t anchor, void *pNode)
virtual void OnNull(const Mark &mark, anchor_t anchor)
virtual void OnAlias(const Mark &mark, anchor_t anchor)
virtual void OnMapStart(const Mark &mark, const std::string &tag, anchor_t anchor)
virtual void OnDocumentStart(const Mark &mark)
GraphBuilderAdapter(GraphBuilderInterface &builder)
GraphBuilderInterface & m_builder


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:36:30