move phoenix functions into ctor
This commit is contained in:
parent
25217549f1
commit
4ca0c21d73
2 changed files with 24 additions and 23 deletions
|
@ -32,7 +32,6 @@
|
|||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_function.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
||||
|
@ -40,26 +39,6 @@ namespace mapnik { namespace json {
|
|||
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
||||
struct set_position_impl
|
||||
{
|
||||
using result_type = void;
|
||||
template <typename T0,typename T1>
|
||||
result_type operator() (T0 & coords, T1 const& pos) const
|
||||
{
|
||||
if (pos) coords = *pos;
|
||||
}
|
||||
};
|
||||
|
||||
struct push_position_impl
|
||||
{
|
||||
using result_type = void;
|
||||
template <typename T0, typename T1>
|
||||
result_type operator() (T0 & coords, T1 const& pos) const
|
||||
{
|
||||
if (pos) coords.emplace_back(*pos);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename ErrorHandler = error_handler<Iterator> >
|
||||
struct positions_grammar :
|
||||
qi::grammar<Iterator,coordinates(),space_type>
|
||||
|
@ -70,8 +49,6 @@ struct positions_grammar :
|
|||
qi::rule<Iterator, positions(), space_type> ring;
|
||||
qi::rule<Iterator, std::vector<positions>(), space_type> rings;
|
||||
qi::rule<Iterator, std::vector<std::vector<positions> >(), space_type> rings_array;
|
||||
boost::phoenix::function<set_position_impl> set_position;
|
||||
boost::phoenix::function<push_position_impl> push_position;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -28,12 +28,33 @@
|
|||
#include <boost/spirit/include/phoenix_object.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_function.hpp>
|
||||
// stl
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
struct set_position_impl
|
||||
{
|
||||
using result_type = void;
|
||||
template <typename T0,typename T1>
|
||||
result_type operator() (T0 & coords, T1 const& pos) const
|
||||
{
|
||||
if (pos) coords = *pos;
|
||||
}
|
||||
};
|
||||
|
||||
struct push_position_impl
|
||||
{
|
||||
using result_type = void;
|
||||
template <typename T0, typename T1>
|
||||
result_type operator() (T0 & coords, T1 const& pos) const
|
||||
{
|
||||
if (pos) coords.emplace_back(*pos);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Iterator, typename ErrorHandler>
|
||||
positions_grammar<Iterator, ErrorHandler>::positions_grammar(ErrorHandler & error_handler)
|
||||
: positions_grammar::base_type(coords,"coordinates")
|
||||
|
@ -49,6 +70,9 @@ positions_grammar<Iterator, ErrorHandler>::positions_grammar(ErrorHandler & erro
|
|||
using qi::fail;
|
||||
using qi::on_error;
|
||||
|
||||
boost::phoenix::function<set_position_impl> set_position;
|
||||
boost::phoenix::function<push_position_impl> push_position;
|
||||
|
||||
coords = rings_array[_val = _1] | rings [_val = _1] | ring[_val = _1] | pos[set_position(_val,_1)]
|
||||
;
|
||||
pos = lit('[') > -(double_ > lit(',') > double_) > omit[*(lit(',') > double_)] > lit(']')
|
||||
|
|
Loading…
Add table
Reference in a new issue