From 021574a48430b6cc5589a76e7d02b1fc6a25849d Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sat, 8 May 2010 16:44:04 +0000 Subject: Added 0.5-compatible interfaces for compatibility git-svn-id: http://pugixml.googlecode.com/svn/trunk@386 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 15 +++++++++++++++ src/pugixml.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index b3f2c2c..615d7d4 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4009,6 +4009,16 @@ namespace pugi return load_buffer(contents, impl::strlen(contents) * sizeof(char_t), options, encoding); } + xml_parse_result xml_document::parse(char* xmlstr, unsigned int options) + { + return load_buffer_inplace(xmlstr, strlen(xmlstr), options, encoding_utf8); + } + + xml_parse_result xml_document::parse(const transfer_ownership_tag&, char* xmlstr, unsigned int options) + { + return load_buffer_inplace_own(xmlstr, strlen(xmlstr), options, encoding_utf8); + } + xml_parse_result xml_document::load_file(const char* name, unsigned int options, encoding_t encoding) { destroy(); @@ -4205,6 +4215,11 @@ namespace pugi return result; } + std::wstring PUGIXML_FUNCTION as_utf16(const char* str) + { + return as_wide(str); + } + std::wstring PUGIXML_FUNCTION as_wide(const char* str) { const impl::char8_t* data = reinterpret_cast(str); diff --git a/src/pugixml.hpp b/src/pugixml.hpp index ccc9f6f..86798e3 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -17,8 +17,6 @@ #include "pugiconfig.hpp" #ifndef PUGIXML_NO_STL -#include - namespace std { struct bidirectional_iterator_tag; @@ -38,6 +36,11 @@ namespace std } #endif +// Macro for deprecated features +#ifndef PUGIXML_DEPRECATED +# define PUGIXML_DEPRECATED(message) +#endif + // No XPath without STL #ifdef PUGIXML_NO_STL # ifndef PUGIXML_NO_XPATH @@ -45,6 +48,11 @@ namespace std # endif #endif +// Include exception header for XPath +#ifndef PUGIXML_NO_XPATH +# include +#endif + // If no API is defined, assume default #ifndef PUGIXML_API # define PUGIXML_API @@ -276,6 +284,8 @@ namespace pugi * This flag is off by default. */ const unsigned int format_write_bom = 0x02; + + PUGIXML_DEPRECATED("Use format_write_bom instead") const unsigned int format_write_bom_utf8 = format_write_bom; /** * If this flag is on, no indentation is performed and no line breaks are written to output file. @@ -1430,7 +1440,6 @@ namespace pugi * \param indent - indentation string * \param flags - formatting flags * \param depth - starting depth (used for indentation) - * \deprecated Use print() with xml_writer_stream instead */ void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto, unsigned int depth = 0) const; @@ -1441,7 +1450,6 @@ namespace pugi * \param indent - indentation string * \param flags - formatting flags * \param depth - starting depth (used for indentation) - * \deprecated Use print() with xml_writer_stream instead */ void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; #endif @@ -1741,6 +1749,12 @@ namespace pugi char data[memory_block_size]; }; + /** + * Struct used to distinguish parsing with ownership transfer from parsing without it. + * \see xml_document::parse + */ + PUGIXML_DEPRECATED("Use xml_document::load_buffer_inplace_own instead") struct transfer_ownership_tag {}; + /** * Parsing status enumeration, returned as part of xml_parse_result struct */ @@ -1851,6 +1865,30 @@ namespace pugi */ xml_parse_result load(const char_t* contents, unsigned int options = parse_default); + /** + * Parse the given XML string in-situ. + * The string is modified; you should ensure that string data will persist throughout the + * document's lifetime. Although, document does not gain ownership over the string, so you + * should free the memory occupied by it manually. + * + * \param xmlstr - readwrite string with xml data + * \param options - parsing options + * \return parsing result + */ + PUGIXML_DEPRECATED("Use xml_document::load_buffer_inplace instead") xml_parse_result parse(char* xmlstr, unsigned int options = parse_default); + + /** + * Parse the given XML string in-situ (gains ownership). + * The string is modified; document gains ownership over the string, so you don't have to worry + * about it's lifetime. + * Call example: doc.parse(transfer_ownership_tag(), string, options); + * + * \param xmlstr - readwrite string with xml data + * \param options - parsing options + * \return parsing result + */ + PUGIXML_DEPRECATED("Use xml_document::load_buffer_inplace_own instead") xml_parse_result parse(const transfer_ownership_tag&, char* xmlstr, unsigned int options = parse_default); + /** * Load document from file * @@ -2191,6 +2229,14 @@ namespace pugi */ std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const wchar_t* str); + /** + * Convert utf8 to wide string + * + * \param str - input UTF8 string + * \return output wide string string + */ + PUGIXML_DEPRECATED("Use as_wide instead") std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf16(const char* str); + /** * Convert utf8 to wide string * -- cgit v1.2.3