File indexing completed on 2025-05-12 09:08:08
0001 #ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0002 #define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0003
0004 #if defined(_MSC_VER) || \
0005 (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
0006 (__GNUC__ >= 4))
0007 #pragma once
0008 #endif
0009
0010 #include "ATOOLS/YAML/yaml-cpp/dll.h"
0011 #include "ATOOLS/YAML/yaml-cpp/node/type.h"
0012 #include "ATOOLS/YAML/yaml-cpp/node/ptr.h"
0013 #include "ATOOLS/YAML/yaml-cpp/node/detail/node_data.h"
0014
0015 namespace SHERPA_YAML {
0016 namespace detail {
0017 class node_ref {
0018 public:
0019 node_ref() : m_pData(new node_data) {}
0020 node_ref(const node_ref&) = delete;
0021 node_ref& operator=(const node_ref&) = delete;
0022
0023 bool is_defined() const { return m_pData->is_defined(); }
0024 const Mark& mark() const { return m_pData->mark(); }
0025 NodeType::value type() const { return m_pData->type(); }
0026 const std::string& scalar() const { return m_pData->scalar(); }
0027 const std::string& tag() const { return m_pData->tag(); }
0028 EmitterStyle::value style() const { return m_pData->style(); }
0029
0030 void mark_defined() { m_pData->mark_defined(); }
0031 void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; }
0032
0033 void set_mark(const Mark& mark) { m_pData->set_mark(mark); }
0034 void set_type(NodeType::value type) { m_pData->set_type(type); }
0035 void set_tag(const std::string& tag) { m_pData->set_tag(tag); }
0036 void set_null() { m_pData->set_null(); }
0037 void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); }
0038 void set_style(EmitterStyle::value style) { m_pData->set_style(style); }
0039
0040
0041 std::size_t size() const { return m_pData->size(); }
0042
0043 const_node_iterator begin() const {
0044 return static_cast<const node_data&>(*m_pData).begin();
0045 }
0046 node_iterator begin() { return m_pData->begin(); }
0047
0048 const_node_iterator end() const {
0049 return static_cast<const node_data&>(*m_pData).end();
0050 }
0051 node_iterator end() { return m_pData->end(); }
0052
0053
0054 void push_back(node& node, shared_memory_holder pMemory) {
0055 m_pData->push_back(node, pMemory);
0056 }
0057 void insert(node& key, node& value, shared_memory_holder pMemory) {
0058 m_pData->insert(key, value, pMemory);
0059 }
0060
0061
0062 template <typename Key>
0063 node* get(const Key& key, shared_memory_holder pMemory) const {
0064 return static_cast<const node_data&>(*m_pData).get(key, pMemory);
0065 }
0066 template <typename Key>
0067 node& get(const Key& key, shared_memory_holder pMemory) {
0068 return m_pData->get(key, pMemory);
0069 }
0070 template <typename Key>
0071 bool remove(const Key& key, shared_memory_holder pMemory) {
0072 return m_pData->remove(key, pMemory);
0073 }
0074
0075 node* get(node& key, shared_memory_holder pMemory) const {
0076 return static_cast<const node_data&>(*m_pData).get(key, pMemory);
0077 }
0078 node& get(node& key, shared_memory_holder pMemory) {
0079 return m_pData->get(key, pMemory);
0080 }
0081 bool remove(node& key, shared_memory_holder pMemory) {
0082 return m_pData->remove(key, pMemory);
0083 }
0084
0085
0086 template <typename Key, typename Value>
0087 void force_insert(const Key& key, const Value& value,
0088 shared_memory_holder pMemory) {
0089 m_pData->force_insert(key, value, pMemory);
0090 }
0091
0092 private:
0093 shared_node_data m_pData;
0094 };
0095 }
0096 }
0097
0098 #endif