1 #ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
3 
4 #if defined(_MSC_VER) ||                                            \
5     (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
6      (__GNUC__ >= 4))  // GCC supports "pragma once" correctly since 3.4
7 #pragma once
8 #endif
9 
10 #include "yaml-cpp/dll.h"
11 #include "yaml-cpp/node/type.h"
12 #include "yaml-cpp/node/ptr.h"
13 #include "yaml-cpp/node/detail/node_data.h"
14 
15 namespace YAML {
16 namespace detail {
17 class node_ref {
18  public:
node_ref()19   node_ref() : m_pData(new node_data) {}
20   node_ref(const node_ref&) = delete;
21   node_ref& operator=(const node_ref&) = delete;
22 
is_defined() const23   bool is_defined() const { return m_pData->is_defined(); }
mark() const24   const Mark& mark() const { return m_pData->mark(); }
type() const25   NodeType::value type() const { return m_pData->type(); }
scalar() const26   const std::string& scalar() const { return m_pData->scalar(); }
tag() const27   const std::string& tag() const { return m_pData->tag(); }
style() const28   EmitterStyle::value style() const { return m_pData->style(); }
29 
mark_defined()30   void mark_defined() { m_pData->mark_defined(); }
set_data(const node_ref & rhs)31   void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; }
32 
set_mark(const Mark & mark)33   void set_mark(const Mark& mark) { m_pData->set_mark(mark); }
set_type(NodeType::value type)34   void set_type(NodeType::value type) { m_pData->set_type(type); }
set_tag(const std::string & tag)35   void set_tag(const std::string& tag) { m_pData->set_tag(tag); }
set_null()36   void set_null() { m_pData->set_null(); }
set_scalar(const std::string & scalar)37   void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); }
set_style(EmitterStyle::value style)38   void set_style(EmitterStyle::value style) { m_pData->set_style(style); }
39 
40   // size/iterator
size() const41   std::size_t size() const { return m_pData->size(); }
42 
begin() const43   const_node_iterator begin() const {
44     return static_cast<const node_data&>(*m_pData).begin();
45   }
begin()46   node_iterator begin() { return m_pData->begin(); }
47 
end() const48   const_node_iterator end() const {
49     return static_cast<const node_data&>(*m_pData).end();
50   }
end()51   node_iterator end() { return m_pData->end(); }
52 
53   // sequence
push_back(node & node,shared_memory_holder pMemory)54   void push_back(node& node, shared_memory_holder pMemory) {
55     m_pData->push_back(node, pMemory);
56   }
insert(node & key,node & value,shared_memory_holder pMemory)57   void insert(node& key, node& value, shared_memory_holder pMemory) {
58     m_pData->insert(key, value, pMemory);
59   }
60 
61   // indexing
62   template <typename Key>
get(const Key & key,shared_memory_holder pMemory) const63   node* get(const Key& key, shared_memory_holder pMemory) const {
64     return static_cast<const node_data&>(*m_pData).get(key, pMemory);
65   }
66   template <typename Key>
get(const Key & key,shared_memory_holder pMemory)67   node& get(const Key& key, shared_memory_holder pMemory) {
68     return m_pData->get(key, pMemory);
69   }
70   template <typename Key>
remove(const Key & key,shared_memory_holder pMemory)71   bool remove(const Key& key, shared_memory_holder pMemory) {
72     return m_pData->remove(key, pMemory);
73   }
74 
get(node & key,shared_memory_holder pMemory) const75   node* get(node& key, shared_memory_holder pMemory) const {
76     return static_cast<const node_data&>(*m_pData).get(key, pMemory);
77   }
get(node & key,shared_memory_holder pMemory)78   node& get(node& key, shared_memory_holder pMemory) {
79     return m_pData->get(key, pMemory);
80   }
remove(node & key,shared_memory_holder pMemory)81   bool remove(node& key, shared_memory_holder pMemory) {
82     return m_pData->remove(key, pMemory);
83   }
84 
85   // map
86   template <typename Key, typename Value>
force_insert(const Key & key,const Value & value,shared_memory_holder pMemory)87   void force_insert(const Key& key, const Value& value,
88                     shared_memory_holder pMemory) {
89     m_pData->force_insert(key, value, pMemory);
90   }
91 
92  private:
93   shared_node_data m_pData;
94 };
95 }
96 }
97 
98 #endif  // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
99