diff --git a/include/boost/geometry/views/closeable_view.hpp b/include/boost/geometry/views/closeable_view.hpp new file mode 100644 index 000000000..e90501dab --- /dev/null +++ b/include/boost/geometry/views/closeable_view.hpp @@ -0,0 +1,94 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to 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) + +#ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP +#define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP + + +#include + +#include +#include +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL + +namespace detail +{ + +template +struct closing_view +{ + // Keep this explicit, important for nested views/ranges + explicit inline closing_view(Range& r) + : m_range(r) + {} + + + typedef closing_iterator iterator; + typedef closing_iterator const_iterator; + + inline const_iterator begin() const { return const_iterator(m_range); } + inline const_iterator end() const { return const_iterator(m_range, true); } + + inline iterator begin() { return iterator(m_range); } + inline iterator end() { return iterator(m_range, true); } +private : + Range& m_range; +}; + +} + +#endif // DOXYGEN_NO_DETAIL + + +/*! +\brief View on a range, either closing or not closing +\tparam Range original range +\tparam Close specifying if it should be closed or not +\ingroup ranges +*/ +template +struct closeable_view {}; + + +#ifndef DOXYGEN_NO_SPECIALIZATIONS + +template +struct closeable_view +{ + typedef identity_view type; +}; + + +template +struct closeable_view +{ + typedef detail::closing_view type; +}; + +#endif // DOXYGEN_NO_SPECIALIZATIONS + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP diff --git a/include/boost/geometry/views/identity_view.hpp b/include/boost/geometry/views/identity_view.hpp new file mode 100644 index 000000000..f29e9778c --- /dev/null +++ b/include/boost/geometry/views/identity_view.hpp @@ -0,0 +1,53 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to 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) + +#ifndef BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP +#define BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP + + +#include + + +namespace boost { namespace geometry +{ + + +/*! +\brief View on a range, not modifying anything +\tparam Range original range +\ingroup ranges +*/ +template +struct identity_view +{ + typedef typename boost::range_iterator::type const_iterator; + typedef typename boost::range_iterator::type iterator; + + explicit inline identity_view(Range& r) + : m_range(r) + {} + + inline const_iterator begin() const { return boost::begin(m_range); } + inline const_iterator end() const { return boost::end(m_range); } + + inline iterator begin() { return boost::begin(m_range); } + inline iterator end() { return boost::end(m_range); } +private : + Range& m_range; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP diff --git a/include/boost/geometry/views/reversible_view.hpp b/include/boost/geometry/views/reversible_view.hpp new file mode 100644 index 000000000..96d1430b9 --- /dev/null +++ b/include/boost/geometry/views/reversible_view.hpp @@ -0,0 +1,74 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to 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) + +#ifndef BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP +#define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP + + +#include +#include +#include + +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + +/*! +\brief Flag for iterating a reversible_view in forward or reverse direction +\ingroup ranges +*/ +enum iterate_direction { iterate_forward, iterate_reverse }; + +/*! +\brief View on a range, reversing direction if necessary +\tparam Range original range +\tparam Direction direction of iteration +\ingroup ranges +*/ +template +struct reversible_view {}; + + + +#ifndef DOXYGEN_NO_SPECIALIZATIONS + +template +struct reversible_view +{ + typedef identity_view type; +}; + + +template +struct reversible_view +{ +#if BOOST_VERSION > 104500 + typedef boost::reversed_range type; +#else + // For older versions of Boost + typedef boost::range_detail::reverse_range type; +#endif +}; + +#endif // DOXYGEN_NO_SPECIALIZATIONS + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP