Debian Codegraph @

tests/svgpp_document_traverser.cpp

raw
1 // The pre-processed boost::mpl::set allows only 20 elements, but we need more
2 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
3 #define BOOST_MPL_LIMIT_SET_SIZE 40
4
5 #include <rapidxml_ns/rapidxml_ns.hpp>
6 #include <svgpp/policy/xml/rapidxml_ns.hpp>
7 #ifdef __GNUC__
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wdeprecated"
10 #endif
11 #include <svgpp/svgpp.hpp>
12 #ifdef __GNUC__
13 #pragma GCC diagnostic pop
14 #endif
15
16 #include "svgpp_context.h"
17 #include "svgpp_document_traverser.h"
18
19 // most of this is taken from
20 // http://svgpp.org/lesson01.html#handling-shapes-geometry
21
22 void traverseDocumentWithSvgpp(SvgppContext &context, char *text) {
23 rapidxml_ns::xml_document<> doc;
24 doc.parse<0>(text);
25 if (rapidxml_ns::xml_node<> *svg_element = doc.first_node("svg")) {
26 const rapidxml_ns::xml_node<> *xml_root_element = svg_element;
27
28 using processed_elements_t = boost::mpl::set<
29 // SVG Structural Elements
30 svgpp::tag::element::svg, svgpp::tag::element::g,
31 // SVG Shape Elements
32 svgpp::tag::element::circle, svgpp::tag::element::ellipse,
33 svgpp::tag::element::line, svgpp::tag::element::path,
34 svgpp::tag::element::polygon, svgpp::tag::element::polyline,
35 svgpp::tag::element::rect, svgpp::tag::element::text,
36 svgpp::tag::element::title>::type;
37
38 using processed_attributes_t =
39 boost::mpl::set<svgpp::traits::shapes_attributes_by_element,
40 svgpp::tag::attribute::class_, //
41 svgpp::tag::attribute::cx, //
42 svgpp::tag::attribute::cy, //
43 svgpp::tag::attribute::d, //
44 svgpp::tag::attribute::fill, //
45 svgpp::tag::attribute::fill_opacity, //
46 svgpp::tag::attribute::font_family, //
47 svgpp::tag::attribute::font_size, //
48 svgpp::tag::attribute::height, //
49 svgpp::tag::attribute::id, //
50 svgpp::tag::attribute::points, //
51 svgpp::tag::attribute::rx, //
52 svgpp::tag::attribute::ry, //
53 svgpp::tag::attribute::stroke, //
54 svgpp::tag::attribute::stroke_opacity, //
55 svgpp::tag::attribute::stroke_width, //
56 svgpp::tag::attribute::text_anchor, //
57 svgpp::tag::attribute::transform, //
58 svgpp::tag::attribute::viewBox, //
59 svgpp::tag::attribute::width, //
60 svgpp::tag::attribute::x, //
61 svgpp::tag::attribute::y //
62 >::type;
63
64 svgpp::document_traversal<
65 svgpp::processed_elements<processed_elements_t>,
66 svgpp::processed_attributes<processed_attributes_t>,
67 svgpp::basic_shapes_policy<svgpp::policy::basic_shapes::raw>>::
68 load_document(xml_root_element, context);
69 }
70 }