node.h
Go to the documentation of this file.
1 #ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define NODE_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 
9 #include "yaml-cpp-pm/dll.h"
10 #include "yaml-cpp-pm/exceptions.h"
11 #include "yaml-cpp-pm/mark.h"
13 #include "yaml-cpp-pm/conversion.h"
14 #include "yaml-cpp-pm/iterator.h"
15 #include "yaml-cpp-pm/ltnode.h"
16 #include <iostream>
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 namespace YAML_PM
23 {
24  class AliasManager;
25  class Content;
26  class NodeOwnership;
27  class Scanner;
28  class Emitter;
29  class EventHandler;
30 
31  struct NodeType { enum value { Null, Scalar, Sequence, Map }; };
32 
33  class YAML_CPP_API Node: private noncopyable
34  {
35  public:
36  friend class NodeOwnership;
37  friend class NodeBuilder;
38 
39  Node();
40  ~Node();
41 
42  void Clear();
43  std::auto_ptr<Node> Clone() const;
44  void EmitEvents(EventHandler& eventHandler) const;
45  void EmitEvents(AliasManager& am, EventHandler& eventHandler) const;
46 
47  NodeType::value Type() const { return m_type; }
48  bool IsAliased() const;
49 
50  // file location of start of this node
51  const Mark GetMark() const { return m_mark; }
52 
53  // accessors
54  Iterator begin() const;
55  Iterator end() const;
56  std::size_t size() const;
57 
58  // extraction of scalars
59  bool GetScalar(std::string& s) const;
60 
61  // we can specialize this for other values
62  template <typename T>
63  bool Read(T& value) const;
64 
65  template <typename T>
66  const T to() const;
67 
68  template <typename T>
69  friend YAML_CPP_API typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value);
70 
71  // retrieval for maps and sequences
72  template <typename T>
73  const Node *FindValue(const T& key) const;
74 
75  template <typename T>
76  const Node& operator [] (const T& key) const;
77 
78  // specific to maps
79  const Node *FindValue(const char *key) const;
80  const Node *FindValue(char *key) const;
81  const Node& operator [] (const char *key) const;
82  const Node& operator [] (char *key) const;
83 
84  // for tags
85  const std::string& Tag() const { return m_tag; }
86 
87  // emitting
88  friend YAML_CPP_API Emitter& operator << (Emitter& out, const Node& node);
89 
90  // ordering
91  int Compare(const Node& rhs) const;
92  friend bool operator < (const Node& n1, const Node& n2);
93 
94  private:
95  explicit Node(NodeOwnership& owner);
96  Node& CreateNode();
97 
98  void Init(NodeType::value type, const Mark& mark, const std::string& tag);
99 
100  void MarkAsAliased();
101  void SetScalarData(const std::string& data);
102  void Append(Node& node);
103  void Insert(Node& key, Node& value);
104 
105  // helper for sequences
106  template <typename, bool> friend struct _FindFromNodeAtIndex;
107  const Node *FindAtIndex(std::size_t i) const;
108 
109  // helper for maps
110  template <typename T>
111  const Node& GetValue(const T& key) const;
112 
113  template <typename T>
114  const Node *FindValueForKey(const T& key) const;
115 
116  private:
117  std::auto_ptr<NodeOwnership> m_pOwnership;
118 
121 
122  typedef std::vector<Node *> node_seq;
123  typedef std::map<Node *, Node *, ltnode> node_map;
124 
127  node_seq m_seqData;
128  node_map m_mapData;
129  };
130 }
131 
132 #include "yaml-cpp-pm/nodeimpl.h"
134 
135 #endif // NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
node_seq m_seqData
Definition: node.h:127
node_map m_mapData
Definition: node.h:128
std::map< Node *, Node *, ltnode > node_map
Definition: node.h:123
bool operator<(const Node &n1, const Node &n2)
Definition: node.cpp:265
::std::string string
Definition: gtest.h:1979
data
Definition: icp.py:50
Mark m_mark
Definition: node.h:119
#define YAML_CPP_API
Definition: dll.h:25
Emitter & operator<<(Emitter &emitter, const std::string &v)
Definition: emitter.h:148
const Mark GetMark() const
Definition: node.h:51
int Read(int fd, void *buf, unsigned int count)
Definition: gtest.h:2890
std::string m_tag
Definition: node.h:120
NodeType::value m_type
Definition: node.h:125
void operator>>(const Node &node, Binary &binary)
Definition: binary.cpp:95
NodeType::value Type() const
Definition: node.h:47
std::string m_scalarData
Definition: node.h:126
const std::string & Tag() const
Definition: node.h:85
std::vector< Node * > node_seq
Definition: node.h:122
std::auto_ptr< NodeOwnership > m_pOwnership
Definition: node.h:117


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