write.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_MULTI_IO_DSV_WRITE_HPP
  11. #define BOOST_GEOMETRY_MULTI_IO_DSV_WRITE_HPP
  12. #include <boost/range.hpp>
  13. #include <boost/geometry/multi/core/tags.hpp>
  14. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  15. #include <boost/geometry/io/dsv/write.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail { namespace dsv
  20. {
  21. template <typename MultiGeometry>
  22. struct dsv_multi
  23. {
  24. typedef dispatch::dsv
  25. <
  26. typename single_tag_of
  27. <
  28. typename tag<MultiGeometry>::type
  29. >::type,
  30. typename boost::range_value<MultiGeometry>::type
  31. > dispatch_one;
  32. typedef typename boost::range_iterator
  33. <
  34. MultiGeometry const
  35. >::type iterator;
  36. template <typename Char, typename Traits>
  37. static inline void apply(std::basic_ostream<Char, Traits>& os,
  38. MultiGeometry const& multi,
  39. dsv_settings const& settings)
  40. {
  41. os << settings.list_open;
  42. bool first = true;
  43. for(iterator it = boost::begin(multi);
  44. it != boost::end(multi);
  45. ++it, first = false)
  46. {
  47. os << (first ? "" : settings.list_separator);
  48. dispatch_one::apply(os, *it, settings);
  49. }
  50. os << settings.list_close;
  51. }
  52. };
  53. }} // namespace detail::dsv
  54. #endif // DOXYGEN_NO_DETAIL
  55. #ifndef DOXYGEN_NO_DISPATCH
  56. namespace dispatch
  57. {
  58. template <typename Geometry>
  59. struct dsv<multi_tag, Geometry>
  60. : detail::dsv::dsv_multi<Geometry>
  61. {};
  62. } // namespace dispatch
  63. #endif // DOXYGEN_NO_DISPATCH
  64. }} // namespace boost::geometry
  65. #endif // BOOST_GEOMETRY_MULTI_IO_DSV_WRITE_HPP