1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 // Tool reporting Implementation Support Status in QBK or plain text format 3 4 // Copyright (c) 2011-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. 6 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 11 #ifndef BOOST_GEOMETRY_SUPPORT_STATUS_QBK_OUTPUTTER_HPP 12 #define BOOST_GEOMETRY_SUPPORT_STATUS_QBK_OUTPUTTER_HPP 13 14 nameqbk_geometry_name15template <typename Tag> struct qbk_geometry_name { static inline std::string name() { return "Range"; } }; // TODO / make general nameqbk_geometry_name16template <> struct qbk_geometry_name<boost::geometry::point_tag> { static inline std::string name() { return "Point"; } }; nameqbk_geometry_name17template <> struct qbk_geometry_name<boost::geometry::segment_tag> { static inline std::string name() { return "Segment"; } }; nameqbk_geometry_name18template <> struct qbk_geometry_name<boost::geometry::box_tag> { static inline std::string name() { return "Box"; } }; nameqbk_geometry_name19template <> struct qbk_geometry_name<boost::geometry::linestring_tag> { static inline std::string name() { return "Linestring"; } }; nameqbk_geometry_name20template <> struct qbk_geometry_name<boost::geometry::ring_tag> { static inline std::string name() { return "Ring"; } }; nameqbk_geometry_name21template <> struct qbk_geometry_name<boost::geometry::polygon_tag> { static inline std::string name() { return "Polygon"; } }; nameqbk_geometry_name22template <> struct qbk_geometry_name<boost::geometry::multi_point_tag> { static inline std::string name() { return "MultiPoint"; } }; nameqbk_geometry_name23template <> struct qbk_geometry_name<boost::geometry::multi_linestring_tag> { static inline std::string name() { return "MultiLinestring"; } }; nameqbk_geometry_name24template <> struct qbk_geometry_name<boost::geometry::multi_polygon_tag> { static inline std::string name() { return "MultiPolygon"; } }; 25 26 27 struct qbk_table_row_header 28 { 29 std::ofstream& m_out; 30 qbk_table_row_headerqbk_table_row_header31 qbk_table_row_header(std::ofstream& out) 32 : m_out(out) 33 {} 34 35 template <typename G> operator ()qbk_table_row_header36 void operator()(G) 37 { 38 m_out 39 << "[" 40 << qbk_geometry_name 41 < 42 typename boost::geometry::tag<G>::type 43 >::name() 44 << "]"; 45 } 46 }; 47 48 struct qbk_outputter 49 { 50 std::ofstream m_out; 51 filenameqbk_outputter52 std::string filename(std::string const& name) 53 { 54 std::ostringstream out; 55 out << "../../../../generated/" << name << "_status.qbk"; 56 return out.str(); 57 } 58 qbk_outputterqbk_outputter59 explicit qbk_outputter(std::string const& name) 60 : m_out(filename(name).c_str()) 61 { 62 } 63 okqbk_outputter64 inline void ok() { m_out << "[ [$img/ok.png] ]"; } nyiqbk_outputter65 inline void nyi() { m_out << "[ [$img/nyi.png] ]"; } 66 headerqbk_outputter67 inline void header(std::string const& ) 68 { 69 m_out << "[heading Supported geometries]" << std::endl; 70 } 71 72 template <typename Types> table_headerqbk_outputter73 inline void table_header() 74 { 75 m_out << "[table" << std::endl << "[[ ]"; 76 boost::mpl::for_each<Types>(qbk_table_row_header(m_out)); 77 m_out << "]" << std::endl; 78 } table_headerqbk_outputter79 inline void table_header() 80 { 81 m_out << "[table" << std::endl << "[[Geometry][Status]]" << std::endl; 82 } 83 table_footerqbk_outputter84 inline void table_footer() 85 { 86 m_out << "]" << std::endl; 87 } 88 89 template <typename G> begin_rowqbk_outputter90 inline void begin_row() 91 { 92 m_out 93 << "[[" 94 << qbk_geometry_name 95 < 96 typename boost::geometry::tag<G>::type 97 >::name() 98 << "]" 99 ; 100 } 101 end_rowqbk_outputter102 inline void end_row() 103 { 104 m_out << "]" << std::endl; 105 } 106 107 }; 108 109 110 #endif // BOOST_GEOMETRY_SUPPORT_STATUS_QBK_OUTPUTTER_HPP 111