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)
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;
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
YAML_PM::GraphBuilderAdapter::m_builder
GraphBuilderInterface & m_builder
Definition: graphbuilderadapter.h:61
YAML_PM::GraphBuilderAdapter::m_containers
ContainerStack m_containers
Definition: graphbuilderadapter.h:62
YAML_PM::GraphBuilderAdapter::OnScalar
virtual void OnScalar(const Mark &mark, const std::string &tag, anchor_t anchor, const std::string &value)
Definition: graphbuilderadapter.cpp:22
YAML_PM::GraphBuilderAdapter::OnDocumentStart
virtual void OnDocumentStart(const Mark &mark)
Definition: graphbuilderadapter.h:25
YAML_PM::GraphBuilderAdapter::ContainerStack
std::stack< ContainerFrame > ContainerStack
Definition: graphbuilderadapter.h:58
YAML_PM::GraphBuilderAdapter::RootNode
void * RootNode() const
Definition: graphbuilderadapter.h:38
YAML_PM
Definition: aliasmanager.h:11
YAML_PM::GraphBuilderAdapter
Definition: graphbuilderadapter.h:17
YAML_PM::GraphBuilderAdapter::OnNull
virtual void OnNull(const Mark &mark, anchor_t anchor)
Definition: graphbuilderadapter.cpp:7
YAML_PM::EventHandler
Definition: eventhandler.h:15
YAML_PM::GraphBuilderAdapter::OnAlias
virtual void OnAlias(const Mark &mark, anchor_t anchor)
Definition: graphbuilderadapter.cpp:16
YAML_PM::GraphBuilderAdapter::ContainerFrame::ContainerFrame
ContainerFrame(void *pMap, void *pPrevKeyNode)
Definition: graphbuilderadapter.h:46
YAML_PM::GraphBuilderAdapter::m_anchors
AnchorMap m_anchors
Definition: graphbuilderadapter.h:63
eventhandler.h
YAML_PM::GraphBuilderAdapter::ContainerFrame::isMap
bool isMap() const
Definition: graphbuilderadapter.h:53
YAML_PM::GraphBuilderAdapter::m_pKeyNode
void * m_pKeyNode
Definition: graphbuilderadapter.h:65
testing::internal::string
::std::string string
Definition: gtest.h:1979
YAML_PM::GraphBuilderAdapter::OnMapStart
virtual void OnMapStart(const Mark &mark, const std::string &tag, anchor_t anchor)
Definition: graphbuilderadapter.cpp:46
YAML_PM::GraphBuilderAdapter::OnDocumentEnd
virtual void OnDocumentEnd()
Definition: graphbuilderadapter.h:26
YAML_PM::GraphBuilderAdapter::DispositionNode
void DispositionNode(void *pNode)
Definition: graphbuilderadapter.cpp:77
YAML_PM::GraphBuilderAdapter::ContainerFrame
Definition: graphbuilderadapter.h:41
YAML_PM::GraphBuilderAdapter::AnchorMap
AnchorDict< void * > AnchorMap
Definition: graphbuilderadapter.h:59
YAML_PM::GraphBuilderAdapter::OnSequenceStart
virtual void OnSequenceStart(const Mark &mark, const std::string &tag, anchor_t anchor)
Definition: graphbuilderadapter.cpp:31
YAML_PM::GraphBuilderAdapter::RegisterAnchor
void RegisterAnchor(anchor_t anchor, void *pNode)
Definition: graphbuilderadapter.cpp:70
YAML_PM::GraphBuilderAdapter::ContainerFrame::pContainer
void * pContainer
Definition: graphbuilderadapter.h:50
YAML_PM::Mark
Definition: mark.h:13
YAML_PM::GraphBuilderAdapter::GraphBuilderAdapter
GraphBuilderAdapter(GraphBuilderInterface &builder)
Definition: graphbuilderadapter.h:20
YAML_PM::GraphBuilderAdapter::ContainerFrame::pPrevKeyNode
void * pPrevKeyNode
Definition: graphbuilderadapter.h:51
YAML_PM::GraphBuilderAdapter::OnSequenceEnd
virtual void OnSequenceEnd()
Definition: graphbuilderadapter.cpp:38
YAML_PM::anchor_t
std::size_t anchor_t
Definition: anchor.h:12
YAML_PM::GraphBuilderAdapter::ContainerFrame::sequenceMarker
static int sequenceMarker
Definition: graphbuilderadapter.h:56
YAML_PM::GraphBuilderAdapter::OnMapEnd
virtual void OnMapEnd()
Definition: graphbuilderadapter.cpp:54
YAML_PM::GraphBuilderAdapter::ContainerFrame::ContainerFrame
ContainerFrame(void *pSequence)
Definition: graphbuilderadapter.h:43
YAML_PM::GraphBuilderAdapter::GetCurrentParent
void * GetCurrentParent() const
Definition: graphbuilderadapter.cpp:62
YAML_PM::GraphBuilderAdapter::m_pRootNode
void * m_pRootNode
Definition: graphbuilderadapter.h:64


mp2p_icp
Author(s):
autogenerated on Fri Dec 20 2024 03:45:58