Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76447 - in branches/release: boost/property_tree boost/property_tree/detail libs/property_tree libs/property_tree/test
From: sebastian.redl_at_[hidden]
Date: 2012-01-13 07:20:41


Author: cornedbee
Date: 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
New Revision: 76447
URL: http://svn.boost.org/trac/boost/changeset/76447

Log:
Merge [72000],[72001],[72003], [74691], [75587], [75589], [75590], and [75593]
from trunk.
Fixes bug 4840.
Fixes bug 5259.
Fixes bug 5281, I think.
Fixes bug 5944.
Fixes bug 5757.
Fixes bug 5710.
Fixes bug 5307, I think.
Properties modified:
   branches/release/boost/property_tree/ (props changed)
   branches/release/libs/property_tree/ (props changed)
Text files modified:
   branches/release/boost/property_tree/detail/exception_implementation.hpp | 4 ++--
   branches/release/boost/property_tree/detail/ptree_implementation.hpp | 35 ++++++++++++++++++++++-------------
   branches/release/boost/property_tree/detail/rapidxml.hpp | 11 ++++++-----
   branches/release/boost/property_tree/detail/xml_parser_read_rapidxml.hpp | 9 ++++++---
   branches/release/boost/property_tree/detail/xml_parser_write.hpp | 7 +++++--
   branches/release/boost/property_tree/exceptions.hpp | 10 ++++++----
   branches/release/boost/property_tree/string_path.hpp | 3 +++
   branches/release/libs/property_tree/test/Jamfile.v2 | 19 ++++++++++++-------
   branches/release/libs/property_tree/test/test_property_tree.cpp | 4 ++++
   branches/release/libs/property_tree/test/test_property_tree.hpp | 25 +++++++++++++++++++++++++
   branches/release/libs/property_tree/test/test_xml_parser_common.hpp | 7 +++++++
   branches/release/libs/property_tree/test/xml_parser_test_data.hpp | 5 +++++
   12 files changed, 103 insertions(+), 36 deletions(-)

Modified: branches/release/boost/property_tree/detail/exception_implementation.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/exception_implementation.hpp (original)
+++ branches/release/boost/property_tree/detail/exception_implementation.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -53,7 +53,7 @@
     }
 
     template<class D> inline
- D ptree_bad_data::data()
+ D ptree_bad_data::data() const
     {
         return boost::any_cast<D>(m_data);
     }
@@ -73,7 +73,7 @@
     }
 
     template<class P> inline
- P ptree_bad_path::path()
+ P ptree_bad_path::path() const
     {
         return boost::any_cast<P>(m_path);
     }

Modified: branches/release/boost/property_tree/detail/ptree_implementation.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/ptree_implementation.hpp (original)
+++ branches/release/boost/property_tree/detail/ptree_implementation.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -14,10 +14,13 @@
 #include <boost/iterator/iterator_adaptor.hpp>
 #include <boost/iterator/reverse_iterator.hpp>
 #include <boost/assert.hpp>
+#include <boost/utility/swap.hpp>
 #include <memory>
 
-#if defined(BOOST_MSVC) && \
- (_MSC_FULL_VER >= 160000000 && _MSC_FULL_VER < 170000000)
+#if (defined(BOOST_MSVC) && \
+ (_MSC_FULL_VER >= 160000000 && _MSC_FULL_VER < 170000000)) || \
+ (defined(BOOST_INTEL_WIN) && \
+ defined(BOOST_DINKUMWARE_STDLIB))
 #define BOOST_PROPERTY_TREE_PAIR_BUG
 #endif
 
@@ -33,28 +36,23 @@
         // class. Unfortunately this does break the interface.
         BOOST_STATIC_CONSTANT(unsigned,
             first_offset = offsetof(value_type, first));
+#endif
         typedef multi_index_container<value_type,
             multi_index::indexed_by<
                 multi_index::sequenced<>,
                 multi_index::ordered_non_unique<multi_index::tag<by_name>,
+#if defined(BOOST_PROPERTY_TREE_PAIR_BUG)
                     multi_index::member_offset<value_type, const key_type,
                                         first_offset>,
- key_compare
- >
- >
- > base_container;
 #else
- typedef multi_index_container<value_type,
- multi_index::indexed_by<
- multi_index::sequenced<>,
- multi_index::ordered_non_unique<multi_index::tag<by_name>,
                     multi_index::member<value_type, const key_type,
                                         &value_type::first>,
+#endif
                     key_compare
>
>
> base_container;
-#endif
+
         // The by-name lookup index.
         typedef typename base_container::template index<by_name>::type
             by_name_index;
@@ -213,7 +211,7 @@
     template<class K, class D, class C> inline
     void basic_ptree<K, D, C>::swap(basic_ptree<K, D, C> &rhs)
     {
- m_data.swap(rhs.m_data);
+ boost::swap(m_data, rhs.m_data);
         // Void pointers, no ADL necessary
         std::swap(m_children, rhs.m_children);
     }
@@ -384,10 +382,21 @@
         subs::ch(this).reverse();
     }
 
+ namespace impl
+ {
+ struct by_first
+ {
+ template <typename P>
+ bool operator ()(const P& lhs, const P& rhs) const {
+ return lhs.first < rhs.first;
+ };
+ };
+ }
+
     template<class K, class D, class C> inline
     void basic_ptree<K, D, C>::sort()
     {
- subs::ch(this).sort();
+ sort(impl::by_first());
     }
 
     template<class K, class D, class C>

Modified: branches/release/boost/property_tree/detail/rapidxml.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/rapidxml.hpp (original)
+++ branches/release/boost/property_tree/detail/rapidxml.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -369,8 +369,9 @@
     public:
 
         //! \cond internal
- typedef void *(alloc_func)(std::size_t); // Type of user-defined function used to allocate memory
- typedef void (free_func)(void *); // Type of user-defined function used to free memory
+ // Prefixed names to work around weird MSVC lookup bug.
+ typedef void *(boost_ptree_raw_alloc_func)(std::size_t); // Type of user-defined function used to allocate memory
+ typedef void (boost_ptree_raw_free_func)(void *); // Type of user-defined function used to free memory
         //! \endcond
         
         //! Constructs empty pool with default allocator functions.
@@ -536,7 +537,7 @@
         //! </code><br>
         //! \param af Allocation function, or 0 to restore default function
         //! \param ff Free function, or 0 to restore default function
- void set_allocator(alloc_func *af, free_func *ff)
+ void set_allocator(boost_ptree_raw_alloc_func *af, boost_ptree_raw_free_func *ff)
         {
             BOOST_ASSERT(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet
             m_alloc_func = af;
@@ -617,8 +618,8 @@
         char *m_ptr; // First free byte in current pool
         char *m_end; // One past last available byte in current pool
         char m_static_memory[BOOST_PROPERTY_TREE_RAPIDXML_STATIC_POOL_SIZE]; // Static raw memory
- alloc_func *m_alloc_func; // Allocator function, or 0 if default is to be used
- free_func *m_free_func; // Free function, or 0 if default is to be used
+ boost_ptree_raw_alloc_func *m_alloc_func; // Allocator function, or 0 if default is to be used
+ boost_ptree_raw_free_func *m_free_func; // Free function, or 0 if default is to be used
     };
 
     ///////////////////////////////////////////////////////////////////////////

Modified: branches/release/boost/property_tree/detail/xml_parser_read_rapidxml.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/xml_parser_read_rapidxml.hpp (original)
+++ branches/release/boost/property_tree/detail/xml_parser_read_rapidxml.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -44,7 +44,8 @@
                     {
                         Ptree &pt_attr = pt_attr_root.push_back(
                             std::make_pair(attr->name(), Ptree()))->second;
- pt_attr.data() = attr->value();
+ pt_attr.data() = std::basic_string<Ch>(attr->value(),
+ attr->value_size());
                     }
                 }
 
@@ -63,7 +64,8 @@
                     pt.push_back(std::make_pair(xmltext<Ch>(),
                                                 Ptree(node->value())));
                 else
- pt.data() += node->value();
+ pt.data() += std::basic_string<Ch>(node->value(),
+ node->value_size());
             }
             break;
 
@@ -72,7 +74,8 @@
             {
                 if (!(flags & no_comments))
                     pt.push_back(std::make_pair(xmlcomment<Ch>(),
- Ptree(node->value())));
+ Ptree(std::basic_string<Ch>(node->value(),
+ node->value_size()))));
             }
             break;
 

Modified: branches/release/boost/property_tree/detail/xml_parser_write.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/xml_parser_write.hpp (original)
+++ branches/release/boost/property_tree/detail/xml_parser_write.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -115,8 +115,11 @@
                 // Write attributes
                 if (optional<const Ptree &> attribs = pt.get_child_optional(xmlattr<Ch>()))
                     for (It it = attribs.get().begin(); it != attribs.get().end(); ++it)
- stream << Ch(' ') << it->first << Ch('=') <<
- Ch('"') << it->second.template get_value<std::basic_string<Ch> >() << Ch('"');
+ stream << Ch(' ') << it->first << Ch('=')
+ << Ch('"')
+ << encode_char_entities(
+ it->second.template get_value<std::basic_string<Ch> >())
+ << Ch('"');
 
                 if ( has_attrs_only )
                 {

Modified: branches/release/boost/property_tree/exceptions.hpp
==============================================================================
--- branches/release/boost/property_tree/exceptions.hpp (original)
+++ branches/release/boost/property_tree/exceptions.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -51,8 +51,9 @@
         ~ptree_bad_data() throw();
 
         /// Retrieve the data associated with this error. This is the source
- /// value that failed to be translated.
- template<class T> T data();
+ /// value that failed to be translated. You need to explicitly
+ /// specify its type.
+ template<class T> T data() const;
     private:
         boost::any m_data;
     };
@@ -71,8 +72,9 @@
 
         ~ptree_bad_path() throw();
 
- /// Retrieve the invalid path.
- template<class T> T path();
+ /// Retrieve the invalid path. You need to explicitly specify the
+ /// type of path.
+ template<class T> T path() const;
     private:
         boost::any m_path;
     };

Modified: branches/release/boost/property_tree/string_path.hpp
==============================================================================
--- branches/release/boost/property_tree/string_path.hpp (original)
+++ branches/release/boost/property_tree/string_path.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -122,6 +122,9 @@
         /// Test if the path contains a single element, i.e. no separators.
         bool single() const;
 
+ /// Get the separator used by this path.
+ char_type separator() const { return m_separator; }
+
         std::string dump() const {
             return detail::dump_sequence(m_value);
         }

Modified: branches/release/libs/property_tree/test/Jamfile.v2
==============================================================================
--- branches/release/libs/property_tree/test/Jamfile.v2 (original)
+++ branches/release/libs/property_tree/test/Jamfile.v2 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -10,12 +10,17 @@
 import testing ;
 
 test-suite "property_tree"
- : [ run test_property_tree.cpp /boost/serialization//boost_serialization ]
- [ run test_info_parser.cpp ]
- [ run test_json_parser.cpp ]
- [ run test_ini_parser.cpp ]
- [ run test_xml_parser_rapidxml.cpp ]
+ : [ run test_property_tree.cpp /boost/serialization//boost_serialization
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_info_parser.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_json_parser.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_ini_parser.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
+ [ run test_xml_parser_rapidxml.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
 
- [ run test_multi_module1.cpp test_multi_module2.cpp ]
- #[ run test_registry_parser.cpp ]
+ [ run test_multi_module1.cpp test_multi_module2.cpp
+ : : : <define>_SCL_SECURE_NO_WARNINGS=1 ]
 ;

Modified: branches/release/libs/property_tree/test/test_property_tree.cpp
==============================================================================
--- branches/release/libs/property_tree/test/test_property_tree.cpp (original)
+++ branches/release/libs/property_tree/test/test_property_tree.cpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -166,6 +166,7 @@
         test_serialization(pt);
         test_bool(pt);
         test_char(pt);
+ test_sort(pt);
         test_leaks(pt); // must be a final test
     }
 #if 0
@@ -199,6 +200,7 @@
         test_serialization(pt);
         test_bool(pt);
         test_char(pt);
+ test_sort(pt);
         test_leaks(pt); // must be a final test
     }
 #endif
@@ -232,6 +234,7 @@
         test_serialization(pt);
         test_bool(pt);
         test_char(pt);
+ test_sort(pt);
         test_leaks(pt); // must be a final test
     }
 
@@ -265,6 +268,7 @@
         test_serialization(pt);
         test_bool(pt);
         test_char(pt);
+ test_sort(pt);
         test_leaks(pt); // must be a final test
     }
 #endif

Modified: branches/release/libs/property_tree/test/test_property_tree.hpp
==============================================================================
--- branches/release/libs/property_tree/test/test_property_tree.hpp (original)
+++ branches/release/libs/property_tree/test/test_property_tree.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -1290,6 +1290,31 @@
 
 }
 
+void test_sort(PTREE *)
+{
+ PTREE pt;
+ pt.put(T("one"), T("v1"));
+ pt.put(T("two"), T("v2"));
+ pt.put(T("three"), T("v3"));
+ pt.put(T("four"), T("v4"));
+
+ pt.sort();
+
+ PTREE::iterator it = pt.begin();
+ BOOST_CHECK(std::distance(it, pt.end()) == 4);
+ BOOST_CHECK(it->first == T("four"));
+ BOOST_CHECK(it->second.data() == T("v4"));
+ ++it;
+ BOOST_CHECK(it->first == T("one"));
+ BOOST_CHECK(it->second.data() == T("v1"));
+ ++it;
+ BOOST_CHECK(it->first == T("three"));
+ BOOST_CHECK(it->second.data() == T("v3"));
+ ++it;
+ BOOST_CHECK(it->first == T("two"));
+ BOOST_CHECK(it->second.data() == T("v2"));
+}
+
 void test_leaks(PTREE *)
 {
     //BOOST_CHECK(PTREE::debug_get_instances_count() == 0);

Modified: branches/release/libs/property_tree/test/test_xml_parser_common.hpp
==============================================================================
--- branches/release/libs/property_tree/test/test_xml_parser_common.hpp (original)
+++ branches/release/libs/property_tree/test/test_xml_parser_common.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -139,6 +139,13 @@
         3, 4 * umlautsize<char_type>(), 13
     );
 
+ generic_parser_test_ok<Ptree, ReadFuncWS, WriteFuncWS>
+ (
+ ReadFuncWS(), WriteFuncWS(), bug_data_pr4840, NULL,
+ "testpr4840.xml", NULL, "testpr4840out.xml",
+ 4, 13, 15
+ );
+
 }
 
 #endif

Modified: branches/release/libs/property_tree/test/xml_parser_test_data.hpp
==============================================================================
--- branches/release/libs/property_tree/test/xml_parser_test_data.hpp (original)
+++ branches/release/libs/property_tree/test/xml_parser_test_data.hpp 2012-01-13 07:20:39 EST (Fri, 13 Jan 2012)
@@ -773,4 +773,9 @@
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
     "<name>\xD0\xAE\xD0\xBD\xD0\xB8\xD1\x82</name>";
 
+// Quoting attributes
+const char *bug_data_pr4840 =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ "<start a=\"hello &quot;world&quot;\"/>";
+
 #endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk