| 6168 | } |
| 6169 | |
| 6170 | PUGI__FN void xml_document::save(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding) const |
| 6171 | { |
| 6172 | impl::xml_buffered_writer buffered_writer(writer, encoding); |
| 6173 | |
| 6174 | if ((flags & format_write_bom) && encoding != encoding_latin1) |
| 6175 | { |
| 6176 | // BOM always represents the codepoint U+FEFF, so just write it in native encoding |
| 6177 | #ifdef PUGIXML_WCHAR_MODE |
| 6178 | unsigned int bom = 0xfeff; |
| 6179 | buffered_writer.write(static_cast<wchar_t>(bom)); |
| 6180 | #else |
| 6181 | buffered_writer.write('\xef', '\xbb', '\xbf'); |
| 6182 | #endif |
| 6183 | } |
| 6184 | |
| 6185 | if (!(flags & format_no_declaration) && !impl::has_declaration(_root)) |
| 6186 | { |
| 6187 | buffered_writer.write_string(PUGIXML_TEXT("<?xml version=\"1.0\"")); |
| 6188 | if (encoding == encoding_latin1) buffered_writer.write_string(PUGIXML_TEXT(" encoding=\"ISO-8859-1\"")); |
| 6189 | buffered_writer.write('?', '>'); |
| 6190 | if (!(flags & format_raw)) buffered_writer.write('\n'); |
| 6191 | } |
| 6192 | |
| 6193 | impl::node_output(buffered_writer, _root, indent, flags, 0); |
| 6194 | } |
| 6195 | |
| 6196 | #ifndef PUGIXML_NO_STL |
| 6197 | PUGI__FN void xml_document::save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding) const |
no test coverage detected