/src/yaml-cpp/include/yaml-cpp/node/detail/node_data.h
Line | Count | Source |
1 | | #ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
2 | | #define VALUE_DETAIL_NODE_DATA_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 <list> |
11 | | #include <map> |
12 | | #include <string> |
13 | | #include <utility> |
14 | | #include <vector> |
15 | | |
16 | | #include "yaml-cpp/dll.h" |
17 | | #include "yaml-cpp/node/detail/node_iterator.h" |
18 | | #include "yaml-cpp/node/iterator.h" |
19 | | #include "yaml-cpp/node/ptr.h" |
20 | | #include "yaml-cpp/node/type.h" |
21 | | |
22 | | namespace YAML { |
23 | | namespace detail { |
24 | | class node; |
25 | | } // namespace detail |
26 | | } // namespace YAML |
27 | | |
28 | | namespace YAML { |
29 | | namespace detail { |
30 | | class YAML_CPP_API node_data { |
31 | | public: |
32 | | node_data(); |
33 | | node_data(const node_data&) = delete; |
34 | | node_data& operator=(const node_data&) = delete; |
35 | | |
36 | | void mark_defined(); |
37 | | void set_mark(const Mark& mark); |
38 | | void set_type(NodeType::value type); |
39 | | void set_tag(const std::string& tag); |
40 | | void set_null(); |
41 | | void set_scalar(const std::string& scalar); |
42 | | void set_style(EmitterStyle::value style); |
43 | | |
44 | 7.50M | bool is_defined() const { return m_isDefined; } |
45 | 0 | const Mark& mark() const { return m_mark; } |
46 | 4.67M | NodeType::value type() const { |
47 | 4.67M | return m_isDefined ? m_type : NodeType::Undefined; |
48 | 4.67M | } |
49 | 3.76M | const std::string& scalar() const { return m_scalar; } |
50 | 0 | const std::string& tag() const { return m_tag; } |
51 | 0 | EmitterStyle::value style() const { return m_style; } |
52 | | |
53 | | // size/iterator |
54 | | std::size_t size() const; |
55 | | |
56 | | const_node_iterator begin() const; |
57 | | node_iterator begin(); |
58 | | |
59 | | const_node_iterator end() const; |
60 | | node_iterator end(); |
61 | | |
62 | | // sequence |
63 | | void push_back(node& node, const shared_memory_holder& pMemory); |
64 | | void insert(node& key, node& value, const shared_memory_holder& pMemory); |
65 | | |
66 | | // indexing |
67 | | template <typename Key> |
68 | | node* get(const Key& key, shared_memory_holder pMemory) const; |
69 | | template <typename Key> |
70 | | node& get(const Key& key, shared_memory_holder pMemory); |
71 | | template <typename Key> |
72 | | bool remove(const Key& key, shared_memory_holder pMemory); |
73 | | |
74 | | node* get(node& key, const shared_memory_holder& pMemory) const; |
75 | | node& get(node& key, const shared_memory_holder& pMemory); |
76 | | bool remove(node& key, const shared_memory_holder& pMemory); |
77 | | |
78 | | // map |
79 | | template <typename Key, typename Value> |
80 | | void force_insert(const Key& key, const Value& value, |
81 | | shared_memory_holder pMemory); |
82 | | |
83 | | public: |
84 | | static const std::string& empty_scalar(); |
85 | | |
86 | | private: |
87 | | void compute_seq_size() const; |
88 | | void compute_map_size() const; |
89 | | |
90 | | void reset_sequence(); |
91 | | void reset_map(); |
92 | | |
93 | | void insert_map_pair(node& key, node& value, bool force = false); |
94 | | void convert_to_map(const shared_memory_holder& pMemory); |
95 | | void convert_sequence_to_map(const shared_memory_holder& pMemory); |
96 | | |
97 | | template <typename T> |
98 | | static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); |
99 | | |
100 | | private: |
101 | | bool m_isDefined; |
102 | | Mark m_mark; |
103 | | NodeType::value m_type; |
104 | | std::string m_tag; |
105 | | EmitterStyle::value m_style; |
106 | | |
107 | | // scalar |
108 | | std::string m_scalar; |
109 | | |
110 | | // sequence |
111 | | using node_seq = std::vector<node *>; |
112 | | node_seq m_sequence; |
113 | | |
114 | | mutable std::size_t m_seqSize; |
115 | | |
116 | | // map |
117 | | using node_map = std::vector<std::pair<node*, node*>>; |
118 | | node_map m_map; |
119 | | |
120 | | using kv_pair = std::pair<node*, node*>; |
121 | | using kv_pairs = std::list<kv_pair>; |
122 | | mutable kv_pairs m_undefinedPairs; |
123 | | }; |
124 | | } |
125 | | } |
126 | | |
127 | | #endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |