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 }
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
virtual void OnScalar(const Mark &mark, const std::string &tag, anchor_t anchor, const std::string &value)
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)
GraphBuilderInterface & m_builder


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