graphbuilderadapter.cpp
Go to the documentation of this file.
1 #include "graphbuilderadapter.h"
2 
3 namespace YAML_PM
4 {
6 
7  void GraphBuilderAdapter::OnNull(const Mark& mark, anchor_t anchor)
8  {
9  void *pParent = GetCurrentParent();
10  void *pNode = m_builder.NewNull(mark, pParent);
11  RegisterAnchor(anchor, pNode);
12 
13  DispositionNode(pNode);
14  }
15 
16  void GraphBuilderAdapter::OnAlias(const Mark& mark, anchor_t anchor)
17  {
18  void *pReffedNode = m_anchors.Get(anchor);
19  DispositionNode(m_builder.AnchorReference(mark, pReffedNode));
20  }
21 
22  void GraphBuilderAdapter::OnScalar(const Mark& mark, const std::string& tag, anchor_t anchor, const std::string& value)
23  {
24  void *pParent = GetCurrentParent();
25  void *pNode = m_builder.NewScalar(mark, tag, pParent, value);
26  RegisterAnchor(anchor, pNode);
27 
28  DispositionNode(pNode);
29  }
30 
31  void GraphBuilderAdapter::OnSequenceStart(const Mark& mark, const std::string& tag, anchor_t anchor)
32  {
33  void *pNode = m_builder.NewSequence(mark, tag, GetCurrentParent());
34  m_containers.push(ContainerFrame(pNode));
35  RegisterAnchor(anchor, pNode);
36  }
37 
39  {
40  void *pSequence = m_containers.top().pContainer;
41  m_containers.pop();
42 
43  DispositionNode(pSequence);
44  }
45 
46  void GraphBuilderAdapter::OnMapStart(const Mark& mark, const std::string& tag, anchor_t anchor)
47  {
48  void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent());
50  m_pKeyNode = NULL;
51  RegisterAnchor(anchor, pNode);
52  }
53 
55  {
56  void *pMap = m_containers.top().pContainer;
57  m_pKeyNode = m_containers.top().pPrevKeyNode;
58  m_containers.pop();
59  DispositionNode(pMap);
60  }
61 
63  {
64  if (m_containers.empty()) {
65  return NULL;
66  }
67  return m_containers.top().pContainer;
68  }
69 
71  {
72  if (anchor) {
73  m_anchors.Register(anchor, pNode);
74  }
75  }
76 
78  {
79  if (m_containers.empty()) {
80  m_pRootNode = pNode;
81  return;
82  }
83 
84  void *pContainer = m_containers.top().pContainer;
85  if (m_containers.top().isMap()) {
86  if (m_pKeyNode) {
87  m_builder.AssignInMap(pContainer, m_pKeyNode, pNode);
88  m_pKeyNode = NULL;
89  } else {
90  m_pKeyNode = pNode;
91  }
92  } else {
93  m_builder.AppendToSequence(pContainer, pNode);
94  }
95  }
96 }
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
Definition: aliasmanager.h:11
YAML_PM::GraphBuilderAdapter::OnNull
virtual void OnNull(const Mark &mark, anchor_t anchor)
Definition: graphbuilderadapter.cpp:7
YAML_PM::GraphBuilderAdapter::OnAlias
virtual void OnAlias(const Mark &mark, anchor_t anchor)
Definition: graphbuilderadapter.cpp:16
YAML_PM::GraphBuilderAdapter::m_anchors
AnchorMap m_anchors
Definition: graphbuilderadapter.h:63
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::DispositionNode
void DispositionNode(void *pNode)
Definition: graphbuilderadapter.cpp:77
YAML_PM::GraphBuilderAdapter::ContainerFrame
Definition: graphbuilderadapter.h:41
graphbuilderadapter.h
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::Mark
Definition: mark.h:13
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::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