Compare commits
6 commits
master
...
expr-expli
Author | SHA1 | Date | |
---|---|---|---|
|
591da55914 | ||
|
8929dbdeb1 | ||
|
dfdeda17fd | ||
|
2e175a16fe | ||
|
4e59b4c7c3 | ||
|
3422472c7d |
5 changed files with 39 additions and 2 deletions
|
@ -217,6 +217,10 @@ struct unary_function_types_ : x3::symbols<unary_function_impl>
|
||||||
("log", log_impl()) //
|
("log", log_impl()) //
|
||||||
("abs", abs_impl()) //
|
("abs", abs_impl()) //
|
||||||
("length", length_impl()) //
|
("length", length_impl()) //
|
||||||
|
("bool", bool_impl()) //
|
||||||
|
("int", int_impl()) //
|
||||||
|
("float", float_impl()) //
|
||||||
|
("str", str_impl()) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} const unary_func_types;
|
} const unary_func_types;
|
||||||
|
|
|
@ -89,6 +89,30 @@ struct length_impl
|
||||||
value_type operator()(value_type const& val) const { return val.to_unicode().length(); }
|
value_type operator()(value_type const& val) const { return val.to_unicode().length(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// str
|
||||||
|
struct str_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_unicode(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// bool
|
||||||
|
struct bool_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_bool(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// int
|
||||||
|
struct int_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_int(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// float
|
||||||
|
struct float_impl
|
||||||
|
{
|
||||||
|
value_type operator()(value_type const& val) const { return val.to_double(); }
|
||||||
|
};
|
||||||
|
|
||||||
// min
|
// min
|
||||||
inline value_type min_impl(value_type const& arg1, value_type const& arg2)
|
inline value_type min_impl(value_type const& arg1, value_type const& arg2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#define MAPNIK_MAJOR_VERSION 4
|
#define MAPNIK_MAJOR_VERSION 4
|
||||||
#define MAPNIK_MINOR_VERSION 0
|
#define MAPNIK_MINOR_VERSION 0
|
||||||
#define MAPNIK_PATCH_VERSION 3
|
#define MAPNIK_PATCH_VERSION 4
|
||||||
|
|
||||||
#define MAPNIK_VERSION MAPNIK_VERSION_ENCODE(MAPNIK_MAJOR_VERSION, MAPNIK_MINOR_VERSION, MAPNIK_PATCH_VERSION)
|
#define MAPNIK_VERSION MAPNIK_VERSION_ENCODE(MAPNIK_MAJOR_VERSION, MAPNIK_MINOR_VERSION, MAPNIK_PATCH_VERSION)
|
||||||
|
|
||||||
|
|
|
@ -441,7 +441,7 @@ struct convert<value_bool>
|
||||||
template<typename T>
|
template<typename T>
|
||||||
value_bool operator()(T val) const
|
value_bool operator()(T val) const
|
||||||
{
|
{
|
||||||
return val > 0 ? true : false;
|
return val == 0 ? false : true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,15 @@ TEST_CASE("expressions")
|
||||||
TRY_CHECK(parse_and_dump("'escaped \\' apostrophe'") == "'escaped \\' apostrophe'");
|
TRY_CHECK(parse_and_dump("'escaped \\' apostrophe'") == "'escaped \\' apostrophe'");
|
||||||
TRY_CHECK(parse_and_dump("'escaped \\\\ backslash'") == "'escaped \\\\ backslash'");
|
TRY_CHECK(parse_and_dump("'escaped \\\\ backslash'") == "'escaped \\\\ backslash'");
|
||||||
|
|
||||||
|
// explicit conversions
|
||||||
|
TRY_CHECK(eval("int('123')") == 123);
|
||||||
|
TRY_CHECK(eval("float('3.14'+'159')") == 3.14159);
|
||||||
|
TRY_CHECK(eval("bool(-0.001)") == true);
|
||||||
|
TRY_CHECK(eval("bool(0.001)") == true);
|
||||||
|
TRY_CHECK(eval("bool(0.0)") == false);
|
||||||
|
TRY_CHECK(eval("str(123)") == tr.transcode("123"));
|
||||||
|
TRY_CHECK(eval("float(str(3.14) + str(159))") == 3.14159);
|
||||||
|
|
||||||
// floating point constants
|
// floating point constants
|
||||||
TRY_CHECK(parse_and_dump("pi") == "3.14159");
|
TRY_CHECK(parse_and_dump("pi") == "3.14159");
|
||||||
TRY_CHECK(parse_and_dump("deg_to_rad") == "0.0174533");
|
TRY_CHECK(parse_and_dump("deg_to_rad") == "0.0174533");
|
||||||
|
|
Loading…
Reference in a new issue