| 5876 | } |
| 5877 | |
| 5878 | PUGI__FN void xml_document::save( |
| 5879 | xml_writer& writer, |
| 5880 | const char_t* indent, |
| 5881 | unsigned int flags, |
| 5882 | xml_encoding encoding) const |
| 5883 | { |
| 5884 | impl::xml_buffered_writer buffered_writer(writer, encoding); |
| 5885 | |
| 5886 | if ((flags & format_write_bom) && encoding != encoding_latin1) |
| 5887 | { |
| 5888 | // BOM always represents the codepoint U+FEFF, so just write it in native encoding |
| 5889 | #ifdef PUGIXML_WCHAR_MODE |
| 5890 | unsigned int bom = 0xfeff; |
| 5891 | buffered_writer.write(static_cast<wchar_t>(bom)); |
| 5892 | #else |
| 5893 | buffered_writer.write('\xef', '\xbb', '\xbf'); |
| 5894 | #endif |
| 5895 | } |
| 5896 | |
| 5897 | if (!(flags & format_no_declaration) && !impl::has_declaration(*this)) |
| 5898 | { |
| 5899 | buffered_writer.write(PUGIXML_TEXT("<?xml version=\"1.0\"")); |
| 5900 | if (encoding == encoding_latin1) |
| 5901 | buffered_writer.write(PUGIXML_TEXT(" encoding=\"ISO-8859-1\"")); |
| 5902 | buffered_writer.write('?', '>'); |
| 5903 | if (!(flags & format_raw)) |
| 5904 | { |
| 5905 | buffered_writer.write('\n'); |
| 5906 | } |
| 5907 | } |
| 5908 | |
| 5909 | impl::node_output(buffered_writer, *this, indent, flags, 0); |
| 5910 | } |
| 5911 | |
| 5912 | #ifndef PUGIXML_NO_STL |
| 5913 | PUGI__FN void xml_document::save( |
no test coverage detected