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 
129  };
130 }
131 
132 #include "yaml-cpp-pm/nodeimpl.h"
134 
135 #endif // NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
exceptions.h
YAML_PM::NodeOwnership
Definition: nodeownership.h:17
YAML_PM::NodeBuilder
Definition: nodebuilder.h:18
YAML_PM
Definition: aliasmanager.h:11
YAML_PM::Node::m_type
NodeType::value m_type
Definition: node.h:125
YAML_PM::EventHandler
Definition: eventhandler.h:15
YAML_PM::Node::node_seq
std::vector< Node * > node_seq
Definition: node.h:122
ltnode.h
Read
Read
testing::internal::string
::std::string string
Definition: gtest.h:1979
YAML_CPP_API
#define YAML_CPP_API
Definition: dll.h:25
Append
Append
YAML_PM::NodeType
Definition: node.h:31
kitti-batch-convert.out
string out
Definition: kitti-batch-convert.py:7
YAML_PM::Node::m_scalarData
std::string m_scalarData
Definition: node.h:126
iterator.h
YAML_PM::Node::Tag
const std::string & Tag() const
Definition: node.h:85
YAML_PM::operator>>
void operator>>(const Node &node, Binary &binary)
Definition: binary.cpp:95
YAML_PM::Node::m_pOwnership
std::auto_ptr< NodeOwnership > m_pOwnership
Definition: node.h:117
conversion.h
YAML_PM::Node
Definition: node.h:33
YAML_PM::AliasManager
Definition: aliasmanager.h:15
YAML_PM::Node::m_seqData
node_seq m_seqData
Definition: node.h:127
YAML_PM::operator<<
Emitter & operator<<(Emitter &emitter, const std::string &v)
Definition: emitter.h:148
YAML_PM::Node::node_map
std::map< Node *, Node *, ltnode > node_map
Definition: node.h:123
noncopyable.h
YAML_PM::Emitter
Definition: emitter.h:23
YAML_PM::Node::GetMark
const Mark GetMark() const
Definition: node.h:51
YAML_PM::Mark
Definition: mark.h:13
YAML_PM::Node::m_mapData
node_map m_mapData
Definition: node.h:128
YAML_PM::NodeType::Sequence
@ Sequence
Definition: node.h:31
YAML_PM::Node::m_tag
std::string m_tag
Definition: node.h:120
YAML_PM::Iterator
Definition: iterator.h:16
YAML_PM::_FindFromNodeAtIndex
Definition: nodeutil.h:45
nodereadimpl.h
YAML_PM::NodeType::Scalar
@ Scalar
Definition: node.h:31
dll.h
nodeimpl.h
YAML_PM::enable_if
Definition: traits.h:42
YAML_PM::Node::m_mark
Mark m_mark
Definition: node.h:119
YAML_PM::operator<
bool operator<(const Node &n1, const Node &n2)
Definition: node.cpp:265
YAML_PM::NodeType::Null
@ Null
Definition: node.h:31
YAML_PM::NodeType::value
value
Definition: node.h:31
YAML_PM::NodeType::Map
@ Map
Definition: node.h:31
mark.h
YAML_PM::Node::Type
NodeType::value Type() const
Definition: node.h:47
YAML_PM::noncopyable
Definition: noncopyable.h:13


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