1#ifndef RAPIDXML_PRINT_HPP_INCLUDED
2#define RAPIDXML_PRINT_HPP_INCLUDED
12#ifndef RAPIDXML_NO_STREAMS
37 template <
class OutIt,
class Ch>
inline OutIt copy_chars(
const Ch* begin,
const Ch* end, OutIt
out)
46 template <
class OutIt,
class Ch>
47 inline OutIt copy_and_expand_chars(
const Ch* begin,
const Ch* end, Ch noexpand, OutIt
out)
51 if (*begin == noexpand)
104 template <
class OutIt,
class Ch>
inline OutIt fill_chars(OutIt
out,
int n, Ch ch)
106 for (
int i = 0;
i < n; ++
i)
112 template <
class Ch, Ch ch>
inline bool find_char(
const Ch* begin,
const Ch* end)
124 template <
class OutIt,
class Ch>
125 inline OutIt print_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
128 switch (node->
type())
133 out = print_children(
out, node, flags, indent);
138 out = print_element_node(
out, node, flags, indent);
143 out = print_data_node(
out, node, flags, indent);
148 out = print_cdata_node(
out, node, flags, indent);
153 out = print_declaration_node(
out, node, flags, indent);
158 out = print_comment_node(
out, node, flags, indent);
163 out = print_doctype_node(
out, node, flags, indent);
168 out = print_pi_node(
out, node, flags, indent);
186 template <
class OutIt,
class Ch>
187 inline OutIt print_children(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
190 out = print_node(
out, child, flags, indent);
195 template <
class OutIt,
class Ch>
inline OutIt print_attributes(OutIt
out,
const xml_node<Ch>* node,
int flags)
198 attribute = attribute->next_attribute())
200 if (attribute->name() && attribute->value())
204 out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(),
out);
207 if (find_char<Ch, Ch(
'"')>(attribute->value(), attribute->value() + attribute->value_size()))
210 out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(),
217 out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(),
227 template <
class OutIt,
class Ch>
228 inline OutIt print_data_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
232 out = fill_chars(
out, indent, Ch(
'\t'));
238 template <
class OutIt,
class Ch>
239 inline OutIt print_cdata_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
243 out = fill_chars(
out, indent, Ch(
'\t'));
273 template <
class OutIt,
class Ch>
274 inline OutIt print_element_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
280 out = fill_chars(
out, indent, Ch(
'\t'));
283 out = print_attributes(
out, node, flags);
314 out = print_children(
out, node, flags, indent + 1);
316 out = fill_chars(
out, indent, Ch(
'\t'));
329 template <
class OutIt,
class Ch>
330 inline OutIt print_declaration_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
334 out = fill_chars(
out, indent, Ch(
'\t'));
342 out = print_attributes(
out, node, flags);
352 template <
class OutIt,
class Ch>
353 inline OutIt print_comment_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
357 out = fill_chars(
out, indent, Ch(
'\t'));
370 template <
class OutIt,
class Ch>
371 inline OutIt print_doctype_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
375 out = fill_chars(
out, indent, Ch(
'\t'));
392 template <
class OutIt,
class Ch>
393 inline OutIt print_pi_node(OutIt
out,
const xml_node<Ch>* node,
int flags,
int indent)
397 out = fill_chars(
out, indent, Ch(
'\t'));
421 return internal::print_node(
out, &node, flags, 0);
424#ifndef RAPIDXML_NO_STREAMS
434 print(std::ostream_iterator<Ch>(
out), node, flags);
440 template <
class Ch>
inline std::basic_ostream<Ch>&
operator<<(std::basic_ostream<Ch>&
out,
const xml_node<Ch>& node)
Definition rapidxml.hpp:784
std::size_t name_size() const
Definition rapidxml.hpp:669
std::size_t value_size() const
Definition rapidxml.hpp:687
Ch * name() const
Definition rapidxml.hpp:661
Ch * value() const
Definition rapidxml.hpp:679
Definition rapidxml.hpp:882
node_type type() const
Definition rapidxml.hpp:900
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition rapidxml.hpp:1017
xml_node< Ch > * next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition rapidxml.hpp:995
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition rapidxml.hpp:924
#define out
Definition encodings.cpp:5
Definition rapidxml.hpp:62
OutIt print(OutIt out, const xml_node< Ch > &node, int flags=0)
Definition rapidxml_print.hpp:419
const int print_no_indenting
Printer flag instructing the printer to suppress indenting of XML. See print() function.
Definition rapidxml_print.hpp:23
@ node_comment
A comment node. Name is empty. Value contains comment text.
Definition rapidxml.hpp:147
@ node_document
A document node. Name and value are empty.
Definition rapidxml.hpp:143
@ node_element
An element node. Name contains element name. Value contains text of first data node.
Definition rapidxml.hpp:144
@ node_data
A data node. Name is empty. Value contains data text.
Definition rapidxml.hpp:145
@ node_cdata
A CDATA node. Name is empty. Value contains data text.
Definition rapidxml.hpp:146
@ node_doctype
A DOCTYPE node. Name is empty. Value contains DOCTYPE text.
Definition rapidxml.hpp:150
@ node_pi
A PI node. Name contains target. Value contains instructions.
Definition rapidxml.hpp:151
@ node_declaration
Definition rapidxml.hpp:148
std::basic_ostream< Ch > & operator<<(std::basic_ostream< Ch > &out, const xml_node< Ch > &node)
Definition rapidxml_print.hpp:440
This file contains rapidxml parser and DOM implementation.
i
Definition tag_strings.h:60