| 3438 | } |
| 3439 | |
| 3440 | PUGI__FN void node_output( |
| 3441 | xml_buffered_writer& writer, |
| 3442 | const xml_node& node, |
| 3443 | const char_t* indent, |
| 3444 | unsigned int flags, |
| 3445 | unsigned int depth) |
| 3446 | { |
| 3447 | const char_t* default_name = PUGIXML_TEXT(":anonymous"); |
| 3448 | |
| 3449 | if ((flags & format_indent) != 0 && (flags & format_raw) == 0) |
| 3450 | for (unsigned int i = 0; i < depth; ++i) |
| 3451 | writer.write(indent); |
| 3452 | |
| 3453 | switch (node.type()) |
| 3454 | { |
| 3455 | case node_document: |
| 3456 | { |
| 3457 | for (xml_node n = node.first_child(); n; n = n.next_sibling()) |
| 3458 | node_output(writer, n, indent, flags, depth); |
| 3459 | break; |
| 3460 | } |
| 3461 | |
| 3462 | case node_element: |
| 3463 | { |
| 3464 | const char_t* name = node.name()[0] ? node.name() : default_name; |
| 3465 | |
| 3466 | writer.write('<'); |
| 3467 | writer.write(name); |
| 3468 | |
| 3469 | node_output_attributes(writer, node, flags); |
| 3470 | |
| 3471 | if (flags & format_raw) |
| 3472 | { |
| 3473 | if (!node.first_child()) |
| 3474 | { |
| 3475 | if (flags & format_space_before_slash) |
| 3476 | writer.write(' '); |
| 3477 | writer.write('/', '>'); |
| 3478 | } |
| 3479 | else |
| 3480 | { |
| 3481 | writer.write('>'); |
| 3482 | |
| 3483 | for (xml_node n = node.first_child(); n; n = n.next_sibling()) |
| 3484 | node_output(writer, n, indent, flags, depth + 1); |
| 3485 | |
| 3486 | writer.write('<', '/'); |
| 3487 | writer.write(name); |
| 3488 | writer.write('>'); |
| 3489 | } |
| 3490 | } |
| 3491 | else if (!node.first_child()) |
| 3492 | { |
| 3493 | if (flags & format_space_before_slash) |
| 3494 | writer.write(' '); |
| 3495 | writer.write('/', '>'); |
| 3496 | if (flags & format_win_new_line) |
| 3497 | writer.write('\r'); |
no test coverage detected