MCPcopy Create free account
hub / github.com/cinder/Cinder / print_element_node

Function print_element_node

include/rapidxml/rapidxml_print.hpp:192–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190 // Print element node
191 template<class OutIt, class Ch>
192 inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
193 {
194 assert(node->type() == node_element);
195
196 // Print element name and attributes, if any
197 if (!(flags & print_no_indenting))
198 out = fill_chars(out, indent, Ch('\t'));
199 *out = Ch('<'), ++out;
200 out = copy_chars(node->name(), node->name() + node->name_size(), out);
201 out = print_attributes(out, node, flags);
202
203 // If node is childless
204 if (node->value_size() == 0 && !node->first_node())
205 {
206 // Print childless node tag ending
207 *out = Ch('/'), ++out;
208 *out = Ch('>'), ++out;
209 }
210 else
211 {
212 // Print normal node tag ending
213 *out = Ch('>'), ++out;
214
215 // Test if node contains a single data node only (and no other nodes)
216 xml_node<Ch> *child = node->first_node();
217 if (!child)
218 {
219 // If node has no children, only print its value without indenting
220 out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
221 }
222 else if (child->next_sibling() == 0 && child->type() == node_data)
223 {
224 // If node has a sole data child, only print its value without indenting
225 out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);
226 }
227 else
228 {
229 // Print all children with full indenting
230 if (!(flags & print_no_indenting))
231 *out = Ch('\n'), ++out;
232 out = print_children(out, node, flags, indent + 1);
233 if (!(flags & print_no_indenting))
234 out = fill_chars(out, indent, Ch('\t'));
235 }
236
237 // Print node end
238 *out = Ch('<'), ++out;
239 *out = Ch('/'), ++out;
240 out = copy_chars(node->name(), node->name() + node->name_size(), out);
241 *out = Ch('>'), ++out;
242 }
243 return out;
244 }
245
246 // Print declaration node
247 template<class OutIt, class Ch>

Callers 1

print_nodeFunction · 0.85

Calls 13

assertFunction · 0.85
fill_charsFunction · 0.85
copy_charsFunction · 0.85
print_attributesFunction · 0.85
copy_and_expand_charsFunction · 0.85
print_childrenFunction · 0.85
name_sizeMethod · 0.80
value_sizeMethod · 0.80
first_nodeMethod · 0.80
next_siblingMethod · 0.80
typeMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected