Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:43

0001 #ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0002 #define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0003 
0004 #if defined(_MSC_VER) ||                                            \
0005     (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
0006      (__GNUC__ >= 4))  // GCC supports "pragma once" correctly since 3.4
0007 #pragma once
0008 #endif
0009 
0010 #include <list>
0011 #include <map>
0012 #include <string>
0013 #include <utility>
0014 #include <vector>
0015 
0016 #include "yaml-cpp/dll.h"
0017 #include "yaml-cpp/node/detail/node_iterator.h"
0018 #include "yaml-cpp/node/iterator.h"
0019 #include "yaml-cpp/node/ptr.h"
0020 #include "yaml-cpp/node/type.h"
0021 
0022 namespace YAML {
0023 namespace detail {
0024 class node;
0025 }  // namespace detail
0026 }  // namespace YAML
0027 
0028 namespace YAML {
0029 namespace detail {
0030 class YAML_CPP_API node_data {
0031  public:
0032   node_data();
0033   node_data(const node_data&) = delete;
0034   node_data& operator=(const node_data&) = delete;
0035 
0036   void mark_defined();
0037   void set_mark(const Mark& mark);
0038   void set_type(NodeType::value type);
0039   void set_tag(const std::string& tag);
0040   void set_null();
0041   void set_scalar(const std::string& scalar);
0042   void set_style(EmitterStyle::value style);
0043 
0044   bool is_defined() const { return m_isDefined; }
0045   const Mark& mark() const { return m_mark; }
0046   NodeType::value type() const {
0047     return m_isDefined ? m_type : NodeType::Undefined;
0048   }
0049   const std::string& scalar() const { return m_scalar; }
0050   const std::string& tag() const { return m_tag; }
0051   EmitterStyle::value style() const { return m_style; }
0052 
0053   // size/iterator
0054   std::size_t size() const;
0055 
0056   const_node_iterator begin() const;
0057   node_iterator begin();
0058 
0059   const_node_iterator end() const;
0060   node_iterator end();
0061 
0062   // sequence
0063   void push_back(node& node, const shared_memory_holder& pMemory);
0064   void insert(node& key, node& value, const shared_memory_holder& pMemory);
0065 
0066   // indexing
0067   template <typename Key>
0068   node* get(const Key& key, shared_memory_holder pMemory) const;
0069   template <typename Key>
0070   node& get(const Key& key, shared_memory_holder pMemory);
0071   template <typename Key>
0072   bool remove(const Key& key, shared_memory_holder pMemory);
0073 
0074   node* get(node& key, const shared_memory_holder& pMemory) const;
0075   node& get(node& key, const shared_memory_holder& pMemory);
0076   bool remove(node& key, const shared_memory_holder& pMemory);
0077 
0078   // map
0079   template <typename Key, typename Value>
0080   void force_insert(const Key& key, const Value& value,
0081                     shared_memory_holder pMemory);
0082 
0083  public:
0084   static const std::string& empty_scalar();
0085 
0086  private:
0087   void compute_seq_size() const;
0088   void compute_map_size() const;
0089 
0090   void reset_sequence();
0091   void reset_map();
0092 
0093   void insert_map_pair(node& key, node& value);
0094   void convert_to_map(const shared_memory_holder& pMemory);
0095   void convert_sequence_to_map(const shared_memory_holder& pMemory);
0096 
0097   template <typename T>
0098   static node& convert_to_node(const T& rhs, shared_memory_holder pMemory);
0099 
0100  private:
0101   bool m_isDefined;
0102   Mark m_mark;
0103   NodeType::value m_type;
0104   std::string m_tag;
0105   EmitterStyle::value m_style;
0106 
0107   // scalar
0108   std::string m_scalar;
0109 
0110   // sequence
0111   using node_seq = std::vector<node *>;
0112   node_seq m_sequence;
0113 
0114   mutable std::size_t m_seqSize;
0115 
0116   // map
0117   using node_map = std::vector<std::pair<node*, node*>>;
0118   node_map m_map;
0119 
0120   using kv_pair = std::pair<node*, node*>;
0121   using kv_pairs = std::list<kv_pair>;
0122   mutable kv_pairs m_undefinedPairs;
0123 };
0124 }
0125 }
0126 
0127 #endif  // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66