Added optional flag to base iterator

Added closing iterator
Added closeable_view


[SVN r61760]
This commit is contained in:
Barend Gehrels 2010-05-04 15:49:16 +00:00
parent 7380fda632
commit d6d33fbd38
19 changed files with 1082 additions and 5 deletions

View File

@ -18,11 +18,16 @@
namespace boost { namespace geometry { namespace detail { namespace iterators
{
template <typename T, typename Iterator>
struct iterator_base :
public boost::iterator_adaptor
template
<
typename DerivedClass,
typename Iterator,
typename TraversalFlag = boost::bidirectional_traversal_tag
>
struct iterator_base
: public boost::iterator_adaptor
<
T,
DerivedClass,
Iterator,
boost::use_default,
typename boost::mpl::if_
@ -32,7 +37,7 @@ struct iterator_base :
typename boost::iterator_traversal<Iterator>::type,
boost::random_access_traversal_tag
>,
boost::bidirectional_traversal_tag,
TraversalFlag,
boost::use_default
>::type
>

View File

@ -0,0 +1,98 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 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_ITERATORS_CLOSING_ITERATOR_HPP
#define BOOST_GEOMETRY_ITERATORS_CLOSING_ITERATOR_HPP
#include <boost/range.hpp>
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/geometry/iterators/base.hpp>
namespace boost { namespace geometry
{
/*!
\brief Iterator which iterates through a range, but adds first element at end of the range
\tparam Range range on which this class is based on
\ingroup iterators
\note Use with "closing_iterator<Range> or "closing_iterator<Range const>
to get non-const / const behaviour
\note This class is normally used from "closeable_view" if Close==true
*/
template <typename Range>
struct closing_iterator
: public detail::iterators::iterator_base
<
closing_iterator<Range>,
typename boost::range_iterator<Range>::type,
boost::forward_traversal_tag
>
{
friend class boost::iterator_core_access;
explicit inline closing_iterator(Range& range)
: m_range(range)
, m_beyond(false)
, m_end(boost::end(m_range))
{
this->base_reference() = boost::begin(m_range);
}
// Constructor to indicate the end of a range
explicit inline closing_iterator(Range& range, bool)
: m_range(range)
, m_beyond(true)
, m_end(boost::end(m_range))
{
this->base_reference() = m_end;
}
//inline bool equal(closing_iterator const& other) const
inline bool operator==(closing_iterator const& other) const
{
return this->base() == other->base()
&& this->m_beyond == other->m_beyond;
}
private:
inline void increment()
{
if (m_beyond)
{
this->base_reference() = m_end;
}
else if (this->base() != m_end)
{
(this->base_reference())++;
if (this->base() == m_end)
{
// Now beyond last position -> set to "begin" again
// and set flag "beyond" such that next increment
// will finish traversal
this->base_reference() = boost::begin(m_range);
m_beyond = true;
}
}
}
Range& m_range;
bool m_beyond;
typename boost::range_iterator<Range>::type m_end;
};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ITERATORS_CLOSING_ITERATOR_HPP

View File

@ -0,0 +1,74 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 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_UTIL_CLOSEABLE_VIEW_HPP
#define BOOST_GEOMETRY_UTIL_CLOSEABLE_VIEW_HPP
#include <boost/range.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/iterators/closing_iterator.hpp>
namespace boost { namespace geometry
{
template <typename Range, bool Close>
struct closeable_view {};
template <typename Range>
struct closeable_view<Range, false>
{
closeable_view(Range& r)
: m_range(r)
{}
typedef typename boost::range_iterator<Range const>::type const_iterator;
typedef typename boost::range_iterator<Range>::type iterator;
const_iterator begin() const { return boost::begin(m_range); }
const_iterator end() const { return boost::end(m_range); }
iterator begin() { return boost::begin(m_range); }
iterator end() { return boost::end(m_range); }
private :
Range& m_range;
};
template <typename Range>
struct closeable_view<Range, true>
{
closeable_view(Range& r)
: m_range(r)
{}
typedef closing_iterator<Range> iterator;
typedef closing_iterator<Range const> const_iterator;
const_iterator begin() const { return const_iterator(m_range); }
const_iterator end() const { return const_iterator(m_range, true); }
iterator begin() { return iterator(m_range); }
iterator end() { return iterator(m_range, true); }
private :
Range& m_range;
};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_UTIL_CLOSEABLE_VIEW_HPP

View File

@ -9,6 +9,7 @@
test-suite ggl-iterators
:
[ run circular_iterator.cpp ]
[ run closing_iterator.cpp ]
[ run ever_circling_iterator.cpp ]
[ run segment_iterator.cpp ]
;

View File

@ -0,0 +1,90 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) test file
//
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands
// Copyright Bruno Lalande 2008, 2009
// 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)
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <geometry_test_common.hpp>
#include <boost/geometry/iterators/closing_iterator.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
template <typename Geometry>
void test_geometry(std::string const& wkt)
{
Geometry geometry;
boost::geometry::read_wkt(wkt, geometry);
typedef boost::geometry::closing_iterator<Geometry const> closing_iterator;
// 1. Test normal behaviour
{
closing_iterator it(geometry);
closing_iterator end(geometry, true);
std::ostringstream out;
for (; it != end; ++it)
{
out << " " << boost::geometry::get<0>(*it) << boost::geometry::get<1>(*it);
}
BOOST_CHECK_EQUAL(out.str(), " 11 14 44 41 11");
// All the following does NOT compile, and should NOT,
// 1) Because it is forward only:
//it--;
//--it;
// 2) Because it is not random access:
//it += 2;
//it = boost::begin(geometry);
}
// 2: check copy behaviour
{
typedef typename boost::range_iterator<Geometry const>::type normal_iterator;
Geometry copy;
std::copy<closing_iterator>(
closing_iterator(geometry),
closing_iterator(geometry, true),
std::back_inserter(copy));
std::ostringstream out;
for (normal_iterator cit = boost::begin(copy); cit != boost::end(copy); ++cit)
{
out << " " << boost::geometry::get<0>(*cit) << boost::geometry::get<1>(*cit);
}
BOOST_CHECK_EQUAL(out.str(), " 11 14 44 41 11");
}
}
template <typename P>
void test_all()
{
test_geometry<boost::geometry::linear_ring<P> >("POLYGON((1 1,1 4,4 4,4 1))");
}
int test_main(int, char* [])
{
test_all<boost::geometry::point_2d>();
return 0;
}

View File

@ -0,0 +1,178 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="closing_iterator"
ProjectGUID="{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}"
RootNamespace="closing_iterator"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\closing_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\closing_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\closing_iterator.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -8,6 +8,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_iterator", "segment
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ggl_headers", "..\ggl_headers.vcproj", "{B3B37654-5AB4-49F3-A1D3-DFDE73EA5E1A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "closing_iterator", "closing_iterator.vcproj", "{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -30,6 +32,10 @@ Global
{B3B37654-5AB4-49F3-A1D3-DFDE73EA5E1A}.Debug|Win32.Build.0 = Debug|Win32
{B3B37654-5AB4-49F3-A1D3-DFDE73EA5E1A}.Release|Win32.ActiveCfg = Release|Win32
{B3B37654-5AB4-49F3-A1D3-DFDE73EA5E1A}.Release|Win32.Build.0 = Release|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Debug|Win32.ActiveCfg = Debug|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Debug|Win32.Build.0 = Debug|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Release|Win32.ActiveCfg = Release|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -12,4 +12,7 @@ test-suite ggl-util
[ run for_each_coordinate.cpp ]
[ run select_most_precise.cpp ]
[ run write_dsv.cpp ]
[ run reversible_view.cpp ]
[ run closeable_view.cpp ]
[ run reversible_closeable.cpp ]
;

View File

@ -46,6 +46,7 @@
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -0,0 +1,74 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) test file
//
// Copyright Barend Gehrels 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)
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <geometry_test_common.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
#include <boost/geometry/util/write_dsv.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/tuple_cartesian.hpp>
template <bool Close, typename Range>
void test_optionally_closing(Range const& range, std::string const& expected)
{
typedef boost::geometry::closeable_view<Range const, Close> view_type;
typedef typename boost::range_iterator<view_type const>::type iterator;
view_type view(range);
bool first = true;
std::ostringstream out;
iterator end = boost::end(view);
for (iterator it = boost::begin(view); it != end; ++it, first = false)
{
out << (first ? "" : " ") << boost::geometry::dsv(*it);
}
BOOST_CHECK_EQUAL(out.str(), expected);
}
template <typename Geometry>
void test_geometry(std::string const& wkt,
std::string const& expected_false,
std::string const& expected_true)
{
namespace bg = boost::geometry;
Geometry geo;
bg::read_wkt(wkt, geo);
test_optionally_closing<false>(geo, expected_false);
test_optionally_closing<true>(geo, expected_true);
}
template <typename P>
void test_all()
{
test_geometry<boost::geometry::linear_ring<P> >(
"POLYGON((1 1,1 4,4 4,4 1))",
"(1, 1) (1, 4) (4, 4) (4, 1)",
"(1, 1) (1, 4) (4, 4) (4, 1) (1, 1)");
}
int test_main(int, char* [])
{
namespace bg = boost::geometry;
test_all<bg::point_2d>();
test_all<bg::point<int, 2, bg::cs::cartesian> >();
test_all<boost::tuple<double, double> >();
return 0;
}

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="closeable_view"
ProjectGUID="{5C40995A-B6FC-4C94-B552-0D80EC9E2049}"
RootNamespace="closeable_view"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\closeable_view"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\closeable_view"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\closeable_view.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -46,6 +46,7 @@
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -46,6 +46,7 @@
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -0,0 +1,178 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) test file
//
// Copyright Barend Gehrels 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)
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <geometry_test_common.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
#include <boost/geometry/util/write_dsv.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/adapted/tuple_cartesian.hpp>
template <typename View, typename Range>
void test_option(Range const& range, std::string const& expected)
{
typedef typename boost::range_iterator<View const>::type iterator;
View view(range);
bool first = true;
std::ostringstream out;
iterator end = boost::end(view);
for (iterator it = boost::begin(view); it != end; ++it, first = false)
{
out << (first ? "" : " ") << boost::geometry::dsv(*it);
}
BOOST_CHECK_EQUAL(out.str(), expected);
}
template <bool Close, boost::geometry::iterate_direction Direction, typename Range>
void test_close_reverse(Range const& range, std::string const& expected)
{
namespace bg = boost::geometry;
test_option
<
bg::closeable_view
<
bg::reversible_view<Range const, Direction> const,
Close
>
>(range, expected);
}
/*
This should NOT compile, or at least not instantiate
Use the code as above, so reversible_view should be nested inside closeable_view
template <boost::geometry::iterate_direction Direction, bool Close, typename Range>
void test_reverse_close(Range const& range, std::string const& expected)
{
namespace bg = boost::geometry;
test_option
<
bg::reversible_view
<
bg::closeable_view<Range const, Close> const,
Direction
>
>(range, expected);
}
*/
template
<
boost::geometry::iterate_direction Direction1,
boost::geometry::iterate_direction Direction2,
typename Range
>
void test_reverse_reverse(Range const& range, std::string const& expected)
{
namespace bg = boost::geometry;
test_option
<
bg::reversible_view
<
bg::reversible_view<Range const, Direction2> const,
Direction1
>
>(range, expected);
}
template
<
bool Close1,
bool Close2,
typename Range
>
void test_close_close(Range const& range, std::string const& expected)
{
namespace bg = boost::geometry;
test_option
<
bg::closeable_view
<
bg::closeable_view<Range const, Close2> const,
Close1
>
>(range, expected);
}
template <typename Geometry>
void test_geometry(std::string const& wkt,
std::string const& expected_1,
std::string const& expected_2,
std::string const& expected_3,
std::string const& expected_4,
std::string const& expected_cc
)
{
namespace bg = boost::geometry;
Geometry geo;
bg::read_wkt(wkt, geo);
test_close_reverse<false, bg::iterate_forward>(geo, expected_1);
test_close_reverse<true, bg::iterate_forward>(geo, expected_2);
test_close_reverse<false, bg::iterate_reverse>(geo, expected_3);
test_close_reverse<true, bg::iterate_reverse>(geo, expected_4);
/*
This should NOT compile on purpose
Because the closing_iterator can only be used forward
test_reverse_close<bg::iterate_forward, false>(geo, expected_1);
test_reverse_close<bg::iterate_forward, true>(geo, expected_2);
test_reverse_close<bg::iterate_reverse, false>(geo, expected_3);
test_reverse_close<bg::iterate_reverse, true>(geo, expected_4);
*/
test_reverse_reverse<bg::iterate_forward, bg::iterate_forward>(geo, expected_1);
test_reverse_reverse<bg::iterate_reverse, bg::iterate_reverse>(geo, expected_1);
test_close_close<false, false>(geo, expected_1);
test_close_close<true, false>(geo, expected_2);
test_close_close<false, true>(geo, expected_2);
// Does not compile - no assignment operator
// Ranges basically support nesting, but the closing iterator does not.
// It is not necessary for the closing iterator to do so.
//test_close_close<true, true>(geo, expected_cc);
}
template <typename P>
void test_all()
{
test_geometry<boost::geometry::linear_ring<P> >(
"POLYGON((1 1,1 4,4 4,4 1))",
"(1, 1) (1, 4) (4, 4) (4, 1)",
"(1, 1) (1, 4) (4, 4) (4, 1) (1, 1)",
"(4, 1) (4, 4) (1, 4) (1, 1)",
"(4, 1) (4, 4) (1, 4) (1, 1) (4, 1)",
"(1, 1) (1, 4) (4, 4) (4, 1) (1, 1) (1, 1)" // closed twice, not used
);
}
int test_main(int, char* [])
{
namespace bg = boost::geometry;
test_all<bg::point_2d>();
test_all<bg::point<int, 2, bg::cs::cartesian> >();
test_all<boost::tuple<double, double> >();
return 0;
}

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="reversible_closeable"
ProjectGUID="{AAA72638-34CD-4A34-8329-984DFC766E24}"
RootNamespace="reversible_closeable"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\reversible_closeable"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\reversible_closeable"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\reversible_closeable.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -47,6 +47,7 @@
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -46,6 +46,7 @@
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -12,6 +12,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "as_range", "as_range.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reversible_view", "reversible_view.vcproj", "{BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "closeable_view", "closeable_view.vcproj", "{5C40995A-B6FC-4C94-B552-0D80EC9E2049}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reversible_closeable", "reversible_closeable.vcproj", "{AAA72638-34CD-4A34-8329-984DFC766E24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -42,6 +46,14 @@ Global
{BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}.Debug|Win32.Build.0 = Debug|Win32
{BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}.Release|Win32.ActiveCfg = Release|Win32
{BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}.Release|Win32.Build.0 = Release|Win32
{5C40995A-B6FC-4C94-B552-0D80EC9E2049}.Debug|Win32.ActiveCfg = Debug|Win32
{5C40995A-B6FC-4C94-B552-0D80EC9E2049}.Debug|Win32.Build.0 = Debug|Win32
{5C40995A-B6FC-4C94-B552-0D80EC9E2049}.Release|Win32.ActiveCfg = Release|Win32
{5C40995A-B6FC-4C94-B552-0D80EC9E2049}.Release|Win32.Build.0 = Release|Win32
{AAA72638-34CD-4A34-8329-984DFC766E24}.Debug|Win32.ActiveCfg = Debug|Win32
{AAA72638-34CD-4A34-8329-984DFC766E24}.Debug|Win32.Build.0 = Debug|Win32
{AAA72638-34CD-4A34-8329-984DFC766E24}.Release|Win32.ActiveCfg = Release|Win32
{AAA72638-34CD-4A34-8329-984DFC766E24}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -46,6 +46,7 @@
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"