|
| 1 | +// Boost.Geometry |
| 2 | + |
| 3 | +// Copyright (c) 2023 Barend Gehrels, Amsterdam, the Netherlands. |
| 4 | + |
| 5 | +// Use, modification and distribution is subject to the Boost Software License, |
| 6 | +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 8 | + |
| 9 | + |
| 10 | +#ifndef GEOMETRY_TEST_ADAPT_CNC_MULTI_LINESTRING_HPP |
| 11 | +#define GEOMETRY_TEST_ADAPT_CNC_MULTI_LINESTRING_HPP |
| 12 | + |
| 13 | +#include "cnc_multi_linestring.hpp" |
| 14 | + |
| 15 | +// 1. Adapt to Boost.Geometry |
| 16 | +namespace boost { namespace geometry { namespace traits |
| 17 | +{ |
| 18 | + |
| 19 | +template <typename Linestring> |
| 20 | +struct tag<cnc_multi_linestring<Linestring>> |
| 21 | +{ |
| 22 | + using type = multi_linestring_tag; |
| 23 | +}; |
| 24 | + |
| 25 | +template <typename Linestring> |
| 26 | +struct clear<cnc_multi_linestring<Linestring> > |
| 27 | +{ |
| 28 | + static void apply(cnc_multi_linestring<Linestring>& multi) |
| 29 | + { |
| 30 | + multi.custom_clear(); |
| 31 | + } |
| 32 | +}; |
| 33 | + |
| 34 | +template <typename Linestring> |
| 35 | +struct push_back<cnc_multi_linestring<Linestring> > |
| 36 | +{ |
| 37 | + static void apply(cnc_multi_linestring<Linestring>& multi, Linestring const& item) |
| 38 | + { |
| 39 | + multi.custom_push_back(item); |
| 40 | + } |
| 41 | + static inline void apply(cnc_multi_linestring<Linestring>& multi, Linestring&& item) |
| 42 | + { |
| 43 | + multi.custom_push_back_move(std::move(item)); |
| 44 | + } |
| 45 | +}; |
| 46 | + |
| 47 | +template <typename Linestring> |
| 48 | +struct resize<cnc_multi_linestring<Linestring> > |
| 49 | +{ |
| 50 | + static void apply(cnc_multi_linestring<Linestring>& multi, std::size_t new_size) |
| 51 | + { |
| 52 | + multi.custom_resize(new_size); |
| 53 | + } |
| 54 | +}; |
| 55 | + |
| 56 | + |
| 57 | +}}} |
| 58 | + |
| 59 | +// 2a. Adapt to Boost.Range, meta-functions |
| 60 | +namespace boost |
| 61 | +{ |
| 62 | + |
| 63 | +template<typename Linestring> |
| 64 | +struct range_mutable_iterator<cnc_multi_linestring<Linestring> > |
| 65 | +{ |
| 66 | + using type = decltype(std::declval<cnc_multi_linestring<Linestring>>().custom_begin()); |
| 67 | +}; |
| 68 | + |
| 69 | +template<typename Linestring> |
| 70 | +struct range_const_iterator<cnc_multi_linestring<Linestring> > |
| 71 | +{ |
| 72 | + using type = decltype(std::declval<cnc_multi_linestring<Linestring>>().const_custom_begin()); |
| 73 | +}; |
| 74 | + |
| 75 | +} |
| 76 | + |
| 77 | +// 2b. Adapt to Boost.Range, part 2, ADP |
| 78 | +template<typename Linestring> |
| 79 | +auto range_begin(cnc_multi_linestring<Linestring>& geo) { return geo.custom_begin(); } |
| 80 | + |
| 81 | +template<typename Linestring> |
| 82 | +auto range_begin(cnc_multi_linestring<Linestring> const& geo) { return geo.const_custom_begin(); } |
| 83 | + |
| 84 | +template<typename Linestring> |
| 85 | +auto range_end(cnc_multi_linestring<Linestring>& geo) { return geo.custom_end(); } |
| 86 | + |
| 87 | +template<typename Linestring> |
| 88 | +auto range_end(cnc_multi_linestring<Linestring> const& geo) { return geo.const_custom_end(); } |
| 89 | + |
| 90 | +template<typename Linestring> |
| 91 | +std::size_t range_calculate_size(cnc_multi_linestring<Linestring> const& geo) { return geo.custom_size(); } |
| 92 | + |
| 93 | +#endif // GEOMETRY_TEST_ADAPT_CNC_MULTI_LINESTRING_HPP |
0 commit comments