Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71991 - in branches/release/boost/property_tree: . detail
From: sebastian.redl_at_[hidden]
Date: 2011-05-16 14:33:40


Author: cornedbee
Date: 2011-05-16 14:33:39 EDT (Mon, 16 May 2011)
New Revision: 71991
URL: http://svn.boost.org/trac/boost/changeset/71991

Log:
Merge r68990-68993, several fixes to PTree. Fixes bug 1678. Fixes bug 4387.
Properties modified:
   branches/release/boost/property_tree/ (props changed)
Text files modified:
   branches/release/boost/property_tree/detail/json_parser_read.hpp | 4 +-
   branches/release/boost/property_tree/detail/ptree_implementation.hpp | 4 +-
   branches/release/boost/property_tree/detail/rapidxml.hpp | 64 +++++++++++++++++++++++----------------
   branches/release/boost/property_tree/string_path.hpp | 10 +++--
   4 files changed, 47 insertions(+), 35 deletions(-)

Modified: branches/release/boost/property_tree/detail/json_parser_read.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/json_parser_read.hpp (original)
+++ branches/release/boost/property_tree/detail/json_parser_read.hpp 2011-05-16 14:33:39 EDT (Mon, 16 May 2011)
@@ -184,7 +184,7 @@
                 using boost::spirit::classic::assertion;
 
                 // Assertions
- assertion<std::string> expect_object("expected object");
+ assertion<std::string> expect_root("expected object or array");
                 assertion<std::string> expect_eoi("expected end of input");
                 assertion<std::string> expect_objclose("expected ',' or '}'");
                 assertion<std::string> expect_arrclose("expected ',' or ']'");
@@ -195,7 +195,7 @@
 
                 // JSON grammar rules
                 root
- = expect_object(object)
+ = expect_root(object | array)
>> expect_eoi(end_p)
                         ;
                 

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 2011-05-16 14:33:39 EDT (Mon, 16 May 2011)
@@ -13,8 +13,8 @@
 
 #include <boost/iterator/iterator_adaptor.hpp>
 #include <boost/iterator/reverse_iterator.hpp>
+#include <boost/assert.hpp>
 #include <memory>
-#include <cassert>
 
 #if defined(BOOST_MSVC) && \
     (_MSC_FULL_VER >= 160000000 && _MSC_FULL_VER < 170000000)
@@ -874,7 +874,7 @@
     template<class K, class D, class C>
     basic_ptree<K, D, C> & basic_ptree<K, D, C>::force_path(path_type &p)
     {
- assert(!p.empty() && "Empty path not allowed for put_child.");
+ BOOST_ASSERT(!p.empty() && "Empty path not allowed for put_child.");
         if(p.single()) {
             // I'm the parent we're looking for.
             return *this;

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 2011-05-16 14:33:39 EDT (Mon, 16 May 2011)
@@ -12,8 +12,8 @@
 
 //! \file rapidxml.hpp This file contains rapidxml parser and DOM implementation
 
+#include <boost/assert.hpp>
 #include <cstdlib> // For std::size_t
-#include <cassert> // For assert
 #include <new> // For placement new
 
 // On MSVC, disable "conditional expression is constant" warning (level 4).
@@ -460,7 +460,7 @@
         //! \return Pointer to allocated char array. This pointer will never be NULL.
         Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)
         {
- assert(source || size); // Either source or size (or both) must be specified
+ BOOST_ASSERT(source || size); // Either source or size (or both) must be specified
             if (size == 0)
                 size = internal::measure(source) + 1;
             Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));
@@ -536,7 +536,7 @@
         //! \param ff Free function, or 0 to restore default function
         void set_allocator(alloc_func *af, free_func *ff)
         {
- assert(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet
+ BOOST_ASSERT(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet
             m_alloc_func = af;
             m_free_func = ff;
         }
@@ -568,7 +568,7 @@
             if (m_alloc_func) // Allocate memory using either user-specified allocation function or global operator new[]
             {
                 memory = m_alloc_func(size);
- assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp
+ BOOST_ASSERT(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp
             }
             else
             {
@@ -938,7 +938,7 @@
         //! \return Pointer to found child, or 0 if not found.
         xml_node<Ch> *last_node(const Ch *n = 0, std::size_t nsize = 0, bool case_sensitive = true) const
         {
- assert(m_first_node); // Cannot query for last child if node has no children
+ BOOST_ASSERT(m_first_node); // Cannot query for last child if node has no children
             if (n)
             {
                 if (nsize == 0)
@@ -961,7 +961,7 @@
         //! \return Pointer to found sibling, or 0 if not found.
         xml_node<Ch> *previous_sibling(const Ch *n = 0, std::size_t nsize = 0, bool case_sensitive = true) const
         {
- assert(this->m_parent); // Cannot query for siblings if node has no parent
+ BOOST_ASSERT(this->m_parent); // Cannot query for siblings if node has no parent
             if (n)
             {
                 if (nsize == 0)
@@ -984,7 +984,7 @@
         //! \return Pointer to found sibling, or 0 if not found.
         xml_node<Ch> *next_sibling(const Ch *n = 0, std::size_t nsize = 0, bool case_sensitive = true) const
         {
- assert(this->m_parent); // Cannot query for siblings if node has no parent
+ BOOST_ASSERT(this->m_parent); // Cannot query for siblings if node has no parent
             if (n)
             {
                 if (nsize == 0)
@@ -1056,7 +1056,7 @@
         //! \param child Node to prepend.
         void prepend_node(xml_node<Ch> *child)
         {
- assert(child && !child->parent() && child->type() != node_document);
+ BOOST_ASSERT(child && !child->parent() && child->type() != node_document);
             if (first_node())
             {
                 child->m_next_sibling = m_first_node;
@@ -1077,7 +1077,7 @@
         //! \param child Node to append.
         void append_node(xml_node<Ch> *child)
         {
- assert(child && !child->parent() && child->type() != node_document);
+ BOOST_ASSERT(child && !child->parent() && child->type() != node_document);
             if (first_node())
             {
                 child->m_prev_sibling = m_last_node;
@@ -1099,8 +1099,8 @@
         //! \param child Node to insert.
         void insert_node(xml_node<Ch> *where, xml_node<Ch> *child)
         {
- assert(!where || where->parent() == this);
- assert(child && !child->parent() && child->type() != node_document);
+ BOOST_ASSERT(!where || where->parent() == this);
+ BOOST_ASSERT(child && !child->parent() && child->type() != node_document);
             if (where == m_first_node)
                 prepend_node(child);
             else if (where == 0)
@@ -1120,7 +1120,7 @@
         //! Use first_node() to test if node has children.
         void remove_first_node()
         {
- assert(first_node());
+ BOOST_ASSERT(first_node());
             xml_node<Ch> *child = m_first_node;
             m_first_node = child->m_next_sibling;
             if (child->m_next_sibling)
@@ -1135,7 +1135,7 @@
         //! Use first_node() to test if node has children.
         void remove_last_node()
         {
- assert(first_node());
+ BOOST_ASSERT(first_node());
             xml_node<Ch> *child = m_last_node;
             if (child->m_prev_sibling)
             {
@@ -1151,8 +1151,8 @@
         // \param where Pointer to child to be removed.
         void remove_node(xml_node<Ch> *where)
         {
- assert(where && where->parent() == this);
- assert(first_node());
+ BOOST_ASSERT(where && where->parent() == this);
+ BOOST_ASSERT(first_node());
             if (where == m_first_node)
                 remove_first_node();
             else if (where == m_last_node)
@@ -1177,7 +1177,7 @@
         //! \param attribute Attribute to prepend.
         void prepend_attribute(xml_attribute<Ch> *attribute)
         {
- assert(attribute && !attribute->parent());
+ BOOST_ASSERT(attribute && !attribute->parent());
             if (first_attribute())
             {
                 attribute->m_next_attribute = m_first_attribute;
@@ -1197,7 +1197,7 @@
         //! \param attribute Attribute to append.
         void append_attribute(xml_attribute<Ch> *attribute)
         {
- assert(attribute && !attribute->parent());
+ BOOST_ASSERT(attribute && !attribute->parent());
             if (first_attribute())
             {
                 attribute->m_prev_attribute = m_last_attribute;
@@ -1219,8 +1219,8 @@
         //! \param attribute Attribute to insert.
         void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)
         {
- assert(!where || where->parent() == this);
- assert(attribute && !attribute->parent());
+ BOOST_ASSERT(!where || where->parent() == this);
+ BOOST_ASSERT(attribute && !attribute->parent());
             if (where == m_first_attribute)
                 prepend_attribute(attribute);
             else if (where == 0)
@@ -1240,7 +1240,7 @@
         //! Use first_attribute() to test if node has attributes.
         void remove_first_attribute()
         {
- assert(first_attribute());
+ BOOST_ASSERT(first_attribute());
             xml_attribute<Ch> *attribute = m_first_attribute;
             if (attribute->m_next_attribute)
             {
@@ -1257,7 +1257,7 @@
         //! Use first_attribute() to test if node has attributes.
         void remove_last_attribute()
         {
- assert(first_attribute());
+ BOOST_ASSERT(first_attribute());
             xml_attribute<Ch> *attribute = m_last_attribute;
             if (attribute->m_prev_attribute)
             {
@@ -1273,7 +1273,7 @@
         //! \param where Pointer to attribute to be removed.
         void remove_attribute(xml_attribute<Ch> *where)
         {
- assert(first_attribute() && where->parent() == this);
+ BOOST_ASSERT(first_attribute() && where->parent() == this);
             if (where == m_first_attribute)
                 remove_first_attribute();
             else if (where == m_last_attribute)
@@ -1361,7 +1361,7 @@
         template<int Flags>
         void parse(Ch *text)
         {
- assert(text);
+ BOOST_ASSERT(text);
             
             // Remove current contents
             this->remove_all_nodes();
@@ -1701,16 +1701,26 @@
         ///////////////////////////////////////////////////////////////////////
         // Internal parsing functions
         
- // Parse BOM, if any
+ // Parse UTF-8 BOM, if any
         template<int Flags>
- void parse_bom(Ch *&text)
+ void parse_bom(char *&text)
         {
- // UTF-8?
             if (static_cast<unsigned char>(text[0]) == 0xEF &&
                 static_cast<unsigned char>(text[1]) == 0xBB &&
                 static_cast<unsigned char>(text[2]) == 0xBF)
             {
- text += 3; // Skip utf-8 bom
+ text += 3;
+ }
+ }
+
+ // Parse UTF-16/32 BOM, if any
+ template<int Flags>
+ void parse_bom(wchar_t *&text)
+ {
+ const wchar_t bom = 0xFEFF;
+ if (text[0] == bom)
+ {
+ ++text;
             }
         }
 

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 2011-05-16 14:33:39 EDT (Mon, 16 May 2011)
@@ -17,13 +17,13 @@
 #include <boost/property_tree/detail/ptree_utils.hpp>
 
 #include <boost/static_assert.hpp>
+#include <boost/assert.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/optional.hpp>
 #include <boost/throw_exception.hpp>
 #include <algorithm>
 #include <string>
 #include <iterator>
-#include <cassert>
 
 namespace boost { namespace property_tree
 {
@@ -132,8 +132,10 @@
             // If it's single, there's no separator. This allows to do
             // p /= "piece";
             // even for non-default separators.
- assert((m_separator == o.m_separator || o.empty() || o.single())
- && "Incompatible paths.");
+ BOOST_ASSERT((m_separator == o.m_separator
+ || o.empty()
+ || o.single())
+ && "Incompatible paths.");
             if(!o.empty()) {
                 String sub;
                 if(!this->empty()) {
@@ -200,7 +202,7 @@
     template <typename String, typename Translator>
     typename Translator::external_type string_path<String, Translator>::reduce()
     {
- assert(!empty() && "Reducing empty path");
+ BOOST_ASSERT(!empty() && "Reducing empty path");
 
         s_iter next_sep = std::find(m_start, m_value.end(), m_separator);
         String part(m_start, next_sep);


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