From 898b2cbabbe45847fb24f7c6185c62b89062122d Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Fri, 23 Mar 2012 04:21:45 +0000 Subject: Extracted file saving into a separate function, fixed DMC compilation (set_value_buffer cast error) git-svn-id: http://pugixml.googlecode.com/svn/trunk@880 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 13034f4..e814970 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3376,7 +3376,7 @@ PUGI__NS_BEGIN } // set value with conversion functions - PUGI__FN bool set_value_buffer(char_t*& dest, uintptr_t& header, uintptr_t header_mask, const char (&buf)[128]) + PUGI__FN bool set_value_buffer(char_t*& dest, uintptr_t& header, uintptr_t header_mask, char (&buf)[128]) { #ifdef PUGIXML_WCHAR_MODE char_t wbuf[128]; @@ -3668,6 +3668,18 @@ PUGI__NS_BEGIN return result; } #endif + + PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding) + { + if (!file) return false; + + xml_writer_file writer(file); + doc.save(writer, indent, flags, encoding); + + fclose(file); + + return true; + } PUGI__NS_END namespace pugi @@ -5243,27 +5255,13 @@ namespace pugi PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const { FILE* file = fopen(path_, "wb"); - if (!file) return false; - - xml_writer_file writer(file); - save(writer, indent, flags, encoding); - - fclose(file); - - return true; + return save_file_impl(*this, file, indent, flags, encoding); } PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const { FILE* file = impl::open_file_wide(path_, L"wb"); - if (!file) return false; - - xml_writer_file writer(file); - save(writer, indent, flags, encoding); - - fclose(file); - - return true; + return save_file_impl(*this, file, indent, flags, encoding); } PUGI__FN xml_node xml_document::document_element() const -- cgit v1.2.3