23 #include <boost/spirit/include/qi.hpp> 24 #include <boost/spirit/include/phoenix_core.hpp> 25 #include <boost/spirit/include/phoenix_operator.hpp> 26 #include <boost/spirit/include/phoenix_fusion.hpp> 27 #include <boost/spirit/include/phoenix_object.hpp> 28 #include <boost/spirit/include/phoenix_stl.hpp> 29 #include <boost/spirit/include/phoenix_bind.hpp> 30 #include <boost/spirit/include/phoenix.hpp> 44 template<
typename Type>
57 void addAttribute(
const shared_ptr<StyleTemplate>& styleTemplate,
const string& specifier,
const shared_ptr<ParserLogger>& logger,
const ParseInfo& info)
59 assert(styleTemplate);
67 template<
typename Type>
70 return boost::make_shared< SpecificAttributeCreator<Type> >(attr);
135 void AppendVector(std::vector<T>& target,
const std::vector<T>& append)
137 target.insert(target.end(), append.begin(), append.end());
146 :
MapCSSGrammar::base_type(rule_stylesheet,
"MapCSS-MainGrammar")
148 using namespace qi::labels;
152 rule_tag %= +qi::char_(
"a-zA-Z_0-9:-");
153 rule_value %= +qi::char_(
"a-zA-Z_0-9./-") | (
'\"' >> +(qi::char_ -
'\"') >>
'\"') | (
'\'' >> +(qi::char_ -
'\'') >>
'\'');
159 rule_specifier = (
'\"' > +(qi::char_ -
'\"') >
'\"' ) | +(qi::char_ -
';' -
'}');
161 _val = phx::construct<StylePtr>(phx::new_<StyleTemplate>())
166 >
':' > pip::pinfo[_b = _1]
180 > ((-uint_[_a = _1] >>
'-' >> -uint_[_b = _1])
181 | (uint_[_a = _b = _1]))
182 >> qi::eps[_val = phx::construct<Zoom>(_a,_b)];
195 phx::push_back(phx::at_c<2>(_val), _1)
218 phx::bind(&AppendVector<RulePtr>, _a, _1)
232 qi::_val = phx::construct<StylesheetPtr>(phx::new_<Stylesheet>(phx::ref(parser.
geodata), _a, _b))
shared_ptr< eval::Eval< float > > icon_opacity
shared_ptr< eval::Eval< Style::LineJoin > > linejoin
shared_ptr< eval::Eval< float > > shield_opacity
shared_ptr< eval::Eval< Color > > color
qi::rule< ItType, StylePtr(), qi::locals< shared_ptr< AttributeCreator >, ParseInfo >, Skipper > rule_styleset
Rule to parse a styleset of a rule.
shared_ptr< eval::Eval< MaybeCachedString > > text
void AppendVector(std::vector< T > &target, const std::vector< T > &append)
Appends a vector to another.
qi::rule< ItType, Zoom(), qi::locals< int, int >, Skipper > rule_zoom
Rule to parse a zoom range.
shared_ptr< eval::Eval< Style::FontWeight > > font_weight
A StyleTemplate is the "raw" / "unevaluated" form of a Style specified by a single MapCSS rule...
shared_ptr< eval::Eval< Type > > StyleTemplate::* attr_member
The grammar for the mapcss format.
qi::rule< ItType, std::vector< RulePtr >), Skipper > rule_cssrule
Rule to parse one rule. Returns a list of rules, because selectors can be splited.
shared_ptr< eval::Eval< float > > casing_width
shared_ptr< Geodata > geodata
The geodata used to inject them in the rules.
shared_ptr< eval::Eval< float > > text_halo_radius
This file is part of alaCarte.
shared_ptr< eval::Eval< Style::LineCap > > linecap
shared_ptr< eval::Eval< float > > font_size
shared_ptr< eval::Eval< float > > shield_frame_width
AttributeTypes attributeType_
The symbol parser for style attributes.
void addAttribute(const shared_ptr< StyleTemplate > &styleTemplate, const string &specifier, const shared_ptr< ParserLogger > &logger, const ParseInfo &info)
shared_ptr< eval::Eval< Style::LineJoin > > casing_linejoin
shared_ptr< eval::Eval< float > > shield_casing_width
qi::rule< ItType, string(), Skipper > rule_specifier
Rule to parse the specifier.
shared_ptr< SpecificAttributeCreator< Type > > CreateAttribute(shared_ptr< eval::Eval< Type > > StyleTemplate::*attr)
shared_ptr< eval::Eval< Color > > shield_frame_color
qi::rule< ItType, string()> rule_tag
Rule to parse a tag.
shared_ptr< eval::Eval< std::vector< double > > > dashes
shared_ptr< eval::Eval< Color > > text_color
SpecificAttributeCreator(attr_member member)
shared_ptr< eval::Eval< Color > > casing_color
ObjectTypes selectorObject_
The symbol parser for objects.
qi::rule< ItType, RulePtr(), qi::locals< std::vector< SelectorItem > >, Skipper > rule_selector
Rule to parse a selector.
RulePtr createSelectorChain(const std::vector< SelectorItem > &items)
Creates a chain of selectors from given subselectors.
shared_ptr< eval::Eval< float > > width
shared_ptr< eval::Eval< MaybeCachedString > > shield_text
qi::rule< ItType, string()> rule_value
Rule to parse a value.
shared_ptr< eval::Eval< float > > icon_height
shared_ptr< eval::Eval< MaybeCachedString > > fill_image
void addAttributeToTemplate(StylePtr &style, const shared_ptr< AttributeCreator > &attrType, const string &specifier, const ParseInfo &info)
Converts a given string into a text position.
qi::rule< ItType, SelectorItem(), Skipper > rule_subselector
Rule to parse one part of the selector.
shared_ptr< eval::Eval< MaybeCachedString > > image
shared_ptr< eval::Eval< int > > z_index
UnaryTypes unaryOperator_
The symbol parser for unary operators.
Represents a value in a style template.
void applyStyleToRules(std::vector< RulePtr > &rules, const StylePtr &style)
Sets a given style as the style of given rules.
shared_ptr< eval::Eval< MaybeCachedString > > font_family
BinaryTypes binaryOperator_
The symbol parser for binary operators.
shared_ptr< eval::Eval< Style::ShieldShape > > shield_shape
shared_ptr< eval::Eval< Color > > shield_casing_color
shared_ptr< eval::Eval< Style::FontStyle > > font_style
shared_ptr< eval::Eval< MaybeCachedString > > icon_image
qi::rule< ItType, string(), Skipper > attribute_name
Rule to parse generic (unknown) attribute name.
shared_ptr< eval::Eval< Color > > text_halo_color
shared_ptr< eval::Eval< float > > icon_width
shared_ptr< eval::Eval< float > > text_offset
qi::rule< ItType, BinaryCondition()> rule_binary_condition
Rule to parse a binary condition.
shared_ptr< eval::Eval< MaybeCachedString > > shield_image
shared_ptr< eval::Eval< Color > > shield_color
shared_ptr< eval::Eval< Color > > fill_color
shared_ptr< eval::Eval< Style::TextPosition > > text_position
MapCSSGrammar(MapCssParser &parser)
Creates all rules for the mapcss grammar.
void warnUnsupportedAttribute(const string &attribute) const
Emits a warning for unknown mapcss attribute.
shared_ptr< eval::Eval< std::vector< double > > > casing_dashes
qi::rule< ItType, StylesheetPtr(), qi::locals< std::vector< RulePtr >, StylePtr >, Skipper > rule_stylesheet
Main rule returning a stylesheet.
qi::rule< ItType, UnaryCondition()> rule_unary_condition
Rule to parse a unary condition.
shared_ptr< eval::Eval< Style::LineCap > > casing_linecap