1 #ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 #define NODE_DETAIL_IMPL_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/node/detail/node.h" 11 #include "yaml-cpp/node/detail/node_data.h" 12 #include <type_traits> 16 template <
typename Key,
typename Enable =
void>
18 static node*
get(
const std::vector<node*>& ,
19 const Key& , shared_memory_holder ) {
24 template <
typename Key>
27 !std::is_same<Key, bool>::value>::type> {
28 static node*
get(
const std::vector<node*>& sequence,
const Key& key,
29 shared_memory_holder ) {
30 return key < sequence.size() ? sequence[key] : 0;
33 static node*
get(std::vector<node*>& sequence,
const Key& key,
34 shared_memory_holder pMemory) {
35 if (key > sequence.size() || (key > 0 && !sequence[key-1]->is_defined()))
37 if (key == sequence.size())
38 sequence.push_back(&pMemory->create_node());
43 template <
typename Key>
45 static node*
get(
const std::vector<node*>& sequence,
const Key& key,
46 shared_memory_holder pMemory) {
48 sequence, static_cast<std::size_t>(key), pMemory)
51 static node*
get(std::vector<node*>& sequence,
const Key& key,
52 shared_memory_holder pMemory) {
54 sequence, static_cast<std::size_t>(key), pMemory)
60 inline bool node::equals(
const T& rhs, shared_memory_holder pMemory) {
68 inline bool node::equals(
const char* rhs, shared_memory_holder pMemory) {
69 return equals<std::string>(rhs, pMemory);
73 template <
typename Key>
74 inline node* node_data::get(
const Key& key,
75 shared_memory_holder pMemory)
const {
79 case NodeType::Undefined:
82 case NodeType::Sequence:
86 case NodeType::Scalar:
90 for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
91 if (it->first->equals(key, pMemory)) {
99 template <
typename Key>
100 inline node& node_data::get(
const Key& key, shared_memory_holder pMemory) {
104 case NodeType::Undefined:
106 case NodeType::Sequence:
108 m_type = NodeType::Sequence;
112 convert_to_map(pMemory);
114 case NodeType::Scalar:
118 for (node_map::const_iterator it = m_map.begin(); it != m_map.end(); ++it) {
119 if (it->first->equals(key, pMemory)) {
124 node& k = convert_to_node(key, pMemory);
125 node& v = pMemory->create_node();
126 insert_map_pair(k, v);
130 template <
typename Key>
131 inline bool node_data::remove(
const Key& key, shared_memory_holder pMemory) {
132 if (m_type != NodeType::Map)
135 for (kv_pairs::iterator it = m_undefinedPairs.begin();
136 it != m_undefinedPairs.end();) {
137 kv_pairs::iterator jt = std::next(it);
138 if (it->first->equals(key, pMemory))
139 m_undefinedPairs.erase(it);
143 for (node_map::iterator it = m_map.begin(); it != m_map.end(); ++it) {
144 if (it->first->equals(key, pMemory)) {
154 template <
typename Key,
typename Value>
155 inline void node_data::force_insert(
const Key& key,
const Value& value,
156 shared_memory_holder pMemory) {
160 case NodeType::Undefined:
162 case NodeType::Sequence:
163 convert_to_map(pMemory);
165 case NodeType::Scalar:
169 node& k = convert_to_node(key, pMemory);
170 node& v = convert_to_node(value, pMemory);
171 insert_map_pair(k, v);
174 template <
typename T>
175 inline node& node_data::convert_to_node(
const T& rhs,
176 shared_memory_holder pMemory) {
178 value.EnsureNodeExists();
179 pMemory->merge(*value.m_pMemory);
180 return *value.m_pNode;
185 #endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 Definition: exceptions.h:233
Definition: exceptions.h:217
Definition: _tbb_windef.h:37
Definition: DrawableObjectLoader.h:10