Index: trunk/extensions/AbuseFilter/parser_native/aftypes.cpp |
— | — | @@ -263,6 +263,18 @@ |
264 | 264 | from_string_converter<T>::convert(a), |
265 | 265 | from_string_converter<U>::convert(b)); |
266 | 266 | } |
| 267 | + |
| 268 | + /* |
| 269 | + * Unary version. |
| 270 | + */ |
| 271 | + template<typename T> |
| 272 | + datum operator() (T const &a) const { |
| 273 | + typedef typename from_string_converter<T>::type a_type; |
| 274 | + |
| 275 | + Operator<typename preferred_type<a_type, a_type>::type> op; |
| 276 | + return op(from_string_converter<T>::convert(a)); |
| 277 | + } |
| 278 | + |
267 | 279 | }; |
268 | 280 | |
269 | 281 | /* |
— | — | @@ -370,6 +382,18 @@ |
371 | 383 | } |
372 | 384 | |
373 | 385 | datum |
| 386 | +datum::operator+() const |
| 387 | +{ |
| 388 | + return *this; |
| 389 | +} |
| 390 | + |
| 391 | +datum |
| 392 | +datum::operator-() const |
| 393 | +{ |
| 394 | + return boost::apply_visitor(arith_visitor<std::negate>(), value_); |
| 395 | +} |
| 396 | + |
| 397 | +datum |
374 | 398 | operator+(datum const &a, datum const &b) { |
375 | 399 | return datum(a) += b; |
376 | 400 | } |
Index: trunk/extensions/AbuseFilter/parser_native/aftypes.h |
— | — | @@ -84,6 +84,8 @@ |
85 | 85 | datum &operator/=(datum const &other); |
86 | 86 | datum &operator%=(datum const &other); |
87 | 87 | bool operator!() const; |
| 88 | + datum operator+() const; |
| 89 | + datum operator-() const; |
88 | 90 | |
89 | 91 | bool compare(datum const &other) const; |
90 | 92 | bool compare_with_type(datum const &other) const; |
Index: trunk/extensions/AbuseFilter/parser_native/parser.cpp |
— | — | @@ -293,6 +293,8 @@ |
294 | 294 | basic = |
295 | 295 | ( '(' >> tern_expr[basic.val = arg1] >> ')' ) |
296 | 296 | | ch_p('!') >> tern_expr[basic.val = !arg1] |
| 297 | + | ch_p('+') >> tern_expr[basic.val = arg1] |
| 298 | + | ch_p('-') >> tern_expr[basic.val = -arg1] |
297 | 299 | | variable[basic.val = arg1] |
298 | 300 | | function[basic.val = arg1] |
299 | 301 | | value[basic.val = arg1] |