Revert "re factor expression grammar/parser stuff"

This reverts commit c58b8c4f71813a2490cf135573009c92be1a90c4.
This commit is contained in:
Artem Pavlenko 2010-03-15 21:08:56 +00:00
parent 0f8deb5e73
commit 83b20c3036
9 changed files with 29 additions and 66 deletions

View file

@ -23,11 +23,10 @@
#include <boost/python.hpp>
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/expression_string.hpp>
#include <mapnik/expression_evaluator.hpp>
#include <mapnik/path_expr_parser.hpp>
#include <mapnik/path_expression_grammar.hpp>
#include <boost/variant.hpp>
@ -35,7 +34,6 @@ using mapnik::expression_ptr;
using mapnik::parse_expression;
using mapnik::to_expression_string;
using mapnik::path_expression_ptr;
using mapnik::path_processor_type;
// expression
expression_ptr parse_expression_(std::string const& wkt)
@ -52,17 +50,17 @@ std::string expression_evaluate_(mapnik::expr_node const& expr, mapnik::Feature
// path expression
path_expression_ptr parse_path_(std::string const& path)
{
return parse_path(path);
return mapnik::parse_path(path);
}
std::string path_to_string_(mapnik::path_expression const& expr)
{
return path_processor_type::to_string(expr);
return mapnik::path_processor_type::to_string(expr);
}
std::string path_evaluate_(mapnik::path_expression const& expr, mapnik::Feature const& f)
{
return path_processor_type::evaluate(expr, f);
return mapnik::path_processor_type::evaluate(expr, f);
}
void export_expression()

View file

@ -1,45 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2010 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_ATTRIBUTE_HPP
#define MAPNIK_ATTRIBUTE_HPP
namespace mapnik {
struct attribute
{
std::string name_;
explicit attribute(std::string const& name)
: name_(name) {}
template <typename V ,typename F>
V value(F const& f) const
{
return f[name_];
}
std::string const& name() const { return name_;}
};
}
#endif // MAPNIK_ATTRIBUTE_HPP

View file

@ -195,10 +195,10 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
multiplicative_expr = primary_expr [_val = _1]
>> *( '*' >> primary_expr [_val *= _1]
| '/' >> primary_expr [_val /= _1]
| '%' >> primary_expr [_val %= _1]
| regex_match_expr[_val = regex_match_(_val, _1)]
| regex_replace_expr(_val) [_val = _1]
| '/' >> primary_expr [_val /= _1]
| '%' >> primary_expr [_val %= _1]
| regex_match_expr[_val = regex_match_(_val, _1)]
| regex_replace_expr(_val) [_val = _1]
)
;

View file

@ -25,7 +25,6 @@
// mapnik
#include <mapnik/value.hpp>
#include <mapnik/attribute.hpp>
// boost
#include <boost/variant.hpp>
#include <boost/shared_ptr.hpp>
@ -36,6 +35,21 @@
namespace mapnik
{
struct attribute
{
std::string name_;
explicit attribute(std::string const& name)
: name_(name) {}
template <typename V ,typename F>
V value(F const& f) const
{
return f[name_];
}
std::string const& name() const { return name_;}
};
namespace tags {
struct plus
{
@ -181,6 +195,8 @@ boost::recursive_wrapper<regex_match_node>,
boost::recursive_wrapper<regex_replace_node>
> expr_node;
typedef boost::shared_ptr<expr_node> expression_ptr;
template <typename Tag> struct make_op;
template <> struct make_op<tags::plus> { typedef std::plus<value_type> type;};
template <> struct make_op<tags::minus> { typedef std::minus<value_type> type;};

View file

@ -25,17 +25,12 @@
#ifndef MAPNIK_FILTER_FACTORY_HPP
#define MAPNIK_FILTER_FACTORY_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/expression_node.hpp>
// stl
#include <string>
#include <mapnik/expression_grammar.hpp>
namespace mapnik
{
typedef boost::shared_ptr<expr_node> expression_ptr;
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt, std::string const& encoding);
MAPNIK_DECL expression_ptr parse_expression (std::string const& wkt);

View file

@ -33,7 +33,7 @@
#include <mapnik/text_symbolizer.hpp>
#include <mapnik/markers_symbolizer.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/expression_grammar.hpp>
// boost
#include <boost/shared_ptr.hpp>

View file

@ -30,7 +30,8 @@
#include <mapnik/color.hpp>
#include <mapnik/font_set.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/expression_node.hpp>
// boost
#include <boost/tuple/tuple.hpp>
#include <boost/shared_ptr.hpp>

View file

@ -90,7 +90,6 @@ source = Split(
load_map.cpp
memory.cpp
params.cpp
path_expr_parser.cpp
placement_finder.cpp
plugin.cpp
png_reader.cpp

View file

@ -22,7 +22,6 @@
//$Id$
#include <mapnik/filter_factory.hpp>
#include <mapnik/expression_grammar.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/unicode.hpp>