+ calc int_parser/generator type from mapnik::value_integer
This commit is contained in:
parent
8f9ebe8452
commit
f5dd9e53c4
8 changed files with 29 additions and 21 deletions
|
@ -196,9 +196,9 @@ void export_feature()
|
|||
// Python to mapnik::value converters
|
||||
// NOTE: order matters here. For example value_null must be listed before
|
||||
// bool otherwise Py_None will be interpreted as bool (false)
|
||||
implicitly_convertible<UnicodeString,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_unicode_string,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_null,mapnik::value>();
|
||||
implicitly_convertible<bool,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_bool,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_integer,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_double,mapnik::value>();
|
||||
|
||||
|
|
|
@ -121,6 +121,12 @@ struct geometry_types : qi::symbols<char,mapnik::value_integer>
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct integer_parser
|
||||
{
|
||||
typedef qi::int_parser<T,10,1,-1> type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
||||
{
|
||||
|
@ -129,6 +135,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
|||
explicit expression_grammar(mapnik::transcoder const& tr);
|
||||
|
||||
qi::real_parser<double, qi::strict_real_policies<double> > strict_double;
|
||||
typename integer_parser<mapnik::value_integer>::type int__;
|
||||
boost::phoenix::function<unicode_impl> unicode_;
|
||||
boost::phoenix::function<regex_match_impl> regex_match_;
|
||||
boost::phoenix::function<regex_replace_impl> regex_replace_;
|
||||
|
|
|
@ -186,8 +186,8 @@ struct feature_generator_grammar:
|
|||
using boost::spirit::karma::lit;
|
||||
using boost::spirit::karma::uint_;
|
||||
using boost::spirit::karma::bool_;
|
||||
using boost::spirit::karma::int_;
|
||||
using boost::spirit::karma::long_long;
|
||||
//using boost::spirit::karma::int_;
|
||||
//using boost::spirit::karma::long_long;
|
||||
using boost::spirit::karma::double_;
|
||||
using boost::spirit::karma::_val;
|
||||
using boost::spirit::karma::_1;
|
||||
|
@ -213,7 +213,7 @@ struct feature_generator_grammar:
|
|||
<< value(phoenix::at_c<1>(_val))
|
||||
;
|
||||
|
||||
value = (value_null_| bool_ | long_long | double_ | ustring)[_1 = value_base_(_r1)]
|
||||
value = (value_null_| bool_ | int__ | double_ | ustring)[_1 = value_base_(_r1)]
|
||||
;
|
||||
|
||||
value_null_ = string[_1 = "null"]
|
||||
|
@ -232,6 +232,7 @@ struct feature_generator_grammar:
|
|||
karma::rule<OutputIterator, void(mapnik::value const&)> value;
|
||||
karma::rule<OutputIterator, mapnik::value_null()> value_null_;
|
||||
karma::rule<OutputIterator, UnicodeString()> ustring;
|
||||
typename karma::int_generator<mapnik::value_integer,10, false> int__;
|
||||
// phoenix functions
|
||||
phoenix::function<get_id> id_;
|
||||
phoenix::function<value_base> value_base_;
|
||||
|
|
|
@ -111,6 +111,7 @@ struct feature_grammar :
|
|||
qi::rule<Iterator,space_type> value;
|
||||
qi::symbols<char const, char const> unesc_char;
|
||||
qi::uint_parser< unsigned, 16, 4, 4 > hex4 ;
|
||||
qi::int_parser<mapnik::value_integer,10,1,-1> int__;
|
||||
qi::rule<Iterator,std::string(), space_type> string_;
|
||||
qi::rule<Iterator,space_type> key_value;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,
|
||||
|
|
|
@ -108,7 +108,8 @@ struct value_null
|
|||
};
|
||||
|
||||
|
||||
typedef boost::long_long_type value_integer;
|
||||
//typedef boost::long_long_type value_integer;
|
||||
typedef int value_integer;
|
||||
typedef double value_double;
|
||||
typedef UnicodeString value_unicode_string;
|
||||
typedef bool value_bool;
|
||||
|
@ -416,7 +417,7 @@ struct add : public boost::static_visitor<V>
|
|||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return 0LL;
|
||||
return value_integer(lhs + rhs);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -454,7 +455,7 @@ struct sub : public boost::static_visitor<V>
|
|||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return 0LL;
|
||||
return value_integer(lhs - rhs);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -491,7 +492,7 @@ struct mult : public boost::static_visitor<V>
|
|||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return 0LL;
|
||||
return value_integer(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -599,7 +600,7 @@ struct negate : public boost::static_visitor<V>
|
|||
|
||||
value_type operator() (value_bool val) const
|
||||
{
|
||||
return val ? -1LL : 0LL;
|
||||
return val ? value_integer(-1) : value_integer(0);
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& ustr) const
|
||||
|
@ -783,9 +784,9 @@ struct to_int : public boost::static_visitor<value_integer>
|
|||
value_integer operator() (std::string const& val) const
|
||||
{
|
||||
value_integer result;
|
||||
if (util::string2longlong(val,result))
|
||||
if (util::string2int(val,result))
|
||||
return result;
|
||||
return 0LL;
|
||||
return value_integer(0);
|
||||
}
|
||||
|
||||
value_integer operator() (value_unicode_string const& val) const
|
||||
|
@ -798,7 +799,7 @@ struct to_int : public boost::static_visitor<value_integer>
|
|||
value_integer operator() (value_null const& val) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return 0LL;
|
||||
return value_integer(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -886,13 +887,12 @@ public:
|
|||
|
||||
value_double to_double() const
|
||||
{
|
||||
return 0.0;
|
||||
//return boost::apply_visitor(impl::to_double(),base_);
|
||||
return boost::apply_visitor(impl::to_double(),base_);
|
||||
}
|
||||
|
||||
value_integer to_int() const
|
||||
{
|
||||
return 0LL;
|
||||
return value_integer(0);
|
||||
//return boost::apply_visitor(impl::to_int(),base_);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
|
|||
}
|
||||
else
|
||||
{
|
||||
mapnik::value_integer val = 0LL;
|
||||
mapnik::value_integer val = 0;
|
||||
const char *itr = record_+fields_[col].offset_;
|
||||
const char *end = itr + fields_[col].length_;
|
||||
if (qi::phrase_parse(itr,end,int_,ascii::space,val))
|
||||
|
|
|
@ -63,13 +63,12 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
|
|||
using qi::lexeme;
|
||||
using qi::_val;
|
||||
using qi::lit;
|
||||
//using qi::int_;
|
||||
using qi::long_long;
|
||||
using qi::double_;
|
||||
using qi::hex;
|
||||
using qi::omit;
|
||||
using standard_wide::char_;
|
||||
using standard_wide::no_case;
|
||||
|
||||
expr = logical_expr.alias();
|
||||
|
||||
logical_expr = not_expr [_val = _1]
|
||||
|
@ -139,7 +138,7 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
|
|||
;
|
||||
|
||||
primary_expr = strict_double [_val = _1]
|
||||
| long_long [_val = _1]
|
||||
| int__[_val = _1]
|
||||
| no_case[lit("true")] [_val = true]
|
||||
| no_case[lit("false")] [_val = false]
|
||||
| no_case[lit("null")] [_val = value_null() ]
|
||||
|
|
|
@ -90,7 +90,7 @@ feature_grammar<Iterator,FeatureType>::feature_grammar(mapnik::transcoder const&
|
|||
#else
|
||||
number = strict_double
|
||||
#endif
|
||||
//| long_long
|
||||
| int__
|
||||
| lit("true") [_val = true]
|
||||
| lit ("false") [_val = false]
|
||||
| lit("null")[_val = construct<value_null>()]
|
||||
|
|
Loading…
Reference in a new issue