alaCarte Maps
Renderer for OpenStreetMap tiles
mapcss_parser.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef MAPCSS_PARSER_HPP
23 #define MAPCSS_PARSER_HPP
24 
25 
26 #include "mapcss_def.hpp"
27 #include "mapcss_grammar.hpp"
28 #include "parser_logger.hpp"
29 
30 #include "server/rule.hpp"
31 
32 #include <boost/filesystem/path.hpp>
33 
34 class Geodata;
35 class Stylesheet;
36 
37 
38 
40 {
41  void addAttributeToTemplate(StylePtr& style, const shared_ptr<AttributeCreator>& attrType, const string& specifier, const ParseInfo& info);
42  void applyStyleToRules(std::vector<RulePtr>& rules, const StylePtr& style);
43  SelectorPtr createSelectorFromObjectType(const SelectorPtr& next, const shared_ptr<Rule>& rule, obj::ObjectTypeEnum objType, Rule::AcceptableTypes& type);
44  SelectorPtr createChildSelectorFromObjectType(const SelectorPtr& next, const shared_ptr<Rule>& rule, obj::ObjectTypeEnum objType);
45  SelectorPtr createSelectorFromUnaryCondition(const SelectorPtr& next, const shared_ptr<Rule>& rule, const UnaryCondition& condition);
46  SelectorPtr createSelectorFromBinaryCondition(const SelectorPtr& next, const shared_ptr<Rule>& rule, const BinaryCondition& condition);
47  SelectorPtr createSelectorFromCondition(const SelectorPtr& next, const shared_ptr<Rule>& rule, const ConditionType& condition);
48  RulePtr createSelectorChain(const std::vector<SelectorItem>& items);
49  void warnUnsupportedAttribute(const string& attribute) const;
50 
51  MapCssParser(const shared_ptr<Geodata>& geodata);
52  void load(const string& path);
53 
55  shared_ptr<Geodata> geodata;
57  shared_ptr<Stylesheet> parsedStylesheet;
61  shared_ptr<ParserLogger> logger;
62 };
63 
64 #endif
MapCssParser(const shared_ptr< Geodata > &geodata)
Initializes the parser.
SelectorPtr createChildSelectorFromObjectType(const SelectorPtr &next, const shared_ptr< Rule > &rule, obj::ObjectTypeEnum objType)
Creates a selector, selecting children of the specified type.
fsio::vector< op::UnaryTypesEnum, string > UnaryCondition
Stores informations about an unary condition.
SelectorPtr createSelectorFromBinaryCondition(const SelectorPtr &next, const shared_ptr< Rule > &rule, const BinaryCondition &condition)
Creates a selector using an binary operator.
SelectorPtr createSelectorFromCondition(const SelectorPtr &next, const shared_ptr< Rule > &rule, const ConditionType &condition)
Creates a selector for a given condition.
shared_ptr< Selector > SelectorPtr
Shortcut for a shared pointer to the base of all selectors.
Definition: mapcss_def.hpp:135
shared_ptr< Geodata > geodata
The geodata used to inject them in the rules.
Thrown if the parsing fails.
Definition: exceptions.hpp:85
shared_ptr< Stylesheet > parsedStylesheet
The parsed stylesheet.
A Stylesheet parses a given MapCSS Stylesheet file and stores the defined rules.
Definition: stylesheet.hpp:39
fsio::vector< string, op::BinaryTypesEnum, string > BinaryCondition
Stores informations about an binary condition.
shared_ptr< Rule > RulePtr
Shortcut for a shared pointer to rule.
Definition: mapcss_def.hpp:132
shared_ptr< StyleTemplate > StylePtr
Shortcut for a shared pointer to style.
Definition: mapcss_def.hpp:141
RulePtr createSelectorChain(const std::vector< SelectorItem > &items)
Creates a chain of selectors from given subselectors.
SelectorPtr createSelectorFromObjectType(const SelectorPtr &next, const shared_ptr< Rule > &rule, obj::ObjectTypeEnum objType, Rule::AcceptableTypes &type)
Creates an selector used to match geoobject types.
boost::variant< UnaryCondition, BinaryCondition > ConditionType
Possible Conditions.
void addAttributeToTemplate(StylePtr &style, const shared_ptr< AttributeCreator > &attrType, const string &specifier, const ParseInfo &info)
Converts a given string into a text position.
ObjectTypeEnum
Enum with object selectors.
Definition: mapcss_def.hpp:49
excp::ParseException catchedException
The exception that may be catched.
SelectorPtr createSelectorFromUnaryCondition(const SelectorPtr &next, const shared_ptr< Rule > &rule, const UnaryCondition &condition)
Creates a selector using an unary operator.
void applyStyleToRules(std::vector< RulePtr > &rules, const StylePtr &style)
Sets a given style as the style of given rules.
shared_ptr< ParserLogger > logger
Output logger for errors and warnings.
void load(const string &path)
Loads a file from the given path and tries to parse the content into a stylesheet.
void warnUnsupportedAttribute(const string &attribute) const
Emits a warning for unknown mapcss attribute.
AcceptableTypes
Definition: rule.hpp:38