diff --git a/include/boost/property_tree/detail/info_parser_read.hpp b/include/boost/property_tree/detail/info_parser_read.hpp index 4e7d42406a..b87c2cbc65 100644 --- a/include/boost/property_tree/detail/info_parser_read.hpp +++ b/include/boost/property_tree/detail/info_parser_read.hpp @@ -60,24 +60,13 @@ namespace boost { namespace property_tree { namespace info_parser } return result; } - - // Detect whitespace in a not very smart way. - template - bool is_ascii_space(Ch c) - { - // Everything outside ASCII is not space. - unsigned n = c; - if (n > 127) - return false; - return isspace(c); - } // Advance pointer past whitespace template void skip_whitespace(const Ch *&text) { using namespace std; - while (is_ascii_space(*text)) + while (isspace(*text)) ++text; } @@ -88,7 +77,7 @@ namespace boost { namespace property_tree { namespace info_parser using namespace std; skip_whitespace(text); const Ch *start = text; - while (!is_ascii_space(*text) && *text != Ch(';') && *text != Ch('\0')) + while (!isspace(*text) && *text != Ch(';') && *text != Ch('\0')) ++text; return expand_escapes(start, text); } @@ -102,7 +91,7 @@ namespace boost { namespace property_tree { namespace info_parser const Ch *start = text; while (*text != Ch('\0') && *text != Ch(';')) ++text; - while (text > start && is_ascii_space(*(text - 1))) + while (text > start && isspace(*(text - 1))) --text; return expand_escapes(start, text); } diff --git a/include/boost/property_tree/detail/json_parser_read.hpp b/include/boost/property_tree/detail/json_parser_read.hpp index f8a374c44d..798552f6f1 100644 --- a/include/boost/property_tree/detail/json_parser_read.hpp +++ b/include/boost/property_tree/detail/json_parser_read.hpp @@ -32,9 +32,8 @@ namespace boost { namespace property_tree { namespace json_parser template struct context { - - typedef typename Ptree::key_type::value_type Ch; - typedef std::basic_string Str; + typedef typename Ptree::key_type Str; + typedef typename Str::value_type Ch; typedef typename std::vector::iterator It; Str string; @@ -162,7 +161,8 @@ namespace boost { namespace property_tree { namespace json_parser { typedef context Context; - typedef typename Ptree::key_type::value_type Ch; + typedef typename Ptree::key_type Str; + typedef typename Str::value_type Ch; mutable Context c; @@ -239,8 +239,8 @@ namespace boost { namespace property_tree { namespace json_parser = !ch_p("-") >> (ch_p("0") | (range_p(Ch('1'), Ch('9')) >> *digit_p)) >> !(ch_p(".") >> +digit_p) >> - !(chset_p(detail::widen("eE").c_str()) >> - !chset_p(detail::widen("-+").c_str()) >> + !(chset_p(detail::widen("eE").c_str()) >> + !chset_p(detail::widen("-+").c_str()) >> +digit_p) ; @@ -255,7 +255,7 @@ namespace boost { namespace property_tree { namespace json_parser ; escape - = chset_p(detail::widen("\"\\/bfnrt").c_str()) + = chset_p(detail::widen("\"\\/bfnrt").c_str()) [typename Context::a_escape(self.c)] | 'u' >> uint_parser() [typename Context::a_unicode(self.c)] diff --git a/include/boost/property_tree/detail/ptree_utils.hpp b/include/boost/property_tree/detail/ptree_utils.hpp index 7e56c8f4bb..72aed4614c 100644 --- a/include/boost/property_tree/detail/ptree_utils.hpp +++ b/include/boost/property_tree/detail/ptree_utils.hpp @@ -54,49 +54,48 @@ namespace boost { namespace property_tree { namespace detail // Naively convert narrow string to another character type - template - std::basic_string widen(const char *text) + template + Str widen(const char *text) { - std::basic_string result; + Str result; while (*text) { - result += Ch(*text); + result += typename Str::value_type(*text); ++text; } return result; } // Naively convert string to narrow character type - template - std::string narrow(const Ch *text) + template + Str narrow(const char_type *text) { - std::string result; + Str result; while (*text) { if (*text < 0 || *text > (std::numeric_limits::max)()) result += '*'; else - result += char(*text); + result += typename Str::value_type(*text); ++text; } return result; } // Remove trailing and leading spaces - template - std::basic_string trim(const std::basic_string &s, - const std::locale &loc = std::locale()) + template + Str trim(const Str &s, const std::locale &loc = std::locale()) { - typename std::basic_string::const_iterator first = s.begin(); - typename std::basic_string::const_iterator end = s.end(); + typename Str::const_iterator first = s.begin(); + typename Str::const_iterator end = s.end(); while (first != end && std::isspace(*first, loc)) ++first; if (first == end) - return std::basic_string(); - typename std::basic_string::const_iterator last = end; + return Str(); + typename Str::const_iterator last = end; do --last; while (std::isspace(*last, loc)); if (first != s.begin() || last + 1 != end) - return std::basic_string(first, last + 1); + return Str(first, last + 1); else return s; } diff --git a/include/boost/property_tree/detail/xml_parser_read_rapidxml.hpp b/include/boost/property_tree/detail/xml_parser_read_rapidxml.hpp index fc994b162e..9c04219189 100644 --- a/include/boost/property_tree/detail/xml_parser_read_rapidxml.hpp +++ b/include/boost/property_tree/detail/xml_parser_read_rapidxml.hpp @@ -38,14 +38,13 @@ namespace boost { namespace property_tree { namespace xml_parser if (node->first_attribute()) { Ptree &pt_attr_root = pt_node.push_back( - std::make_pair(xmlattr(), Ptree()))->second; + std::make_pair(xmlattr(), Ptree()))->second; for (xml_attribute *attr = node->first_attribute(); attr; attr = attr->next_attribute()) { Ptree &pt_attr = pt_attr_root.push_back( std::make_pair(attr->name(), Ptree()))->second; - pt_attr.data() = std::basic_string(attr->value(), - attr->value_size()); + pt_attr.data() = typename Ptree::key_type(attr->value(), attr->value_size()); } } @@ -61,11 +60,10 @@ namespace boost { namespace property_tree { namespace xml_parser case node_cdata: { if (flags & no_concat_text) - pt.push_back(std::make_pair(xmltext(), + pt.push_back(std::make_pair(xmltext(), Ptree(node->value()))); else - pt.data() += std::basic_string(node->value(), - node->value_size()); + pt.data() += typename Ptree::key_type(node->value(), node->value_size()); } break; @@ -73,9 +71,8 @@ namespace boost { namespace property_tree { namespace xml_parser case node_comment: { if (!(flags & no_comments)) - pt.push_back(std::make_pair(xmlcomment(), - Ptree(std::basic_string(node->value(), - node->value_size())))); + pt.push_back(std::make_pair(xmlcomment(), + Ptree(typename Ptree::key_type(node->value(), node->value_size())))); } break; diff --git a/include/boost/property_tree/detail/xml_parser_utils.hpp b/include/boost/property_tree/detail/xml_parser_utils.hpp index 02e0936826..b4c502b5eb 100644 --- a/include/boost/property_tree/detail/xml_parser_utils.hpp +++ b/include/boost/property_tree/detail/xml_parser_utils.hpp @@ -20,14 +20,15 @@ namespace boost { namespace property_tree { namespace xml_parser { - template - std::basic_string condense(const std::basic_string &s) + template + Str condense(const Str &s) { - std::basic_string r; + typedef typename Str::value_type Ch; + Str r; std::locale loc; bool space = false; - typename std::basic_string::const_iterator end = s.end(); - for (typename std::basic_string::const_iterator it = s.begin(); + typename Str::const_iterator end = s.end(); + for (typename Str::const_iterator it = s.begin(); it != end; ++it) { if (isspace(*it, loc) || *it == Ch('\n')) @@ -41,20 +42,22 @@ namespace boost { namespace property_tree { namespace xml_parser return r; } - template - std::basic_string encode_char_entities(const std::basic_string &s) + + template + Str encode_char_entities(const Str &s) { // Don't do anything for empty strings. if(s.empty()) return s; - typedef typename std::basic_string Str; + typedef typename Str::value_type Ch; + Str r; // To properly round-trip spaces and not uglify the XML beyond // recognition, we have to encode them IF the text contains only spaces. Str sp(1, Ch(' ')); if(s.find_first_not_of(sp) == Str::npos) { // The first will suffice. - r = detail::widen(" "); + r = detail::widen(" "); r += Str(s.size() - 1, Ch(' ')); } else { typename Str::const_iterator end = s.end(); @@ -62,13 +65,13 @@ namespace boost { namespace property_tree { namespace xml_parser { switch (*it) { - case Ch('<'): r += detail::widen("<"); break; - case Ch('>'): r += detail::widen(">"); break; - case Ch('&'): r += detail::widen("&"); break; - case Ch('"'): r += detail::widen("""); break; - case Ch('\''): r += detail::widen("'"); break; - case Ch('\t'): r += detail::widen(" "); break; - case Ch('\n'): r += detail::widen(" "); break; + case Ch('<'): r += detail::widen("<"); break; + case Ch('>'): r += detail::widen(">"); break; + case Ch('&'): r += detail::widen("&"); break; + case Ch('"'): r += detail::widen("""); break; + case Ch('\''): r += detail::widen("'"); break; + case Ch('\t'): r += detail::widen(" "); break; + case Ch('\n'): r += detail::widen(" "); break; default: r += *it; break; } } @@ -76,10 +79,10 @@ namespace boost { namespace property_tree { namespace xml_parser return r; } - template - std::basic_string decode_char_entities(const std::basic_string &s) + template + Str decode_char_entities(const Str &s) { - typedef typename std::basic_string Str; + typedef typename Str::value_type Ch; Str r; typename Str::const_iterator end = s.end(); for (typename Str::const_iterator it = s.begin(); it != end; ++it) @@ -90,11 +93,11 @@ namespace boost { namespace property_tree { namespace xml_parser if (semicolon == end) BOOST_PROPERTY_TREE_THROW(xml_parser_error("invalid character entity", "", 0)); Str ent(it + 1, semicolon); - if (ent == detail::widen("lt")) r += Ch('<'); - else if (ent == detail::widen("gt")) r += Ch('>'); - else if (ent == detail::widen("amp")) r += Ch('&'); - else if (ent == detail::widen("quot")) r += Ch('"'); - else if (ent == detail::widen("apos")) r += Ch('\''); + if (ent == detail::widen("lt")) r += Ch('<'); + else if (ent == detail::widen("gt")) r += Ch('>'); + else if (ent == detail::widen("amp")) r += Ch('&'); + else if (ent == detail::widen("quot")) r += Ch('"'); + else if (ent == detail::widen("apos")) r += Ch('\''); else BOOST_PROPERTY_TREE_THROW(xml_parser_error("invalid character entity", "", 0)); it = semicolon; @@ -105,31 +108,31 @@ namespace boost { namespace property_tree { namespace xml_parser return r; } - template - const std::basic_string &xmldecl() + template + const Str &xmldecl() { - static std::basic_string s = detail::widen(""); + static Str s = detail::widen(""); return s; } - template - const std::basic_string &xmlattr() + template + const Str &xmlattr() { - static std::basic_string s = detail::widen(""); + static Str s = detail::widen(""); return s; } - template - const std::basic_string &xmlcomment() + template + const Str &xmlcomment() { - static std::basic_string s = detail::widen(""); + static Str s = detail::widen(""); return s; } - template - const std::basic_string &xmltext() + template + const Str &xmltext() { - static std::basic_string s = detail::widen(""); + static Str s = detail::widen(""); return s; } diff --git a/include/boost/property_tree/detail/xml_parser_write.hpp b/include/boost/property_tree/detail/xml_parser_write.hpp index d4d709c881..f861eabf73 100644 --- a/include/boost/property_tree/detail/xml_parser_write.hpp +++ b/include/boost/property_tree/detail/xml_parser_write.hpp @@ -19,23 +19,24 @@ namespace boost { namespace property_tree { namespace xml_parser { - template - void write_xml_indent(std::basic_ostream &stream, + template + void write_xml_indent(Stream &stream, int indent, - const xml_writer_settings & settings + const Settings & settings ) { - stream << std::basic_string(indent * settings.indent_count, settings.indent_char); + stream << std::basic_string(indent * settings.indent_count, settings.indent_char); } - template - void write_xml_comment(std::basic_ostream &stream, - const std::basic_string &s, + template + void write_xml_comment(std::basic_ostream &stream, + const Str &s, int indent, bool separate_line, - const xml_writer_settings & settings + const Settings& settings ) { + typedef typename Str::value_type Ch; if (separate_line) write_xml_indent(stream,indent,settings); stream << Ch('<') << Ch('!') << Ch('-') << Ch('-'); @@ -45,14 +46,15 @@ namespace boost { namespace property_tree { namespace xml_parser stream << Ch('\n'); } - template - void write_xml_text(std::basic_ostream &stream, - const std::basic_string &s, + template + void write_xml_text(std::basic_ostream &stream, + const Str &s, int indent, bool separate_line, - const xml_writer_settings & settings + const Settings& settings ) { + typedef typename Str::value_type Ch; if (separate_line) write_xml_indent(stream,indent,settings); stream << encode_char_entities(s); @@ -60,15 +62,15 @@ namespace boost { namespace property_tree { namespace xml_parser stream << Ch('\n'); } - template + template void write_xml_element(std::basic_ostream &stream, - const std::basic_string &key, + const typename Ptree::key_type &key, const Ptree &pt, int indent, - const xml_writer_settings & settings) + const Settings& settings) { - typedef typename Ptree::key_type::value_type Ch; + typedef typename Ptree::key_type Str; typedef typename Ptree::const_iterator It; bool want_pretty = settings.indent_count > 0; @@ -77,10 +79,10 @@ namespace boost { namespace property_tree { namespace xml_parser bool has_attrs_only = pt.data().empty(); for (It it = pt.begin(), end = pt.end(); it != end; ++it) { - if (it->first != xmlattr() ) + if (it->first != xmlattr() ) { has_attrs_only = false; - if (it->first != xmltext()) + if (it->first != xmltext()) { has_elements = true; break; @@ -112,12 +114,12 @@ namespace boost { namespace property_tree { namespace xml_parser stream << Ch('<') << key; // Write attributes - if (optional attribs = pt.get_child_optional(xmlattr())) + if (optional attribs = pt.get_child_optional(xmlattr())) for (It it = attribs.get().begin(); it != attribs.get().end(); ++it) stream << Ch(' ') << it->first << Ch('=') << Ch('"') << encode_char_entities( - it->second.template get_value >()) + it->second.template get_value()) << Ch('"'); if ( has_attrs_only ) @@ -141,21 +143,21 @@ namespace boost { namespace property_tree { namespace xml_parser // Write data text, if present if (!pt.data().empty()) write_xml_text(stream, - pt.template get_value >(), + pt.template get_value(), indent + 1, has_elements && want_pretty, settings); // Write elements, comments and texts for (It it = pt.begin(); it != pt.end(); ++it) { - if (it->first == xmlattr()) + if (it->first == xmlattr()) continue; - else if (it->first == xmlcomment()) + else if (it->first == xmlcomment()) write_xml_comment(stream, - it->second.template get_value >(), + it->second.template get_value(), indent + 1, want_pretty, settings); - else if (it->first == xmltext()) + else if (it->first == xmltext()) write_xml_text(stream, - it->second.template get_value >(), + it->second.template get_value(), indent + 1, has_elements && want_pretty, settings); else write_xml_element(stream, it->first, it->second, @@ -175,17 +177,16 @@ namespace boost { namespace property_tree { namespace xml_parser } } - template + template void write_xml_internal(std::basic_ostream &stream, const Ptree &pt, const std::string &filename, - const xml_writer_settings & settings) + const Settings & settings) { - typedef typename Ptree::key_type::value_type Ch; - typedef typename std::basic_string Str; - stream << detail::widen("("("\"?>\n"); + << detail::widen("\"?>\n"); write_xml_element(stream, Str(), pt, -1, settings); if (!stream) BOOST_PROPERTY_TREE_THROW(xml_parser_error("write error", filename, 0)); diff --git a/include/boost/property_tree/detail/xml_parser_writer_settings.hpp b/include/boost/property_tree/detail/xml_parser_writer_settings.hpp index 0cc707a538..dfdb50affa 100644 --- a/include/boost/property_tree/detail/xml_parser_writer_settings.hpp +++ b/include/boost/property_tree/detail/xml_parser_writer_settings.hpp @@ -18,10 +18,11 @@ namespace boost { namespace property_tree { namespace xml_parser { // Naively convert narrow string to another character type - template - std::basic_string widen(const char *text) + template + Str widen(const char *text) { - std::basic_string result; + typedef typename Str::value_type Ch; + Str result; while (*text) { result += Ch(*text); @@ -31,30 +32,56 @@ namespace boost { namespace property_tree { namespace xml_parser } //! Xml writer settings. The default settings lead to no pretty printing. - template + template class xml_writer_settings { + typedef typename Str::value_type Ch; public: xml_writer_settings(Ch inchar = Ch(' '), - typename std::basic_string::size_type incount = 0, - const std::basic_string &enc = widen("utf-8")) + typename Str::size_type incount = 0, + const Str &enc = widen("utf-8")) : indent_char(inchar) , indent_count(incount) , encoding(enc) { } - const Ch indent_char; - const typename std::basic_string::size_type indent_count; - const std::basic_string encoding; + Ch indent_char; + typename Str::size_type indent_count; + Str encoding; }; - template - xml_writer_settings xml_writer_make_settings(Ch indent_char = Ch(' '), - typename std::basic_string::size_type indent_count = 0, - const std::basic_string &encoding = widen("utf-8")) + template<> + class xml_writer_settings { - return xml_writer_settings(indent_char, indent_count, encoding); + public: + xml_writer_settings(char inchar = ' ', + std::string::size_type incount = 0, + const std::string &enc = widen("utf-8")) + : indent_char(inchar) + , indent_count(incount) + , encoding(enc) + { + } + + char indent_char; + std::string::size_type indent_count; + std::string encoding; + }; + + template + xml_writer_settings xml_writer_make_settings(typename Str::value_type indent_char = (typename Str::value_type)(' '), + typename Str::size_type indent_count = 0, + const Str &encoding = widen("utf-8")) + { + return xml_writer_settings(indent_char, indent_count, encoding); + } + + template + xml_writer_settings xml_writer_make_settings(char indent_char, + size_type indent_count) + { + return xml_writer_settings(indent_char, indent_count, widen("utf-8")); } } } } diff --git a/include/boost/property_tree/string_path.hpp b/include/boost/property_tree/string_path.hpp index d4bc686dc6..3ddcfb2033 100644 --- a/include/boost/property_tree/string_path.hpp +++ b/include/boost/property_tree/string_path.hpp @@ -61,7 +61,7 @@ namespace boost { namespace property_tree #ifndef BOOST_NO_STD_WSTRING inline std::string dump_sequence(const std::wstring &s) { - return narrow(s.c_str()); + return narrow(s.c_str()); } #endif } diff --git a/include/boost/property_tree/xml_parser.hpp b/include/boost/property_tree/xml_parser.hpp index 4f36e9a0be..739f622590 100644 --- a/include/boost/property_tree/xml_parser.hpp +++ b/include/boost/property_tree/xml_parser.hpp @@ -96,19 +96,37 @@ namespace boost { namespace property_tree { namespace xml_parser * @param settings The settings to use when writing out the property tree as * XML. */ - template + template void write_xml(std::basic_ostream< typename Ptree::key_type::value_type > &stream, const Ptree &pt, - const xml_writer_settings< + const Settings & settings) + { + write_xml_internal(stream, pt, std::string(), settings); + } + + /** + * Translates the property tree to XML and writes it the given output + * stream. + * @throw xml_parser_error In case of error translating the property tree to + * XML or writing to the output stream. + * @param stream The stream to which to write the XML representation of the + * property tree. + * @param pt The property tree to tranlsate to XML and output. + */ + template + void write_xml(std::basic_ostream< typename Ptree::key_type::value_type - > & settings = xml_writer_settings< - typename Ptree::key_type::value_type>() ) + > &stream, + const Ptree &pt ) { + xml_writer_settings settings; + write_xml_internal(stream, pt, std::string(), settings); } + /** * Translates the property tree to XML and writes it the given file. * @throw xml_parser_error In case of error translating the property tree to @@ -120,14 +138,11 @@ namespace boost { namespace property_tree { namespace xml_parser * @param settings The settings to use when writing out the property tree as * XML. */ - template + template void write_xml(const std::string &filename, const Ptree &pt, - const std::locale &loc = std::locale(), - const xml_writer_settings< - typename Ptree::key_type::value_type - > & settings = xml_writer_settings< - typename Ptree::key_type::value_type>()) + const std::locale &loc, + const Settings & settings) { std::basic_ofstream stream(filename.c_str()); @@ -138,6 +153,24 @@ namespace boost { namespace property_tree { namespace xml_parser write_xml_internal(stream, pt, filename, settings); } + /** + * Translates the property tree to XML and writes it the given file. + * @throw xml_parser_error In case of error translating the property tree to + * XML or writing to the output stream. + * @param filename The file to which to write the XML representation of the + * property tree. + * @param pt The property tree to tranlsate to XML and output. + * @param loc The locale to use when writing the output to file. + */ + template + void write_xml(const std::string &filename, + const Ptree &pt, + const std::locale &loc = std::locale()) + { + xml_writer_settings settings; + write_xml(filename, pt, loc, settings); + } + } } } namespace boost { namespace property_tree diff --git a/test/test_property_tree.hpp b/test/test_property_tree.hpp index f9ac6664fd..9a0b1272ff 100644 --- a/test/test_property_tree.hpp +++ b/test/test_property_tree.hpp @@ -797,9 +797,6 @@ void test_get_put(PTREE *) void test_get_child_put_child(PTREE *) { - - typedef std::basic_string str_t; - PTREE pt(T("ala ma kota")); // Do insertions via put_child @@ -1076,7 +1073,6 @@ void test_custom_data_type(PTREE *) typedef std::basic_string Str; typedef PTREE::key_compare Comp; - typedef PTREE::path_type Path; // Property_tree with boost::any as data type typedef boost::property_tree::basic_ptree my_ptree; diff --git a/test/test_registry_parser.cpp b/test/test_registry_parser.cpp deleted file mode 100644 index 2e7c348816..0000000000 --- a/test/test_registry_parser.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// ---------------------------------------------------------------------------- -// Copyright (C) 2002-2006 Marcin Kalicinski -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// For more information, see www.boost.org -// ---------------------------------------------------------------------------- - -#include "test_utils.hpp" - -// Only test registry parser if we have windows platform -#ifdef BOOST_WINDOWS - -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -// Test data - -const char *data_1 = - "root\n" - "{\n" - " subkey1 \"default value 1\"\n" - " subkey2 \"default value 2\"\n" - " \\\\values\n" - " {\n" - " REG_NONE \"\"\n" - " REG_BINARY \"de ad be ef\"\n" - " REG_DWORD 1234567890\n" - " REG_QWORD 12345678901234567890\n" - " REG_SZ \"some text\"\n" - " REG_EXPAND_SZ \"some other text\"\n" - " }\n" - " \\\\types\n" - " {\n" - " REG_NONE 0\n" - " REG_BINARY 3\n" - " REG_DWORD 4\n" - " REG_QWORD 11\n" - " REG_SZ 1\n" - " REG_EXPAND_SZ 2\n" - " }\n" - "}\n"; - -template -void test_registry_parser() -{ - - using namespace boost::property_tree; - typedef typename Ptree::key_type::value_type Ch; - typedef std::basic_string Str; - - // Delete test registry key - RegDeleteKeyA(HKEY_CURRENT_USER, "boost ptree test"); - - // Get test ptree - Ptree pt; - std::basic_stringstream stream(detail::widen(data_1)); - read_info(stream, pt); - - try - { - - // Write to registry, read back and compare contents - Ptree pt2; - write_registry(HKEY_CURRENT_USER, detail::widen("boost ptree test"), pt); - read_registry(HKEY_CURRENT_USER, detail::widen("boost ptree test"), pt2); - BOOST_CHECK(pt == pt2); - - // Test binary translation - Str s = pt2.template get(detail::widen("root.\\values.REG_BINARY")); - std::vector bin = registry_parser::translate(REG_BINARY, s); - BOOST_REQUIRE(bin.size() == 4); - BOOST_CHECK(*reinterpret_cast(&bin.front()) == 0xEFBEADDE); - Str s2 = registry_parser::translate(REG_BINARY, bin); - BOOST_CHECK(s == s2); - - } - catch (std::exception &e) - { - BOOST_ERROR(e.what()); - } - - // Delete test registry key - RegDeleteKeyA(HKEY_CURRENT_USER, "boost ptree test"); - -} - -int test_main(int argc, char *argv[]) -{ - using namespace boost::property_tree; - test_registry_parser(); - //test_registry_parser(); -#ifndef BOOST_NO_CWCHAR - //test_registry_parser(); - //test_registry_parser(); -#endif - return 0; -} - -#else - -int test_main(int argc, char *argv[]) -{ - return 0; -} - -#endif diff --git a/test/test_utils.hpp b/test/test_utils.hpp index 2a4a3bdae6..809f91f572 100644 --- a/test/test_utils.hpp +++ b/test/test_utils.hpp @@ -81,13 +81,13 @@ template Ptree get_test_ptree() { using namespace boost::property_tree; - typedef typename Ptree::key_type::value_type Ch; + typedef typename Ptree::key_type Str; Ptree pt; - pt.put_value(detail::widen("data0")); - pt.put(detail::widen("key1"), detail::widen("data1")); - pt.put(detail::widen("key1.key"), detail::widen("data2")); - pt.put(detail::widen("key2"), detail::widen("data3")); - pt.put(detail::widen("key2.key"), detail::widen("data4")); + pt.put_value(detail::widen("data0")); + pt.put(detail::widen("key1"), detail::widen("data1")); + pt.put(detail::widen("key1.key"), detail::widen("data2")); + pt.put(detail::widen("key2"), detail::widen("data3")); + pt.put(detail::widen("key2.key"), detail::widen("data4")); return pt; } @@ -104,7 +104,6 @@ void generic_parser_test(Ptree &pt, { using namespace boost::property_tree; - typedef typename Ptree::key_type::value_type Ch; // Create test files test_file file_1(test_data_1, filename_1); @@ -236,7 +235,8 @@ void check_exact_roundtrip(ReadFunc rf, WriteFunc wf, const char *test_data) { << test_data << "\n-----\n"; using namespace boost::property_tree; typedef typename Ptree::key_type::value_type Ch; - std::basic_string native_test_data = detail::widen(test_data); + typedef typename Ptree::key_type Str; + Str native_test_data = detail::widen(test_data); std::basic_istringstream in_stream(native_test_data); std::basic_ostringstream out_stream; diff --git a/test/test_xml_parser_common.hpp b/test/test_xml_parser_common.hpp index 9679cb57ec..019773bb65 100644 --- a/test/test_xml_parser_common.hpp +++ b/test/test_xml_parser_common.hpp @@ -49,8 +49,7 @@ struct WriteFuncNS void operator()(const std::string &filename, const Ptree &pt) const { boost::property_tree::write_xml(filename, pt, std::locale(), - boost::property_tree::xml_writer_make_settings( - typename Ptree::key_type::value_type(' '), 4)); + boost::property_tree::xml_writer_make_settings(' ', 4)); } };