alaCarte Maps
Renderer for OpenStreetMap tiles
parse_info_parser.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef _PARSE_INFO_PARSER_HPP
23 #define _PARSE_INFO_PARSER_HPP
24 
25 
26 #include "settings.hpp"
27 #include "parse_info.hpp"
28 #include "mapcss_def.hpp"
29 
30 namespace pip {
31 
32  BOOST_SPIRIT_TERMINAL(pinfo);
33 
34 }
35 
36 
38  (string, sourceline)
39  (unsigned int, column)
40  (unsigned int, line)
41  (string, linecontent)
42  );
43 
44 namespace boost { namespace spirit
45 {
46  // We want custom_parser::iter_pos to be usable as a terminal only,
47  // and only for parser expressions (qi::domain).
48  template <>
49  struct use_terminal<qi::domain, pip::tag::pinfo>
50  : mpl::true_
51  {};
52 }}
53 
54 
55 namespace pip {
56  struct pinfo_parser
57  : boost::spirit::qi::primitive_parser<pinfo_parser>
58  {
59  // Define the attribute type exposed by this parser component
60  template <typename Context, typename Iterator>
61  struct attribute
62  {
63  typedef ParseInfo type;
64  };
65 
66  // This function is called during the actual parsing process
67  template <typename WrappedIterator, typename Context
68  , typename Skipper, typename Attribute>
69  bool parse(classic::position_iterator2<WrappedIterator>& first, classic::position_iterator2<WrappedIterator> const& last
70  , Context&, Skipper const& skipper, Attribute& attr) const
71  {
72  boost::spirit::qi::skip_over(first, last, skipper);
73 
74  const classic::file_position_base<std::string>& pos = first.get_position();
75 
76  boost::spirit::traits::assign_to(ParseInfo(pos.file, pos.column, pos.line, first.get_currentline()), attr);
77  return true;
78  }
79 
80  // This function is called during error handling to create
81  // a human readable string for the error context.
82  template <typename Context>
83  boost::spirit::info what(Context&) const
84  {
85  return boost::spirit::info("pinfo_parser");
86  }
87  };
88 
89 }
90 
91 namespace boost { namespace spirit { namespace qi
92 {
93  // This is the factory function object invoked in order to create
94  // an instance of our iter_pos_parser.
95  template <typename Modifiers>
96  struct make_primitive<pip::tag::pinfo, Modifiers>
97  {
99 
100  result_type operator()(unused_type, unused_type) const
101  {
102  return result_type();
103  }
104  };
105 }}}
106 
107 
108 #endif
BOOST_FUSION_ADAPT_STRUCT(ParseInfo,(string, sourceline)(unsigned int, column)(unsigned int, line)(string, linecontent))
BOOST_SPIRIT_TERMINAL(pinfo)
boost::spirit::info what(Context &) const
result_type operator()(unused_type, unused_type) const
bool parse(classic::position_iterator2< WrappedIterator > &first, classic::position_iterator2< WrappedIterator > const &last, Context &, Skipper const &skipper, Attribute &attr) const