refactor expression and value type usage to speed up compile time
This commit is contained in:
parent
501fd64194
commit
b5c06965ac
36 changed files with 173 additions and 307 deletions
|
@ -24,7 +24,7 @@
|
|||
#define MAPNIK_ATTRIBUTE_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
// stl
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/expression_grammar.hpp>
|
||||
#include <mapnik/expression_node_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
@ -35,13 +37,14 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
// fwd declare to reduce compile time
|
||||
template <typename Iterator> struct expression_grammar;
|
||||
typedef boost::shared_ptr<expr_node> expression_ptr;
|
||||
typedef std::set<expression_ptr> expression_set;
|
||||
|
||||
|
||||
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, std::string const& encoding = "UTF8");
|
||||
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt,
|
||||
mapnik::expression_grammar<std::string::const_iterator> const& g);
|
||||
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, mapnik::expression_grammar<std::string::const_iterator> const& g);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,29 +24,22 @@
|
|||
#define MAPNIK_EXPRESSIONS_GRAMMAR_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
// spirit2
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/qi_action.hpp>
|
||||
|
||||
// fusion
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
#include <boost/spirit/home/qi/domain.hpp> // for qi
|
||||
#include <boost/spirit/home/qi/nonterminal/grammar.hpp> // for grammar
|
||||
#include <boost/spirit/home/qi/nonterminal/rule.hpp> // for rule
|
||||
#include <boost/spirit/home/qi/numeric/int.hpp> // for int_parser
|
||||
#include <boost/spirit/home/qi/numeric/real.hpp> // for real_parser
|
||||
#include <boost/spirit/home/qi/string/symbols.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/support/nonterminal/locals.hpp> // for locals
|
||||
|
||||
// phoenix
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_object.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_function.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
#include <boost/spirit/home/phoenix/object/construct.hpp>
|
||||
#include <boost/spirit/home/phoenix/function/function.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/expression_node_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/regex.hpp>
|
||||
|
@ -33,167 +34,11 @@
|
|||
#include <boost/regex/icu.hpp>
|
||||
#endif
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
namespace tags {
|
||||
struct negate
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
struct plus
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "+";
|
||||
}
|
||||
};
|
||||
|
||||
struct minus
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
};
|
||||
|
||||
struct mult
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "*";
|
||||
}
|
||||
};
|
||||
|
||||
struct div
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct mod
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
};
|
||||
|
||||
struct less
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "<";
|
||||
}
|
||||
};
|
||||
|
||||
struct less_equal
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "<=";
|
||||
}
|
||||
};
|
||||
|
||||
struct greater
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return ">";
|
||||
}
|
||||
};
|
||||
|
||||
struct greater_equal
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return ">=";
|
||||
}
|
||||
};
|
||||
|
||||
struct equal_to
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "=";
|
||||
}
|
||||
};
|
||||
|
||||
struct not_equal_to
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "!=";
|
||||
}
|
||||
};
|
||||
|
||||
struct logical_not
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "not ";
|
||||
}
|
||||
};
|
||||
|
||||
struct logical_and
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return " and ";
|
||||
}
|
||||
};
|
||||
|
||||
struct logical_or
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return " or ";
|
||||
}
|
||||
};
|
||||
|
||||
} // end operation tags
|
||||
|
||||
|
||||
template <typename Tag> struct binary_node;
|
||||
template <typename Tag> struct unary_node;
|
||||
struct regex_match_node;
|
||||
struct regex_replace_node;
|
||||
|
||||
typedef mapnik::value value_type;
|
||||
|
||||
typedef boost::variant <
|
||||
value_type,
|
||||
attribute,
|
||||
geometry_type_attribute,
|
||||
boost::recursive_wrapper<unary_node<tags::negate> >,
|
||||
boost::recursive_wrapper<binary_node<tags::plus> >,
|
||||
boost::recursive_wrapper<binary_node<tags::minus> >,
|
||||
boost::recursive_wrapper<binary_node<tags::mult> >,
|
||||
boost::recursive_wrapper<binary_node<tags::div> >,
|
||||
boost::recursive_wrapper<binary_node<tags::mod> >,
|
||||
boost::recursive_wrapper<binary_node<tags::less> >,
|
||||
boost::recursive_wrapper<binary_node<tags::less_equal> >,
|
||||
boost::recursive_wrapper<binary_node<tags::greater> >,
|
||||
boost::recursive_wrapper<binary_node<tags::greater_equal> >,
|
||||
boost::recursive_wrapper<binary_node<tags::equal_to> >,
|
||||
boost::recursive_wrapper<binary_node<tags::not_equal_to> >,
|
||||
boost::recursive_wrapper<unary_node<tags::logical_not> >,
|
||||
boost::recursive_wrapper<binary_node<tags::logical_and> >,
|
||||
boost::recursive_wrapper<binary_node<tags::logical_or> >,
|
||||
boost::recursive_wrapper<regex_match_node>,
|
||||
boost::recursive_wrapper<regex_replace_node>
|
||||
> expr_node;
|
||||
|
||||
template <typename Tag> struct make_op;
|
||||
template <> struct make_op<tags::negate> { typedef std::negate<value_type> type;};
|
||||
template <> struct make_op<tags::plus> { typedef std::plus<value_type> type;};
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/make_shared.hpp>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <boost/optional.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
|
|
@ -25,121 +25,30 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/path_expression.hpp>
|
||||
#include <mapnik/path_expression_grammar.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
// fwd declare to reduce compile time
|
||||
template <typename Iterator> struct path_expression_grammar;
|
||||
class feature_impl;
|
||||
|
||||
MAPNIK_DECL path_expression_ptr parse_path(std::string const & str);
|
||||
MAPNIK_DECL path_expression_ptr parse_path(std::string const & str,
|
||||
path_expression_grammar<std::string::const_iterator> const& g);
|
||||
|
||||
template <typename T>
|
||||
struct path_processor
|
||||
{
|
||||
typedef T feature_type;
|
||||
struct path_visitor_ : boost::static_visitor<void>
|
||||
{
|
||||
path_visitor_ (std::string & filename, feature_type const& f)
|
||||
: filename_(filename),
|
||||
feature_(f) {}
|
||||
|
||||
void operator() (std::string const& token) const
|
||||
{
|
||||
filename_ += token;
|
||||
}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
// convert mapnik::value to std::string
|
||||
value const& val = feature_.get(attr.name());
|
||||
filename_ += val.to_string();
|
||||
}
|
||||
|
||||
std::string & filename_;
|
||||
feature_type const& feature_;
|
||||
};
|
||||
|
||||
struct to_string_ : boost::static_visitor<void>
|
||||
{
|
||||
to_string_ (std::string & str)
|
||||
: str_(str) {}
|
||||
|
||||
void operator() (std::string const& token) const
|
||||
{
|
||||
str_ += token;
|
||||
}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
str_ += "[";
|
||||
str_ += attr.name();
|
||||
str_ += "]";
|
||||
}
|
||||
|
||||
std::string & str_;
|
||||
};
|
||||
|
||||
template <typename T1>
|
||||
struct collect_ : boost::static_visitor<void>
|
||||
{
|
||||
collect_ (T1 & cont)
|
||||
: cont_(cont) {}
|
||||
|
||||
void operator() (std::string const& token) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(token);
|
||||
}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
cont_.insert(attr.name());
|
||||
}
|
||||
|
||||
T1 & cont_;
|
||||
};
|
||||
|
||||
static std::string evaluate(path_expression const& path,feature_type const& f)
|
||||
{
|
||||
std::string out;
|
||||
path_visitor_ eval(out,f);
|
||||
BOOST_FOREACH( mapnik::path_component const& token, path)
|
||||
boost::apply_visitor(eval,token);
|
||||
return out;
|
||||
}
|
||||
|
||||
static std::string to_string(path_expression const& path)
|
||||
{
|
||||
std::string str;
|
||||
to_string_ visitor(str);
|
||||
BOOST_FOREACH( mapnik::path_component const& token, path)
|
||||
boost::apply_visitor(visitor,token);
|
||||
return str;
|
||||
}
|
||||
|
||||
template <typename T2>
|
||||
static void collect_attributes(path_expression const& path, T2 & names)
|
||||
{
|
||||
typedef T2 cont_type;
|
||||
collect_<cont_type> visitor(names);
|
||||
BOOST_FOREACH( mapnik::path_component const& token, path)
|
||||
boost::apply_visitor(visitor,token);
|
||||
}
|
||||
static std::string evaluate(path_expression const& path, feature_impl const& f);
|
||||
static std::string to_string(path_expression const& path);
|
||||
static void collect_attributes(path_expression const& path, std::set<std::string>& names);
|
||||
};
|
||||
|
||||
typedef mapnik::path_processor<feature_impl> path_processor_type;
|
||||
typedef mapnik::path_processor path_processor_type;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
|
||||
using namespace boost;
|
||||
namespace qi = boost::spirit::qi;
|
||||
namespace phoenix = boost::phoenix;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <mapnik/transform_expression.hpp>
|
||||
|
||||
// spirit
|
||||
#include <boost/spirit/home/qi.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/util/trim.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// stl
|
||||
#include <sstream>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/optional.hpp>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/timer.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
#include <gdal_version.h>
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/timer.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/sql_utils.hpp>
|
||||
#include <mapnik/timer.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/optional.hpp>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef OSM_H
|
||||
#define OSM_H
|
||||
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef OSMPARSER_H
|
||||
#define OSMPARSER_H
|
||||
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <libxml/xmlreader.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
|
|
@ -41,7 +41,7 @@ plugin_env['LIBS'].append('mapnik')
|
|||
plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND'])
|
||||
plugin_env['LIBS'].append(env['ICU_LIB_NAME'])
|
||||
if env['THREADING'] == 'multi':
|
||||
plugin_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND'])
|
||||
plugin_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND'])
|
||||
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
#cmd = 'pg_config --libs'
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <mapnik/sql_utils.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/timer.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/optional.hpp>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/wkb.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/feature_factory.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/util/trim.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/utils.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/timer.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// stl
|
||||
#include <fstream>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/optional.hpp>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
#include "shape_io.hpp"
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
#include <mapnik/wkb.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/optional.hpp>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
#include <mapnik/expression.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/expression_grammar.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
|
|
@ -20,7 +20,23 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/expression_grammar.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/home/phoenix/object/construct.hpp>
|
||||
|
||||
// fwd declare
|
||||
namespace mapnik {
|
||||
struct attribute;
|
||||
struct geometry_type_attribute;
|
||||
}
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/params.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/path_expression_grammar.hpp>
|
||||
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/path_expression.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
@ -51,4 +60,92 @@ path_expression_ptr parse_path(std::string const& str,
|
|||
}
|
||||
}
|
||||
|
||||
namespace path_processor_detail {
|
||||
struct path_visitor_ : boost::static_visitor<void>
|
||||
{
|
||||
path_visitor_ (std::string & filename, feature_impl const& f)
|
||||
: filename_(filename),
|
||||
feature_(f) {}
|
||||
|
||||
void operator() (std::string const& token) const
|
||||
{
|
||||
filename_ += token;
|
||||
}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
// convert mapnik::value to std::string
|
||||
value const& val = feature_.get(attr.name());
|
||||
filename_ += val.to_string();
|
||||
}
|
||||
|
||||
std::string & filename_;
|
||||
feature_impl const& feature_;
|
||||
};
|
||||
|
||||
struct to_string_ : boost::static_visitor<void>
|
||||
{
|
||||
to_string_ (std::string & str)
|
||||
: str_(str) {}
|
||||
|
||||
void operator() (std::string const& token) const
|
||||
{
|
||||
str_ += token;
|
||||
}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
str_ += "[";
|
||||
str_ += attr.name();
|
||||
str_ += "]";
|
||||
}
|
||||
|
||||
std::string & str_;
|
||||
};
|
||||
|
||||
struct collect_ : boost::static_visitor<void>
|
||||
{
|
||||
collect_ (std::set<std::string> & cont)
|
||||
: cont_(cont) {}
|
||||
|
||||
void operator() (std::string const& token) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(token);
|
||||
}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
cont_.insert(attr.name());
|
||||
}
|
||||
|
||||
std::set<std::string> & cont_;
|
||||
};
|
||||
}
|
||||
|
||||
std::string path_processor::evaluate(path_expression const& path,feature_impl const& f)
|
||||
{
|
||||
std::string out;
|
||||
path_processor_detail::path_visitor_ eval(out,f);
|
||||
BOOST_FOREACH( mapnik::path_component const& token, path)
|
||||
boost::apply_visitor(eval,token);
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string path_processor::to_string(path_expression const& path)
|
||||
{
|
||||
std::string str;
|
||||
path_processor_detail::to_string_ visitor(str);
|
||||
BOOST_FOREACH( mapnik::path_component const& token, path)
|
||||
boost::apply_visitor(visitor,token);
|
||||
return str;
|
||||
}
|
||||
|
||||
void path_processor::collect_attributes(path_expression const& path, std::set<std::string>& names)
|
||||
{
|
||||
path_processor_detail::collect_ visitor(names);
|
||||
BOOST_FOREACH( mapnik::path_component const& token, path)
|
||||
boost::apply_visitor(visitor,token);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/raster.hpp>
|
||||
#include <mapnik/raster_colorizer.hpp>
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
|
||||
// boost
|
||||
#include <boost/version.hpp>
|
||||
|
||||
// spirit
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/home/phoenix/object/construct.hpp>
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
|
Loading…
Reference in a new issue