alaCarte Maps
Renderer for OpenStreetMap tiles
color_grammar.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef COLOR_GRAMMAR_HPP
23 #define COLOR_GRAMMAR_HPP
24 
25 #include <boost/spirit/home/qi/string/tst.hpp>
26 #include <boost/spirit/home/qi/string/tst_map.hpp>
27 
28 #include "settings.hpp"
29 #include "comment_skipper.hpp"
30 #include "mapcss_def.hpp"
31 
32 namespace spirit = boost::spirit;
33 namespace qi = spirit::qi;
34 namespace classic = boost::spirit::classic;
35 namespace phx = boost::phoenix;
36 namespace chs = spirit::standard;
37 
38 
39 
40 
42 struct ColorSymbols : qi::symbols<char, Color, qi::tst_map<char, Color> >
43 {
44  ColorSymbols();
45 };
46 
47 
58 struct ColorGrammar : public qi::grammar<StringIterator, Color(), chs::space_type>
59 {
63  typedef chs::space_type Skipper;
64 
65 
67  qi::uint_parser<uint8, 10, 1, 3> number;
69  qi::uint_parser<uint8, 16, 1, 1> hexdigit;
72 
73  ColorGrammar();
74 
76  qi::rule<ItType, uint8(), qi::locals<uint8, uint8> > rule_hexvalue;
78  qi::rule<ItType, Color(), qi::locals<uint8, uint8, uint8, uint8> > rule_hexcolor;
80  qi::rule<ItType, Color(), qi::locals<float, float>, Skipper> rule_rgb;
82  qi::rule<ItType, Color(), qi::locals<float, float, float>, Skipper> rule_rgba;
84  qi::rule<ItType, Color(), Skipper> rule_color;
85 };
86 
87 
88 
89 
90 
91 
92 
93 #endif
A grammar to parse a mapcss color.
qi::rule< ItType, uint8(), qi::locals< uint8, uint8 > > rule_hexvalue
Rule to parse the hex color code.
StringIterator ItType
Iterator type for this grammar.
ColorSymbols()
This file is part of alaCarte.
symbols for the binary operators
qi::uint_parser< uint8, 10, 1, 3 > number
Rule to parse a number with up to 3 digits.
qi::uint_parser< uint8, 16, 1, 1 > hexdigit
Rule to parse a hex digit.
qi::rule< ItType, Color(), qi::locals< float, float >, Skipper > rule_rgb
Rule for rgb(...)
qi::rule< ItType, Color(), qi::locals< float, float, float >, Skipper > rule_rgba
Rule for rgba(...)
ColorSymbols colorSymbol_
Symbol parser for colors.
qi::rule< ItType, Color(), Skipper > rule_color
Mainrule.
chs::space_type Skipper
Skipper type used in this grammar.
std::string::const_iterator StringIterator
Iterator to iterate over a file.
Definition: mapcss_def.hpp:146
qi::rule< ItType, Color(), qi::locals< uint8, uint8, uint8, uint8 > > rule_hexcolor
Rule for #COLORCODE.