| 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> |
no test coverage detected