/src/Fast-DDS/include/fastrtps/xmlparser/XMLTree.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef _XML_TREE_ |
2 | | #define _XML_TREE_ |
3 | | |
4 | | #include <map> |
5 | | #include <memory> |
6 | | #include <string> |
7 | | #include <vector> |
8 | | |
9 | | namespace eprosima { |
10 | | namespace fastrtps { |
11 | | namespace xmlparser { |
12 | | |
13 | | enum class NodeType |
14 | | { |
15 | | PROFILES, |
16 | | PARTICIPANT, |
17 | | PUBLISHER, |
18 | | SUBSCRIBER, |
19 | | RTPS, |
20 | | QOS_PROFILE, |
21 | | APPLICATION, |
22 | | TYPE, |
23 | | TOPIC, |
24 | | DATA_WRITER, |
25 | | DATA_READER, |
26 | | ROOT, |
27 | | TYPES, |
28 | | LOG, |
29 | | REQUESTER, |
30 | | REPLIER, |
31 | | LIBRARY_SETTINGS |
32 | | }; |
33 | | |
34 | | class BaseNode |
35 | | { |
36 | | public: |
37 | | |
38 | | BaseNode( |
39 | | NodeType type) |
40 | | : data_type_(type) |
41 | | , parent_(nullptr) |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | 0 | virtual ~BaseNode() = default; |
46 | | |
47 | | BaseNode( |
48 | | const BaseNode&) = delete; |
49 | | BaseNode& operator =( |
50 | | const BaseNode&) = delete; |
51 | | |
52 | | BaseNode( |
53 | | BaseNode&&) = default; |
54 | | BaseNode& operator =( |
55 | | BaseNode&&) = default; |
56 | | |
57 | | NodeType getType() const |
58 | 0 | { |
59 | 0 | return data_type_; |
60 | 0 | } |
61 | | |
62 | | void addChild( |
63 | | std::unique_ptr<BaseNode> child) |
64 | 0 | { |
65 | 0 | child->setParent(this); |
66 | 0 | children.push_back(std::move(child)); |
67 | 0 | } |
68 | | |
69 | | bool removeChild( |
70 | | const size_t& index) |
71 | 0 | { |
72 | 0 | if (children.size() > index) |
73 | 0 | { |
74 | 0 | children.erase(children.begin() + index); |
75 | 0 | return true; |
76 | 0 | } |
77 | 0 | else |
78 | 0 | { |
79 | 0 | return false; |
80 | 0 | } |
81 | 0 | } |
82 | | |
83 | | BaseNode* getChild( |
84 | | const size_t& index) const |
85 | 0 | { |
86 | 0 | if (children.empty()) |
87 | 0 | { |
88 | 0 | return nullptr; |
89 | 0 | } |
90 | 0 | return children[index].get(); |
91 | 0 | } |
92 | | |
93 | | BaseNode* getParent() const |
94 | 0 | { |
95 | 0 | return parent_; |
96 | 0 | } |
97 | | |
98 | | void setParent( |
99 | | BaseNode* parent) |
100 | 0 | { |
101 | 0 | parent_ = parent; |
102 | 0 | } |
103 | | |
104 | | size_t getNumChildren() const |
105 | 0 | { |
106 | 0 | return children.size(); |
107 | 0 | } |
108 | | |
109 | | std::vector<std::unique_ptr<BaseNode>>& getChildren() |
110 | 0 | { |
111 | 0 | return children; |
112 | 0 | } |
113 | | |
114 | | private: |
115 | | |
116 | | NodeType data_type_; |
117 | | BaseNode* parent_; |
118 | | std::vector<std::unique_ptr<BaseNode>> children; |
119 | | }; |
120 | | |
121 | | template <class T> |
122 | | class DataNode : public BaseNode |
123 | | { |
124 | | public: |
125 | | |
126 | | DataNode( |
127 | | NodeType type); |
128 | | DataNode( |
129 | | NodeType type, |
130 | | std::unique_ptr<T> data); |
131 | | virtual ~DataNode(); |
132 | | |
133 | | DataNode( |
134 | | const DataNode&) = delete; |
135 | | DataNode& operator =( |
136 | | const DataNode&) = delete; |
137 | | |
138 | | DataNode( |
139 | | DataNode&&) = default; |
140 | | DataNode& operator =( |
141 | | DataNode&&) = default; |
142 | | |
143 | | T* get() const; |
144 | | std::unique_ptr<T> getData(); |
145 | | void setData( |
146 | | std::unique_ptr<T> data); |
147 | | |
148 | | void addAttribute( |
149 | | const std::string& name, |
150 | | const std::string& value); |
151 | | const std::map<std::string, std::string>& getAttributes(); |
152 | | |
153 | | private: |
154 | | |
155 | | std::map<std::string, std::string> attributes_; |
156 | | std::unique_ptr<T> data_; |
157 | | }; |
158 | | |
159 | | template <class T> |
160 | | DataNode<T>::DataNode( |
161 | | NodeType type) |
162 | | : BaseNode(type) |
163 | | , attributes_() |
164 | | , data_(nullptr) |
165 | | { |
166 | | } |
167 | | |
168 | | template <class T> |
169 | | DataNode<T>::DataNode( |
170 | | NodeType type, |
171 | | std::unique_ptr<T> data) |
172 | | : BaseNode(type) |
173 | | , attributes_() |
174 | | , data_(std::move(data)) |
175 | 0 | { |
176 | 0 | } Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ParticipantAttributes>::DataNode(eprosima::fastrtps::xmlparser::NodeType, std::__1::unique_ptr<eprosima::fastrtps::ParticipantAttributes, std::__1::default_delete<eprosima::fastrtps::ParticipantAttributes> >) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::PublisherAttributes>::DataNode(eprosima::fastrtps::xmlparser::NodeType, std::__1::unique_ptr<eprosima::fastrtps::PublisherAttributes, std::__1::default_delete<eprosima::fastrtps::PublisherAttributes> >) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::SubscriberAttributes>::DataNode(eprosima::fastrtps::xmlparser::NodeType, std::__1::unique_ptr<eprosima::fastrtps::SubscriberAttributes, std::__1::default_delete<eprosima::fastrtps::SubscriberAttributes> >) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::TopicAttributes>::DataNode(eprosima::fastrtps::xmlparser::NodeType, std::__1::unique_ptr<eprosima::fastrtps::TopicAttributes, std::__1::default_delete<eprosima::fastrtps::TopicAttributes> >) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::RequesterAttributes>::DataNode(eprosima::fastrtps::xmlparser::NodeType, std::__1::unique_ptr<eprosima::fastrtps::RequesterAttributes, std::__1::default_delete<eprosima::fastrtps::RequesterAttributes> >) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ReplierAttributes>::DataNode(eprosima::fastrtps::xmlparser::NodeType, std::__1::unique_ptr<eprosima::fastrtps::ReplierAttributes, std::__1::default_delete<eprosima::fastrtps::ReplierAttributes> >) |
177 | | |
178 | | template <class T> |
179 | | DataNode<T>::~DataNode() |
180 | 0 | { |
181 | 0 | } Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ParticipantAttributes>::~DataNode() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::PublisherAttributes>::~DataNode() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::SubscriberAttributes>::~DataNode() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::TopicAttributes>::~DataNode() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::RequesterAttributes>::~DataNode() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ReplierAttributes>::~DataNode() |
182 | | |
183 | | template <class T> |
184 | | T* DataNode<T>::get() const |
185 | 0 | { |
186 | 0 | return data_.get(); |
187 | 0 | } Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::TopicAttributes>::get() const Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ParticipantAttributes>::get() const Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::PublisherAttributes>::get() const Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::SubscriberAttributes>::get() const Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::RequesterAttributes>::get() const Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ReplierAttributes>::get() const |
188 | | |
189 | | template <class T> |
190 | | std::unique_ptr<T> DataNode<T>::getData() |
191 | 0 | { |
192 | 0 | return std::move(data_); |
193 | 0 | } Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ParticipantAttributes>::getData() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::PublisherAttributes>::getData() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::SubscriberAttributes>::getData() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::TopicAttributes>::getData() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::RequesterAttributes>::getData() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ReplierAttributes>::getData() |
194 | | |
195 | | template <class T> |
196 | | void DataNode<T>::setData( |
197 | | std::unique_ptr<T> data) |
198 | | { |
199 | | data_ = std::move(data); |
200 | | } |
201 | | |
202 | | template <class T> |
203 | | void DataNode<T>::addAttribute( |
204 | | const std::string& name, |
205 | | const std::string& value) |
206 | 0 | { |
207 | 0 | attributes_[name] = value; |
208 | 0 | } Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::TopicAttributes>::addAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ParticipantAttributes>::addAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::PublisherAttributes>::addAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::SubscriberAttributes>::addAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::RequesterAttributes>::addAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ReplierAttributes>::addAttribute(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
209 | | |
210 | | template <class T> |
211 | | const std::map<std::string, std::string>& DataNode<T>::getAttributes() |
212 | 0 | { |
213 | 0 | return attributes_; |
214 | 0 | } Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ParticipantAttributes>::getAttributes() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::PublisherAttributes>::getAttributes() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::SubscriberAttributes>::getAttributes() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::TopicAttributes>::getAttributes() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::RequesterAttributes>::getAttributes() Unexecuted instantiation: eprosima::fastrtps::xmlparser::DataNode<eprosima::fastrtps::ReplierAttributes>::getAttributes() |
215 | | |
216 | | } // namespace xmlparser |
217 | | } // namespace fastrtps |
218 | | } // namespace eprosima |
219 | | #endif // !_XML_TREE_ |