mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-27 13:33:17 +08:00
Renamed encoding_t to xml_encoding, renamed xpath_type_t to xpath_value_type
git-svn-id: http://pugixml.googlecode.com/svn/trunk@544 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
1b337b51e0
commit
aeaa1da161
@ -1024,7 +1024,7 @@ namespace
|
||||
return *reinterpret_cast<unsigned char*>(&ui) == 1;
|
||||
}
|
||||
|
||||
encoding_t get_wchar_encoding()
|
||||
xml_encoding get_wchar_encoding()
|
||||
{
|
||||
STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4);
|
||||
|
||||
@ -1034,7 +1034,7 @@ namespace
|
||||
return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
}
|
||||
|
||||
encoding_t get_buffer_encoding(encoding_t encoding, const void* contents, size_t size)
|
||||
xml_encoding get_buffer_encoding(xml_encoding encoding, const void* contents, size_t size)
|
||||
{
|
||||
// replace wchar encoding with utf implementation
|
||||
if (encoding == encoding_wchar) return get_wchar_encoding();
|
||||
@ -1095,7 +1095,7 @@ namespace
|
||||
}
|
||||
|
||||
#ifdef PUGIXML_WCHAR_MODE
|
||||
inline bool need_endian_swap_utf(encoding_t le, encoding_t re)
|
||||
inline bool need_endian_swap_utf(xml_encoding le, xml_encoding re)
|
||||
{
|
||||
return (le == encoding_utf16_be && re == encoding_utf16_le) || (le == encoding_utf16_le && re == encoding_utf16_be) ||
|
||||
(le == encoding_utf32_be && re == encoding_utf32_le) || (le == encoding_utf32_le && re == encoding_utf32_be);
|
||||
@ -1187,10 +1187,10 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convert_buffer(char_t*& out_buffer, size_t& out_length, encoding_t encoding, const void* contents, size_t size, bool is_mutable)
|
||||
bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable)
|
||||
{
|
||||
// get native encoding
|
||||
encoding_t wchar_encoding = get_wchar_encoding();
|
||||
xml_encoding wchar_encoding = get_wchar_encoding();
|
||||
|
||||
// fast path: no conversion required
|
||||
if (encoding == wchar_encoding) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable);
|
||||
@ -1204,7 +1204,7 @@ namespace
|
||||
// source encoding is utf16
|
||||
if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
|
||||
{
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
|
||||
return (native_encoding == encoding) ?
|
||||
convert_buffer_utf16(out_buffer, out_length, contents, size, opt_false()) :
|
||||
@ -1214,7 +1214,7 @@ namespace
|
||||
// source encoding is utf32
|
||||
if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
|
||||
{
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
|
||||
return (native_encoding == encoding) ?
|
||||
convert_buffer_utf32(out_buffer, out_length, contents, size, opt_false()) :
|
||||
@ -1271,7 +1271,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convert_buffer(char_t*& out_buffer, size_t& out_length, encoding_t encoding, const void* contents, size_t size, bool is_mutable)
|
||||
bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable)
|
||||
{
|
||||
// fast path: no conversion required
|
||||
if (encoding == encoding_utf8) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable);
|
||||
@ -1279,7 +1279,7 @@ namespace
|
||||
// source encoding is utf16
|
||||
if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
|
||||
{
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
|
||||
return (native_encoding == encoding) ?
|
||||
convert_buffer_utf16(out_buffer, out_length, contents, size, opt_false()) :
|
||||
@ -1289,7 +1289,7 @@ namespace
|
||||
// source encoding is utf32
|
||||
if (encoding == encoding_utf32_be || encoding == encoding_utf32_le)
|
||||
{
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
|
||||
return (native_encoding == encoding) ?
|
||||
convert_buffer_utf32(out_buffer, out_length, contents, size, opt_false()) :
|
||||
@ -2378,7 +2378,7 @@ namespace
|
||||
};
|
||||
|
||||
// Output facilities
|
||||
encoding_t get_write_native_encoding()
|
||||
xml_encoding get_write_native_encoding()
|
||||
{
|
||||
#ifdef PUGIXML_WCHAR_MODE
|
||||
return get_wchar_encoding();
|
||||
@ -2387,7 +2387,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
encoding_t get_write_encoding(encoding_t encoding)
|
||||
xml_encoding get_write_encoding(xml_encoding encoding)
|
||||
{
|
||||
// replace wchar encoding with utf implementation
|
||||
if (encoding == encoding_wchar) return get_wchar_encoding();
|
||||
@ -2414,7 +2414,7 @@ namespace
|
||||
return (sizeof(wchar_t) == 2 && (unsigned)(static_cast<uint16_t>(data[length - 1]) - 0xD800) < 0x400) ? length - 1 : length;
|
||||
}
|
||||
|
||||
size_t convert_buffer(char* result, const char_t* data, size_t length, encoding_t encoding)
|
||||
size_t convert_buffer(char* result, const char_t* data, size_t length, xml_encoding encoding)
|
||||
{
|
||||
// only endian-swapping is required
|
||||
if (need_endian_swap_utf(encoding, get_wchar_encoding()))
|
||||
@ -2445,7 +2445,7 @@ namespace
|
||||
uint16_t* end = utf_decoder<utf16_writer>::decode_utf32_block(reinterpret_cast<const uint32_t*>(data), length, dest);
|
||||
|
||||
// swap if necessary
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
|
||||
if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast<size_t>(end - dest));
|
||||
|
||||
@ -2461,7 +2461,7 @@ namespace
|
||||
uint32_t* end = utf_decoder<utf32_writer>::decode_utf16_block(reinterpret_cast<const uint16_t*>(data), length, dest);
|
||||
|
||||
// swap if necessary
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
|
||||
if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast<size_t>(end - dest));
|
||||
|
||||
@ -2490,7 +2490,7 @@ namespace
|
||||
return length;
|
||||
}
|
||||
|
||||
size_t convert_buffer(char* result, const char_t* data, size_t length, encoding_t encoding)
|
||||
size_t convert_buffer(char* result, const char_t* data, size_t length, xml_encoding encoding)
|
||||
{
|
||||
if (encoding == encoding_utf16_be || encoding == encoding_utf16_le)
|
||||
{
|
||||
@ -2500,7 +2500,7 @@ namespace
|
||||
uint16_t* end = utf_decoder<utf16_writer>::decode_utf8_block(reinterpret_cast<const uint8_t*>(data), length, dest);
|
||||
|
||||
// swap if necessary
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
|
||||
|
||||
if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast<size_t>(end - dest));
|
||||
|
||||
@ -2515,7 +2515,7 @@ namespace
|
||||
uint32_t* end = utf_decoder<utf32_writer>::decode_utf8_block(reinterpret_cast<const uint8_t*>(data), length, dest);
|
||||
|
||||
// swap if necessary
|
||||
encoding_t native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
|
||||
|
||||
if (native_encoding != encoding) convert_utf_endian_swap(dest, dest, static_cast<size_t>(end - dest));
|
||||
|
||||
@ -2535,7 +2535,7 @@ namespace
|
||||
xml_buffered_writer& operator=(const xml_buffered_writer&);
|
||||
|
||||
public:
|
||||
xml_buffered_writer(xml_writer& writer, encoding_t user_encoding): writer(writer), bufsize(0), encoding(get_write_encoding(user_encoding))
|
||||
xml_buffered_writer(xml_writer& writer, xml_encoding user_encoding): writer(writer), bufsize(0), encoding(get_write_encoding(user_encoding))
|
||||
{
|
||||
}
|
||||
|
||||
@ -2687,10 +2687,10 @@ namespace
|
||||
|
||||
xml_writer& writer;
|
||||
size_t bufsize;
|
||||
encoding_t encoding;
|
||||
xml_encoding encoding;
|
||||
};
|
||||
|
||||
void write_bom(xml_writer& writer, encoding_t encoding)
|
||||
void write_bom(xml_writer& writer, xml_encoding encoding)
|
||||
{
|
||||
switch (encoding)
|
||||
{
|
||||
@ -2967,7 +2967,7 @@ namespace
|
||||
}
|
||||
|
||||
#ifndef PUGIXML_NO_STL
|
||||
template <typename T> xml_parse_result load_stream_impl(xml_document& doc, std::basic_istream<T, std::char_traits<T> >& stream, unsigned int options, encoding_t encoding)
|
||||
template <typename T> xml_parse_result load_stream_impl(xml_document& doc, std::basic_istream<T, std::char_traits<T> >& stream, unsigned int options, xml_encoding encoding)
|
||||
{
|
||||
if (!stream.good()) return make_parse_result(status_io_error);
|
||||
|
||||
@ -3991,7 +3991,7 @@ namespace pugi
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, encoding_t encoding, unsigned int depth) const
|
||||
void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const
|
||||
{
|
||||
if (!_root) return;
|
||||
|
||||
@ -4001,7 +4001,7 @@ namespace pugi
|
||||
}
|
||||
|
||||
#ifndef PUGIXML_NO_STL
|
||||
void xml_node::print(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent, unsigned int flags, encoding_t encoding, unsigned int depth) const
|
||||
void xml_node::print(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const
|
||||
{
|
||||
if (!_root) return;
|
||||
|
||||
@ -4289,7 +4289,7 @@ namespace pugi
|
||||
}
|
||||
|
||||
#ifndef PUGIXML_NO_STL
|
||||
xml_parse_result xml_document::load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options, encoding_t encoding)
|
||||
xml_parse_result xml_document::load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options, xml_encoding encoding)
|
||||
{
|
||||
create();
|
||||
|
||||
@ -4310,9 +4310,9 @@ namespace pugi
|
||||
|
||||
// Force native encoding (skip autodetection)
|
||||
#ifdef PUGIXML_WCHAR_MODE
|
||||
encoding_t encoding = encoding_wchar;
|
||||
xml_encoding encoding = encoding_wchar;
|
||||
#else
|
||||
encoding_t encoding = encoding_utf8;
|
||||
xml_encoding encoding = encoding_utf8;
|
||||
#endif
|
||||
|
||||
return load_buffer(contents, impl::strlen(contents) * sizeof(char_t), options, encoding);
|
||||
@ -4328,7 +4328,7 @@ namespace pugi
|
||||
return load_buffer_inplace_own(xmlstr, strlen(xmlstr), options, encoding_utf8);
|
||||
}
|
||||
|
||||
xml_parse_result xml_document::load_file(const char* path, unsigned int options, encoding_t encoding)
|
||||
xml_parse_result xml_document::load_file(const char* path, unsigned int options, xml_encoding encoding)
|
||||
{
|
||||
create();
|
||||
|
||||
@ -4365,12 +4365,12 @@ namespace pugi
|
||||
return load_buffer_inplace_own(s, length, options, encoding);
|
||||
}
|
||||
|
||||
xml_parse_result xml_document::load_buffer_impl(void* contents, size_t size, unsigned int options, encoding_t encoding, bool is_mutable, bool own)
|
||||
xml_parse_result xml_document::load_buffer_impl(void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own)
|
||||
{
|
||||
create();
|
||||
|
||||
// get actual encoding
|
||||
encoding_t buffer_encoding = get_buffer_encoding(encoding, contents, size);
|
||||
xml_encoding buffer_encoding = get_buffer_encoding(encoding, contents, size);
|
||||
|
||||
// get private buffer
|
||||
char_t* buffer = 0;
|
||||
@ -4393,22 +4393,22 @@ namespace pugi
|
||||
return res;
|
||||
}
|
||||
|
||||
xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options, encoding_t encoding)
|
||||
xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding)
|
||||
{
|
||||
return load_buffer_impl(const_cast<void*>(contents), size, options, encoding, false, false);
|
||||
}
|
||||
|
||||
xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options, encoding_t encoding)
|
||||
xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options, xml_encoding encoding)
|
||||
{
|
||||
return load_buffer_impl(contents, size, options, encoding, true, false);
|
||||
}
|
||||
|
||||
xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options, encoding_t encoding)
|
||||
xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options, xml_encoding encoding)
|
||||
{
|
||||
return load_buffer_impl(contents, size, options, encoding, true, true);
|
||||
}
|
||||
|
||||
void xml_document::save(xml_writer& writer, const char_t* indent, unsigned int flags, encoding_t encoding) const
|
||||
void xml_document::save(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding) const
|
||||
{
|
||||
if (flags & format_write_bom) write_bom(writer, get_write_encoding(encoding));
|
||||
|
||||
@ -4424,7 +4424,7 @@ namespace pugi
|
||||
}
|
||||
|
||||
#ifndef PUGIXML_NO_STL
|
||||
void xml_document::save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent, unsigned int flags, encoding_t encoding) const
|
||||
void xml_document::save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding) const
|
||||
{
|
||||
xml_writer_stream writer(stream);
|
||||
|
||||
@ -4439,7 +4439,7 @@ namespace pugi
|
||||
}
|
||||
#endif
|
||||
|
||||
bool xml_document::save_file(const char* path, const char_t* indent, unsigned int flags, encoding_t encoding) const
|
||||
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;
|
||||
|
@ -271,7 +271,7 @@ namespace pugi
|
||||
* which means that document encoding is auto-detected from BOM and necessary encoding conversions are
|
||||
* applied. You can override this mode by using any of the specific encodings.
|
||||
*/
|
||||
enum encoding_t
|
||||
enum xml_encoding
|
||||
{
|
||||
encoding_auto, //!< Auto-detect input encoding using BOM or < / <? detection; use UTF8 if BOM is not found
|
||||
encoding_utf8, //!< UTF8 encoding
|
||||
@ -348,7 +348,7 @@ namespace pugi
|
||||
class xpath_allocator;
|
||||
|
||||
/// XPath query return type classification
|
||||
enum xpath_type_t
|
||||
enum xpath_value_type
|
||||
{
|
||||
xpath_type_none, ///< Unknown type (query failed to compile)
|
||||
xpath_type_node_set, ///< Node set (xpath_node_set)
|
||||
@ -391,7 +391,7 @@ namespace pugi
|
||||
*
|
||||
* \return expression return type
|
||||
**/
|
||||
xpath_type_t return_type() const;
|
||||
xpath_value_type return_type() const;
|
||||
|
||||
/**
|
||||
* Evaluate expression as boolean value for the context node \a n.
|
||||
@ -1467,7 +1467,7 @@ namespace pugi
|
||||
* \param encoding - encoding used for writing
|
||||
* \param depth - starting depth (used for indentation)
|
||||
*/
|
||||
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto, unsigned int depth = 0) const;
|
||||
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
|
||||
|
||||
#ifndef PUGIXML_NO_STL
|
||||
/**
|
||||
@ -1479,7 +1479,7 @@ namespace pugi
|
||||
* \param encoding - encoding used for writing
|
||||
* \param depth - starting depth (used for indentation)
|
||||
*/
|
||||
void print(std::basic_ostream<char, std::char_traits<char> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto, unsigned int depth = 0) const;
|
||||
void print(std::basic_ostream<char, std::char_traits<char> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
|
||||
|
||||
/**
|
||||
* Print subtree to stream
|
||||
@ -1810,7 +1810,7 @@ namespace pugi
|
||||
ptrdiff_t offset;
|
||||
|
||||
/// Source document encoding
|
||||
encoding_t encoding;
|
||||
xml_encoding encoding;
|
||||
|
||||
/// Cast to bool operator
|
||||
operator bool() const
|
||||
@ -1839,7 +1839,7 @@ namespace pugi
|
||||
void create();
|
||||
void destroy();
|
||||
|
||||
xml_parse_result load_buffer_impl(void* contents, size_t size, unsigned int options, encoding_t encoding, bool is_mutable, bool own);
|
||||
xml_parse_result load_buffer_impl(void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own);
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -1862,7 +1862,7 @@ namespace pugi
|
||||
* \param encoding - source data encoding
|
||||
* \return parsing result
|
||||
*/
|
||||
xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
|
||||
xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||
|
||||
/**
|
||||
* Load document from stream.
|
||||
@ -1919,7 +1919,7 @@ namespace pugi
|
||||
* \param encoding - source data encoding
|
||||
* \return parsing result
|
||||
*/
|
||||
xml_parse_result load_file(const char* path, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
|
||||
xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||
|
||||
/**
|
||||
* Load document from buffer
|
||||
@ -1930,7 +1930,7 @@ namespace pugi
|
||||
* \param encoding - source data encoding
|
||||
* \return parsing result
|
||||
*/
|
||||
xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
|
||||
xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||
|
||||
/**
|
||||
* Load document from buffer in-situ.
|
||||
@ -1943,7 +1943,7 @@ namespace pugi
|
||||
* \param encoding - source data encoding
|
||||
* \return parsing result
|
||||
*/
|
||||
xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
|
||||
xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||
|
||||
/**
|
||||
* Load document from buffer in-situ (gains buffer ownership).
|
||||
@ -1957,7 +1957,7 @@ namespace pugi
|
||||
* \param encoding - source data encoding
|
||||
* \return parsing result
|
||||
*/
|
||||
xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, encoding_t encoding = encoding_auto);
|
||||
xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
|
||||
|
||||
/**
|
||||
* Save XML to writer
|
||||
@ -1967,7 +1967,7 @@ namespace pugi
|
||||
* \param flags - formatting flags
|
||||
* \param encoding - encoding used for writing
|
||||
*/
|
||||
void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto) const;
|
||||
void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
||||
|
||||
#ifndef PUGIXML_NO_STL
|
||||
/**
|
||||
@ -1978,7 +1978,7 @@ namespace pugi
|
||||
* \param flags - formatting flags
|
||||
* \param encoding - encoding used for writing
|
||||
*/
|
||||
void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto) const;
|
||||
void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
||||
|
||||
/**
|
||||
* Save XML to stream
|
||||
@ -1999,7 +1999,7 @@ namespace pugi
|
||||
* \param encoding - encoding used for writing
|
||||
* \return success flag
|
||||
*/
|
||||
bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, encoding_t encoding = encoding_auto) const;
|
||||
bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
|
||||
|
||||
/**
|
||||
* Compute document order for the whole tree
|
||||
|
@ -1315,7 +1315,7 @@ namespace pugi
|
||||
private:
|
||||
ast_type_t m_type;
|
||||
|
||||
xpath_type_t m_rettype;
|
||||
xpath_value_type m_rettype;
|
||||
|
||||
// tree node structure
|
||||
xpath_ast_node* m_left;
|
||||
@ -1336,7 +1336,7 @@ namespace pugi
|
||||
|
||||
template <class Comp> static bool compare_eq(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const Comp& comp)
|
||||
{
|
||||
xpath_type_t lt = lhs->rettype(), rt = rhs->rettype();
|
||||
xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
|
||||
|
||||
if (lt != xpath_type_node_set && rt != xpath_type_node_set)
|
||||
{
|
||||
@ -1405,7 +1405,7 @@ namespace pugi
|
||||
|
||||
template <class Comp> static bool compare_rel(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const Comp& comp)
|
||||
{
|
||||
xpath_type_t lt = lhs->rettype(), rt = rhs->rettype();
|
||||
xpath_value_type lt = lhs->rettype(), rt = rhs->rettype();
|
||||
|
||||
if (lt != xpath_type_node_set && rt != xpath_type_node_set)
|
||||
return comp(lhs->eval_number(c), rhs->eval_number(c));
|
||||
@ -1955,7 +1955,7 @@ namespace pugi
|
||||
else m_contents = 0;
|
||||
}
|
||||
public:
|
||||
xpath_ast_node(ast_type_t type, xpath_type_t rettype, const xpath_lexer_string& contents, xpath_allocator& a):
|
||||
xpath_ast_node(ast_type_t type, xpath_value_type rettype, const xpath_lexer_string& contents, xpath_allocator& a):
|
||||
m_type(type), m_rettype(rettype), m_left(0), m_right(0), m_third(0), m_next(0), m_contents(0),
|
||||
m_axis(axis_self), m_test(nodetest_none)
|
||||
{
|
||||
@ -1968,7 +1968,7 @@ namespace pugi
|
||||
{
|
||||
}
|
||||
|
||||
xpath_ast_node(ast_type_t type, xpath_type_t rettype, xpath_ast_node* left = 0, xpath_ast_node* right = 0, xpath_ast_node* third = 0):
|
||||
xpath_ast_node(ast_type_t type, xpath_value_type rettype, xpath_ast_node* left = 0, xpath_ast_node* right = 0, xpath_ast_node* third = 0):
|
||||
m_type(type), m_rettype(rettype), m_left(left), m_right(right), m_third(third), m_next(0), m_contents(0),
|
||||
m_axis(axis_self), m_test(nodetest_none)
|
||||
{
|
||||
@ -2608,7 +2608,7 @@ namespace pugi
|
||||
}
|
||||
}
|
||||
|
||||
xpath_type_t rettype() const
|
||||
xpath_value_type rettype() const
|
||||
{
|
||||
return m_rettype;
|
||||
}
|
||||
@ -3429,7 +3429,7 @@ namespace pugi
|
||||
m_root = p.parse();
|
||||
}
|
||||
|
||||
xpath_type_t xpath_query::return_type() const
|
||||
xpath_value_type xpath_query::return_type() const
|
||||
{
|
||||
if (!m_root) return xpath_type_none;
|
||||
|
||||
|
@ -171,7 +171,7 @@ bool is_little_endian()
|
||||
return *reinterpret_cast<char*>(&ui) == 1;
|
||||
}
|
||||
|
||||
pugi::encoding_t get_native_encoding()
|
||||
pugi::xml_encoding get_native_encoding()
|
||||
{
|
||||
#ifdef PUGIXML_WCHAR_MODE
|
||||
return pugi::encoding_wchar;
|
||||
|
@ -146,6 +146,6 @@ inline wchar_t wchar_cast(unsigned int value)
|
||||
}
|
||||
|
||||
bool is_little_endian();
|
||||
pugi::encoding_t get_native_encoding();
|
||||
pugi::xml_encoding get_native_encoding();
|
||||
|
||||
#endif
|
||||
|
@ -394,7 +394,7 @@ TEST(document_load_file_convert_auto)
|
||||
"tests/data/utftest_utf8_nodecl.xml"
|
||||
};
|
||||
|
||||
encoding_t encodings[] =
|
||||
xml_encoding encodings[] =
|
||||
{
|
||||
encoding_utf16_be, encoding_utf16_be, encoding_utf16_be,
|
||||
encoding_utf16_le, encoding_utf16_le, encoding_utf16_le,
|
||||
@ -435,7 +435,7 @@ TEST(document_load_file_convert_specific)
|
||||
"tests/data/utftest_utf8_nodecl.xml"
|
||||
};
|
||||
|
||||
encoding_t encodings[] =
|
||||
xml_encoding encodings[] =
|
||||
{
|
||||
encoding_utf16_be, encoding_utf16_be, encoding_utf16_be,
|
||||
encoding_utf16_le, encoding_utf16_le, encoding_utf16_le,
|
||||
@ -448,7 +448,7 @@ TEST(document_load_file_convert_specific)
|
||||
{
|
||||
for (unsigned int j = 0; j < sizeof(files) / sizeof(files[0]); ++j)
|
||||
{
|
||||
encoding_t encoding = encodings[j];
|
||||
xml_encoding encoding = encodings[j];
|
||||
|
||||
xml_document doc;
|
||||
xml_parse_result res = doc.load_file(files[i], parse_default, encoding);
|
||||
@ -490,7 +490,7 @@ TEST(document_load_file_convert_native_endianness)
|
||||
}
|
||||
};
|
||||
|
||||
encoding_t encodings[] =
|
||||
xml_encoding encodings[] =
|
||||
{
|
||||
encoding_utf16, encoding_utf16, encoding_utf16,
|
||||
encoding_utf32, encoding_utf32, encoding_utf32
|
||||
@ -503,7 +503,7 @@ TEST(document_load_file_convert_native_endianness)
|
||||
|
||||
for (unsigned int j = 0; j < sizeof(encodings) / sizeof(encodings[0]); ++j)
|
||||
{
|
||||
encoding_t encoding = encodings[j];
|
||||
xml_encoding encoding = encodings[j];
|
||||
|
||||
// check file with right endianness
|
||||
{
|
||||
@ -554,7 +554,7 @@ TEST(document_contents_preserve)
|
||||
struct file_t
|
||||
{
|
||||
const char* path;
|
||||
encoding_t encoding;
|
||||
xml_encoding encoding;
|
||||
|
||||
char* data;
|
||||
size_t size;
|
||||
@ -596,7 +596,7 @@ TEST(document_contents_preserve)
|
||||
}
|
||||
}
|
||||
|
||||
static bool test_parse_fail(const void* buffer, size_t size, encoding_t encoding = encoding_utf8)
|
||||
static bool test_parse_fail(const void* buffer, size_t size, xml_encoding encoding = encoding_utf8)
|
||||
{
|
||||
// copy buffer to heap (to enable out-of-bounds checks)
|
||||
void* temp = malloc(size);
|
||||
@ -646,7 +646,7 @@ TEST(document_convert_invalid_utf16)
|
||||
|
||||
TEST(document_load_buffer_empty)
|
||||
{
|
||||
encoding_t encodings[] =
|
||||
xml_encoding encodings[] =
|
||||
{
|
||||
encoding_auto,
|
||||
encoding_utf8,
|
||||
@ -663,7 +663,7 @@ TEST(document_load_buffer_empty)
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(encodings) / sizeof(encodings[0]); ++i)
|
||||
{
|
||||
encoding_t encoding = encodings[i];
|
||||
xml_encoding encoding = encodings[i];
|
||||
|
||||
xml_document doc;
|
||||
CHECK(doc.load_buffer(buffer, 0, parse_default, encoding) && !doc.first_child());
|
||||
|
@ -39,7 +39,7 @@ std::basic_string<pugi::char_t> xml_writer_string::as_string() const
|
||||
return std::basic_string<pugi::char_t>(reinterpret_cast<const pugi::char_t*>(contents.data()), contents.size() / sizeof(pugi::char_t));
|
||||
}
|
||||
|
||||
std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::encoding_t encoding)
|
||||
std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding)
|
||||
{
|
||||
xml_writer_string writer;
|
||||
|
||||
@ -48,12 +48,12 @@ std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi:
|
||||
return writer.as_narrow();
|
||||
}
|
||||
|
||||
bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::encoding_t encoding, const char* expected, size_t length)
|
||||
bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length)
|
||||
{
|
||||
return test_narrow(save_narrow(doc, flags, encoding), expected, length);
|
||||
}
|
||||
|
||||
std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::encoding_t encoding)
|
||||
std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding)
|
||||
{
|
||||
xml_writer_string writer;
|
||||
|
||||
@ -62,12 +62,12 @@ std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::encoding
|
||||
return writer.as_narrow();
|
||||
}
|
||||
|
||||
bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::encoding_t encoding, const char* expected, size_t length)
|
||||
bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length)
|
||||
{
|
||||
return test_narrow(write_narrow(node, flags, encoding), expected, length);
|
||||
}
|
||||
|
||||
std::wstring write_wide(pugi::xml_node node, unsigned int flags, pugi::encoding_t encoding)
|
||||
std::wstring write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding)
|
||||
{
|
||||
xml_writer_string writer;
|
||||
|
||||
|
@ -16,12 +16,12 @@ struct xml_writer_string: public pugi::xml_writer
|
||||
std::basic_string<pugi::char_t> as_string() const;
|
||||
};
|
||||
|
||||
std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::encoding_t encoding);
|
||||
bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::encoding_t encoding, const char* expected, size_t length);
|
||||
std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding);
|
||||
bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length);
|
||||
|
||||
std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::encoding_t encoding);
|
||||
bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::encoding_t encoding, const char* expected, size_t length);
|
||||
std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding);
|
||||
bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length);
|
||||
|
||||
std::wstring write_wide(pugi::xml_node node, unsigned int flags, pugi::encoding_t encoding);
|
||||
std::wstring write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user