diff options
Diffstat (limited to 'boost/geometry/index/detail/serialization.hpp')
-rw-r--r-- | boost/geometry/index/detail/serialization.hpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/boost/geometry/index/detail/serialization.hpp b/boost/geometry/index/detail/serialization.hpp index 71902d19f7..acb8cde2aa 100644 --- a/boost/geometry/index/detail/serialization.hpp +++ b/boost/geometry/index/detail/serialization.hpp @@ -1,6 +1,11 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland. +// +// This file was modified by Oracle on 2021-2023. +// Modifications copyright (c) 2021-2023 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -9,10 +14,20 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_SERIALIZATION_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_SERIALIZATION_HPP -//#include <boost/serialization/serialization.hpp> +#include <boost/type_traits/alignment_of.hpp> +#include <boost/type_traits/aligned_storage.hpp> + +#include <boost/serialization/serialization.hpp> #include <boost/serialization/split_member.hpp> #include <boost/serialization/version.hpp> -//#include <boost/serialization/nvp.hpp> +#include <boost/serialization/nvp.hpp> + +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/box.hpp> + +#include <boost/geometry/index/parameters.hpp> +#include <boost/geometry/index/detail/rtree/node/concept.hpp> +#include <boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp> // TODO // how about using the unsigned type capable of storing Max in compile-time versions? @@ -26,9 +41,15 @@ // each geometry save without this info // TODO - move to index/detail/serialization.hpp -namespace boost { namespace geometry { namespace index { namespace detail { +namespace boost { namespace geometry { namespace index { + +// Forward declaration +template <typename Value, typename Options, typename IndexableGetter, typename EqualTo, typename Allocator> +class rtree; -// TODO - use boost::move? +namespace detail { + +// TODO - use std::move? template<typename T> class serialization_storage { @@ -57,7 +78,7 @@ private: template <typename T, typename Archive> inline T serialization_load(const char * name, Archive & ar) { - namespace bs = boost::serialization; + namespace bs = boost::serialization; serialization_storage<T> storage(ar, bs::version<T>::value); // load_construct_data ar >> boost::serialization::make_nvp(name, *storage.address()); // serialize //ar >> *storage.address(); // serialize @@ -72,7 +93,7 @@ void serialization_save(T const& t, const char * name, Archive & ar) ar << boost::serialization::make_nvp(name, t); // serialize //ar << t; // serialize } - + }}}} // TODO - move to index/serialization/rtree.hpp @@ -391,15 +412,17 @@ private: size_t elements_count; ar >> boost::serialization::make_nvp("s", elements_count); - // leafs_level == 0 implies current_level == 0 - if ( (elements_count < parameters.get_min_elements() && leafs_level > 0) + // root may contain count < min but shouldn't contain count > max + if ( (elements_count < parameters.get_min_elements() && current_level > 0) || parameters.get_max_elements() < elements_count ) + { BOOST_THROW_EXCEPTION(std::runtime_error("rtree loading error")); + } if ( current_level < leafs_level ) { node_pointer n = rtree::create_node<allocators_type, internal_node>::apply(allocators); // MAY THROW (A) - subtree_destroyer auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); internal_node & in = rtree::get<internal_node>(*n); elements_type & elements = rtree::elements(in); @@ -460,7 +483,7 @@ public: typedef typename Rtree::value_type value_type; typedef typename Rtree::options_type options_type; typedef typename Rtree::box_type box_type; - typedef typename Rtree::allocators_type allocators_type; + typedef typename Rtree::allocators_type allocators_type; const_private_view(Rtree const& rt) : m_rtree(rt) {} @@ -485,7 +508,7 @@ public: typedef typename Rtree::value_type value_type; typedef typename Rtree::options_type options_type; typedef typename Rtree::box_type box_type; - typedef typename Rtree::allocators_type allocators_type; + typedef typename Rtree::allocators_type allocators_type; private_view(Rtree & rt) : m_rtree(rt) {} |