nodeimpl.h
Go to the documentation of this file.
1 #ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define NODEIMPL_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/nodeutil.h"
10 #include <cassert>
11 
12 namespace YAML_PM
13 {
14  // implementation of templated things
15  template <typename T>
16  inline const T Node::to() const {
17  T value;
18  *this >> value;
19  return value;
20  }
21 
22  template <typename T>
23  inline typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value) {
24  if(!ConvertScalar(node, value))
25  throw InvalidScalar(node.m_mark);
26  }
27 
28  template <typename T>
29  inline const Node *Node::FindValue(const T& key) const {
30  switch(m_type) {
31  case NodeType::Null:
32  case NodeType::Scalar:
33  throw BadDereference();
34  case NodeType::Sequence:
35  return FindFromNodeAtIndex(*this, key);
36  case NodeType::Map:
37  return FindValueForKey(key);
38  }
39  assert(false);
40  throw BadDereference();
41  }
42 
43  template <typename T>
44  inline const Node *Node::FindValueForKey(const T& key) const {
45  for(Iterator it=begin();it!=end();++it) {
46  T t;
47  if(it.first().Read(t)) {
48  if(key == t)
49  return &it.second();
50  }
51  }
52 
53  return 0;
54  }
55 
56  template <typename T>
57  inline const Node& Node::GetValue(const T& key) const {
58  if(const Node *pValue = FindValue(key))
59  return *pValue;
60  throw MakeTypedKeyNotFound(m_mark, key);
61  }
62 
63  template <typename T>
64  inline const Node& Node::operator [] (const T& key) const {
65  return GetValue(key);
66  }
67 
68  inline const Node *Node::FindValue(const char *key) const {
69  return FindValue(std::string(key));
70  }
71 
72  inline const Node *Node::FindValue(char *key) const {
73  return FindValue(std::string(key));
74  }
75 
76  inline const Node& Node::operator [] (const char *key) const {
77  return GetValue(std::string(key));
78  }
79 
80  inline const Node& Node::operator [] (char *key) const {
81  return GetValue(std::string(key));
82  }
83 }
84 
85 #endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
YAML_PM::Node::begin
Iterator begin() const
Definition: node.cpp:141
YAML_PM::ConvertScalar
bool ConvertScalar(const Node &node, T &value)
Definition: nodereadimpl.h:77
YAML_PM
Definition: aliasmanager.h:11
YAML_PM::Node::m_type
NodeType::value m_type
Definition: node.h:125
YAML_PM::FindFromNodeAtIndex
const Node * FindFromNodeAtIndex(const Node &node, const T &key)
Definition: nodeutil.h:57
YAML_PM::MakeTypedKeyNotFound
TypedKeyNotFound< T > MakeTypedKeyNotFound(const Mark &mark, const T &key)
Definition: exceptions.h:147
YAML_PM::Node::end
Iterator end() const
Definition: node.cpp:159
nodeutil.h
YAML_PM::Node::FindValueForKey
const Node * FindValueForKey(const T &key) const
Definition: nodeimpl.h:44
testing::internal::string
::std::string string
Definition: gtest.h:1979
YAML_PM::Node::operator[]
const Node & operator[](const T &key) const
Definition: nodeimpl.h:64
YAML_PM::Node::GetValue
const Node & GetValue(const T &key) const
Definition: nodeimpl.h:57
YAML_PM::Node::FindValue
const Node * FindValue(const T &key) const
Definition: nodeimpl.h:29
YAML_PM::operator>>
void operator>>(const Node &node, Binary &binary)
Definition: binary.cpp:95
YAML_PM::Node
Definition: node.h:33
YAML_PM::Node::to
const T to() const
Definition: nodeimpl.h:16
YAML_PM::BadDereference
Definition: exceptions.h:151
YAML_PM::InvalidScalar
Definition: exceptions.h:123
YAML_PM::NodeType::Sequence
@ Sequence
Definition: node.h:31
YAML_PM::Iterator
Definition: iterator.h:16
YAML_PM::NodeType::Scalar
@ Scalar
Definition: node.h:31
YAML_PM::enable_if
Definition: traits.h:42
YAML_PM::Node::m_mark
Mark m_mark
Definition: node.h:119
YAML_PM::NodeType::Null
@ Null
Definition: node.h:31
YAML_PM::NodeType::Map
@ Map
Definition: node.h:31
t
geometry_msgs::TransformStamped t


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