1 #ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 #define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 4 #if defined(_MSC_VER) || \ 5 (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 10 #include "yaml-cpp/mark.h" 23 virtual void *NewNull(
const Mark &mark,
void *pParentNode) = 0;
26 virtual void *NewScalar(
const Mark &mark,
const std::string &tag,
27 void *pParentNode,
const std::string &value) = 0;
30 virtual void *NewSequence(
const Mark &mark,
const std::string &tag,
31 void *pParentNode) = 0;
35 virtual void AppendToSequence(
void *pSequence,
void *pNode) = 0;
38 virtual void SequenceComplete(
void *pSequence) { (void)pSequence; }
41 virtual void *NewMap(
const Mark &mark,
const std::string &tag,
42 void *pParentNode) = 0;
46 virtual void AssignInMap(
void *pMap,
void *pKeyNode,
void *pValueNode) = 0;
49 virtual void MapComplete(
void *pMap) { (void)pMap; }
53 virtual void *AnchorReference(
const Mark &mark,
void *pNode) {
69 typedef typename Impl::Node Node;
70 typedef typename Impl::Sequence Sequence;
71 typedef typename Impl::Map Map;
75 Sequence *pSeq = NULL;
85 virtual void *NewNull(
const Mark &mark,
void *pParentNode) {
86 return CheckType<Node>(m_impl.NewNull(mark, AsNode(pParentNode)));
89 virtual void *NewScalar(
const Mark &mark,
const std::string &tag,
90 void *pParentNode,
const std::string &value) {
91 return CheckType<Node>(
92 m_impl.NewScalar(mark, tag, AsNode(pParentNode), value));
95 virtual void *NewSequence(
const Mark &mark,
const std::string &tag,
97 return CheckType<Sequence>(
98 m_impl.NewSequence(mark, tag, AsNode(pParentNode)));
100 virtual void AppendToSequence(
void *pSequence,
void *pNode) {
101 m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode));
103 virtual void SequenceComplete(
void *pSequence) {
104 m_impl.SequenceComplete(AsSequence(pSequence));
107 virtual void *NewMap(
const Mark &mark,
const std::string &tag,
109 return CheckType<Map>(m_impl.NewMap(mark, tag, AsNode(pParentNode)));
111 virtual void AssignInMap(
void *pMap,
void *pKeyNode,
void *pValueNode) {
112 m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode));
114 virtual void MapComplete(
void *pMap) { m_impl.MapComplete(AsMap(pMap)); }
116 virtual void *AnchorReference(
const Mark &mark,
void *pNode) {
117 return CheckType<Node>(m_impl.AnchorReference(mark, AsNode(pNode)));
124 template <
class T,
class U>
125 static T *CheckType(U *p) {
129 static Node *AsNode(
void *pNode) {
return static_cast<Node *
>(pNode); }
130 static Sequence *AsSequence(
void *pSeq) {
131 return static_cast<Sequence *
>(pSeq);
133 static Map *AsMap(
void *pMap) {
return static_cast<Map *
>(pMap); }
136 void *BuildGraphOfNextDocument(
Parser &parser,
139 template <
class Impl>
140 typename Impl::Node *BuildGraphOfNextDocument(
Parser &parser, Impl &impl) {
142 return static_cast<typename Impl::Node *
>(
143 BuildGraphOfNextDocument(parser, graphBuilder));
147 #endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66
A parser turns a stream of bytes into one stream of "events" per YAML document in the input stream...
Definition: parser.h:27
Definition: DrawableObjectLoader.h:10
Definition: graphbuilder.h:67
Definition: graphbuilder.h:20