1 [/==============================================================================
2 Copyright (C) 2001-2011 Joel de Guzman
3 Copyright (C) 2001-2011 Hartmut Kaiser
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ===============================================================================/]
9 [section:numeric Numeric Parsers]
11 The library includes a couple of predefined objects for parsing signed
12 and unsigned integers and real numbers. These parsers are fully
13 parametric. Most of the important aspects of numeric parsing can be
14 finely adjusted to suit. This includes the radix base, the minimum and
15 maximum number of allowable digits, the exponent, the fraction etc.
16 Policies control the real number parsers' behavior. There are some
17 predefined policies covering the most common real number formats but the
18 user can supply her own when needed.
20 The numeric parsers are fine tuned (employing loop unrolling and
21 extensive template metaprogramming) with exceptional performance that
22 rivals the low level C functions such as `atof`, `strtod`, `atol`,
23 `strtol`. Benchmarks reveal up to 4X speed over the C counterparts. This
24 goes to show that you can write extremely tight generic C++ code that
25 rivals, if not surpasses C.
27 [heading Module Header]
29 // forwards to <boost/spirit/home/qi/numeric.hpp>
30 #include <boost/spirit/include/qi_numeric.hpp>
32 Also, see __include_structure__.
34 [/------------------------------------------------------------------------------]
35 [section:uint Unsigned Integer Parsers (`uint_`, etc.)]
39 The `uint_parser` class is the simplest among the members of the
40 numerics package. The `uint_parser` can parse unsigned integers of
41 arbitrary length and size. The `uint_parser` parser can be used to parse
42 ordinary primitive C/C++ integers or even user defined scalars such as
43 bigints (unlimited precision integers) as long as the type follows
44 certain expression requirements (documented below). The `uint_parser` is
45 a template class. Template parameters fine tune its behavior.
49 // forwards to <boost/spirit/home/qi/numeric/uint.hpp>
50 #include <boost/spirit/include/qi_uint.hpp>
52 Also, see __include_structure__.
58 [[`boost::spirit::lit // alias: boost::spirit::qi::lit`]]
59 [[`boost::spirit::bin // alias: boost::spirit::qi::bin`]]
60 [[`boost::spirit::oct // alias: boost::spirit::qi::oct`]]
61 [[`boost::spirit::hex // alias: boost::spirit::qi::hex`]]
62 [[`boost::spirit::ushort_ // alias: boost::spirit::qi::ushort_`]]
63 [[`boost::spirit::ulong_ // alias: boost::spirit::qi::ulong_`]]
64 [[`boost::spirit::uint_ // alias: boost::spirit::qi::uint_`]]
65 [[`boost::spirit::ulong_long // alias: boost::spirit::qi::ulong_long`]]
68 [note `ulong_long` is only available on platforms where the preprocessor
69 constant `BOOST_HAS_LONG_LONG` is defined (i.e. on platforms having
70 native support for `unsigned long long` (64 bit) unsigned integer
73 [note `lit` is reused by the [qi_lit_char Character Parsers], and the Numeric
74 Parsers. In general, a char parser is created when you pass in a
75 character, and a numeric parser is created when you use a numeric
87 [heading Template parameters]
90 [[Parameter] [Description] [Default]]
91 [[`T`] [The numeric base type of the
92 numeric parser.] [none]]
93 [[`Radix`] [The radix base. This can be
94 any base from 2..10 and 16] [10]]
95 [[`MinDigits`] [The minimum number of digits
97 [[`MaxDigits`] [The maximum number of digits
98 allowable. If this is -1, then the
99 maximum limit becomes unbounded.] [-1]]
104 [:__primitive_parser_concept__]
106 [variablelist Notation
107 [[`n`] [An object of `T`, the numeric base type.]]
108 [[`num`] [Numeric literal, any unsigned integer value, or a
109 __qi_lazy_argument__ that evaluates to a unsigned integer
113 [heading Expression Semantics]
115 Semantics of an expression is defined only where it differs from, or is
116 not defined in __primitive_parser_concept__.
129 [Parse an unsigned integer using the default radix (10).]
138 [Match the literal `num` using the default radix (10). The parser will fail
139 if the parsed value is not equal to the specified value.]
146 [Parse an unsigned integer using radix 2 for `bin`, radix 8 for `oct`, and
154 [Match the literal `num` using radix 2 for `bin`, radix 8 for `oct`, and
155 radix 16 for `hex`. The parser will fail
156 if the parsed value is not equal to the specified value.]
160 T, Radix, MinDigits, MaxDigits
163 [Parse an unsigned integer of type `T` using radix `Radix`, with
164 a minimum of `MinDigits` and a maximum of `MaxDigits`.]
168 T, Radix, MinDigits, MaxDigits
171 [Match the literal `num` of type `T` using radix `Radix`, with
172 a minimum of `MinDigits` and a maximum of `MaxDigits`. The parser will fail
173 if the parsed value is not equal to the specified value.]
177 [important All numeric parsers check for overflow conditions based on the type
178 `T` the corresponding `uint_parser<>` has been instantiated with. If the
179 parsed number overflows this type the parsing fails. Please be aware
180 that the overflow check is not based on the type of the supplied
181 attribute but solely depends on the template parameter `T`.]
223 [`boost::ulong_long_type`]
227 T, Radix, MinDigits, MaxDigits
230 T, Radix, MinDigits, MaxDigits
239 [:O(N), where N is the number of digits being parsed.]
241 [heading Minimum Expression Requirements for `T`]
243 For the numeric base type, `T`, the expression requirements below must be
247 [[Expression] [Semantics]]
248 [[`T()`] [Default construct.]]
249 [[`T(0)`] [Construct from an `int`.]]
250 [[`n + n`] [Addition.]]
251 [[`n * n`] [Multiplication.]]
252 [[`std::numeric_limits<T>::is_bounded`] [`true` or `false` if `T` bounded.]]
253 [[`std::numeric_limits<T>::digits`] [Maximum Digits for `T`, radix digits.
254 Required only if `T` is bounded.]]
255 [[`std::numeric_limits<T>::digits10`] [Maximum Digits for `T`, base 10.
256 Required only if `T` is bounded.]]
257 [[`std::numeric_limits<T>::max()`] [Maximum value for `T`.
258 Required only if `T` is bounded.]]
259 [[`std::numeric_limits<T>::min()`] [Minimum value for `T`.
260 Required only if `T` is bounded.]]
265 [note The test harness for the example(s) below is presented in the
266 __qi_basics_examples__ section.]
268 Some using declarations:
270 [reference_using_declarations_uint]
272 Basic unsigned integers:
276 [reference_thousand_separated]
278 [endsect] [/ Unsigned Integers]
280 [/------------------------------------------------------------------------------]
281 [section:int Signed Integer Parsers (`int_`, etc.)]
283 [heading Description]
285 The `int_parser` can parse signed integers of arbitrary length and size.
286 This is almost the same as the `uint_parser`. The only difference is the
287 additional task of parsing the `'+'` or `'-'` sign preceding the number.
288 The class interface is the same as that of the `uint_parser`.
290 The `int_parser` parser can be used to parse ordinary primitive C/C++
291 integers or even user defined scalars such as bigints (unlimited
292 precision integers) as long as the type follows certain expression
293 requirements (documented below).
297 // forwards to <boost/spirit/home/qi/numeric/int.hpp>
298 #include <boost/spirit/include/qi_int.hpp>
300 Also, see __include_structure__.
306 [[`boost::spirit::lit // alias: boost::spirit::qi::lit`]]
307 [[`boost::spirit::short_ // alias: boost::spirit::qi::short_`]]
308 [[`boost::spirit::int_ // alias: boost::spirit::qi::int_`]]
309 [[`boost::spirit::long_ // alias: boost::spirit::qi::long_`]]
310 [[`boost::spirit::long_long // alias: boost::spirit::qi::long_long`]]
313 [note `long_long` is only available on platforms where the preprocessor
314 constant `BOOST_HAS_LONG_LONG` is defined (i.e. on platforms having
315 native support for `signed long long` (64 bit) unsigned integer types).]
317 [note `lit` is reused by the [qi_lit_char Character Parsers], and the Numeric
318 Parsers. In general, a char parser is created when you pass in a
319 character, and a numeric parser is created when you use a numeric
331 [heading Template parameters]
334 [[Parameter] [Description] [Default]]
335 [[`T`] [The numeric base type of the
336 numeric parser.] [none]]
337 [[`Radix`] [The radix base. This can be
338 any base from 2..10 and 16] [10]]
339 [[`MinDigits`] [The minimum number of digits
341 [[`MaxDigits`] [The maximum number of digits
342 allowable. If this is -1, then the
343 maximum limit becomes unbounded.] [-1]]
348 [:__primitive_parser_concept__]
350 [variablelist Notation
351 [[`n`] [An object of `T`, the numeric base type.]]
352 [[`num`] [Numeric literal, any signed integer value, or a
353 __qi_lazy_argument__ that evaluates to a signed integer
357 [heading Expression Semantics]
359 Semantics of an expression is defined only where it differs from, or is
360 not defined in __primitive_parser_concept__.
373 [Parse a signed integer using the default radix (10).]
382 [Match the literal `num` using the default radix (10). The parser will fail
383 if the parsed value is not equal to the specified value.]
387 T, Radix, MinDigits, MaxDigits
390 [Parse a signed integer of type `T` using radix `Radix`, with
391 a minimum of `MinDigits` and a maximum of `MaxDigits`.]
395 T, Radix, MinDigits, MaxDigits
398 [Match the literal `num` of type `T` using radix `Radix`, with
399 a minimum of `MinDigits` and a maximum of `MaxDigits`. The parser will fail
400 if the parsed value is not equal to the specified value.]
404 [important All numeric parsers check for overflow conditions based on the type `T`
405 the corresponding `int_parser<>` has been instantiated with. If the
406 parsed number overflows this type the parsing fails. Please be aware
407 that the overflow check is not based on the type of the supplied
408 attribute but solely depends on the template parameter `T`.]
444 [`boost::long_long_type`]
448 T, Radix, MinDigits, MaxDigits
451 T, Radix, MinDigits, MaxDigits
460 [:O(N), where N is the number of digits being parsed plus the sign.]
462 [heading Minimum Expression Requirements for `T`]
464 For the numeric base type, `T`, the expression requirements below must be
468 [[Expression] [Semantics]]
469 [[`T()`] [Default construct.]]
470 [[`T(0)`] [Construct from an `int`.]]
471 [[`n + n`] [Addition.]]
472 [[`n - n`] [Subtraction.]]
473 [[`n * n`] [Multiplication.]]
474 [[`std::numeric_limits<T>::is_bounded`] [`true` or `false` if `T` bounded.]]
475 [[`std::numeric_limits<T>::digits`] [Maximum Digits for `T`, radix digits.
476 Required only if `T` is bounded.]]
477 [[`std::numeric_limits<T>::digits10`] [Maximum Digits for `T`, base 10.
478 Required only if `T` is bounded.]]
479 [[`std::numeric_limits<T>::max()`] [Maximum value for `T`.
480 Required only if `T` is bounded.]]
481 [[`std::numeric_limits<T>::min()`] [Minimum value for `T`.
482 Required only if `T` is bounded.]]
487 [note The test harness for the example(s) below is presented in the
488 __qi_basics_examples__ section.]
490 Some using declarations:
492 [reference_using_declarations_int]
494 Basic signed integers:
498 [endsect] [/ Signed Integers]
500 [/------------------------------------------------------------------------------]
501 [section:real Real Number Parsers (`float_`, `double_`, etc.)]
503 [heading Description]
505 The `real_parser` can parse real numbers of arbitrary length and size
506 limited by its template parameter, `T`. The numeric base type `T` can be
507 a user defined numeric type such as fixed_point (fixed point reals) and
508 bignum (unlimited precision numbers) as long as the type follows certain
509 expression requirements (documented below).
513 // forwards to <boost/spirit/home/qi/numeric/real.hpp>
514 #include <boost/spirit/include/qi_real.hpp>
516 Also, see __include_structure__.
522 [[`boost::spirit::lit // alias: boost::spirit::qi::lit`]]
523 [[`boost::spirit::float_ // alias: boost::spirit::qi::float_`]]
524 [[`boost::spirit::double_ // alias: boost::spirit::qi::double_`]]
525 [[`boost::spirit::long_double // alias: boost::spirit::qi::long_double`]]
528 [note `lit` is reused by the [qi_lit_char Character Parsers], and the Numeric
529 Parsers. In general, a char parser is created when you pass in a
530 character, and a numeric parser is created when you use a numeric
535 template <typename T, typename RealPolicies>
538 [heading Template parameters]
541 [[Parameter] [Description] [Default]]
542 [[`T`] [The numeric base type of the
543 numeric parser.] [none]]
544 [[`RealPolicies`] [Policies control the
545 parser's behavior.] [`real_policies<T>`]]
550 [:__primitive_parser_concept__]
552 [variablelist Notation
553 [[`n`] [An object of `T`, the numeric base type.]]
554 [[`num`] [Numeric literal, any real value, or a __qi_lazy_argument__
555 that evaluates to a real value.]]
556 [[`RP`] [A `RealPolicies` (type).]]
557 [[`exp`] [A `int` exponent.]]
558 [[`b`] [A `bool` flag.]]
559 [[`f`, `l`] [__fwditer__. first/last iterator pair.]]
562 [heading Expression Semantics]
564 Semantics of an expression is defined only where it differs from, or is
565 not defined in __primitive_parser_concept__.
577 [Parse a real using the default policies (`real_policies<T>`).]
585 [Match the literal `num` using the default policies (`real_policies<T>`).
586 The parser will fail if the parsed value is not equal to the specified
594 [Parse a real of type `T` using `RealPolicies`.]
601 [Match the literal `num` of type `T` using `RealPolicies`. The parser will fail
602 if the parsed value is not equal to the specified value.]
650 [:O(N), where N is the number of characters (including the digits,
651 exponent, sign, etc.) being parsed.]
653 [heading Minimum Expression Requirements for `T`]
655 The numeric base type, `T`, the minimum expression requirements listed
656 below must be valid. Take note that additional requirements may be
657 imposed by custom policies.
660 [[Expression] [Semantics]]
661 [[`T()`] [Default construct.]]
662 [[`T(0)`] [Construct from an `int`.]]
663 [[`n + n`] [Addition.]]
664 [[`n - n`] [Subtraction.]]
665 [[`n * n`] [Multiplication.]]
666 [[`std::numeric_limits<T>::is_bounded`] [`true` or `false` if `T` bounded.]]
667 [[`std::numeric_limits<T>::digits`] [Maximum Digits for `T`, radix digits.
668 Required only if `T` is bounded.]]
669 [[`std::numeric_limits<T>::digits10`] [Maximum Digits for `T`, base 10.
670 Required only if `T` is bounded.]]
671 [[`std::numeric_limits<T>::max()`] [Maximum value for `T`.
672 Required only if `T` is bounded.]]
673 [[`std::numeric_limits<T>::min()`] [Minimum value for `T`.
674 Required only if `T` is bounded.]]
677 [[`boost::spirit::traits::scale(exp, n)`]
678 [Multiply `n` by `10^exp`. Default implementation
679 is provided for `float`, `double` and `long double`.]]
681 [[`boost::spirit::traits::negate(b, n)`]
682 [Negate `n` if `b` is `true`. Default implementation
683 is provided for `float`, `double` and `long double`.]]
685 [[`boost::spirit::traits::is_equal_to_one(n)`]
686 [Return `true` if `n` is equal to `1.0`. Default implementation
687 is provided for `float`, `double` and `long double`.]]
691 [note The additional spirit real number traits above are provided to
692 allow custom implementations to implement efficient real number parsers.
693 For example, for certain custom real numbers, scaling to a base 10
694 exponent is a very cheap operation.]
696 [heading `RealPolicies`]
698 The `RealPolicies` template parameter is a class that groups all the
699 policies that control the parser's behavior. Policies control the real
700 number parsers' behavior.
702 The default is `real_policies<T>`. The default is provided to take care
703 of the most common case (there are many ways to represent, and hence
704 parse, real numbers). In most cases, the default policies are sufficient
705 and can be used straight out of the box. They are designed to parse
706 C/C++ style floating point numbers of the form `nnn.fff.Eeee` where
707 `nnn` is the whole number part, `fff` is the fractional part, `E` is
708 `'e'` or `'E'` and `eee` is the exponent optionally preceded by `'-'` or
709 `'+'` with the additional detection of NaN and Inf as mandated by the
710 C99 Standard and proposed for inclusion into the C++0x Standard: nan,
711 nan(...), inf and infinity (the matching is case-insensitive). This
712 corresponds to the following grammar:
719 = -lit("1.0#") >> no_case["nan"]
720 >> -('(' >> *(char_ - ')') >> ')')
724 = no_case[lit("inf") >> -lit("inity")]
731 | fractional_constant >> -exponent_part
732 | +digit >> exponent_part
737 = *digit >> '.' >> +digit
738 | +digit >> -lit('.')
742 = (lit('e') | 'E') >> -sign >> +digit
745 There are four `RealPolicies` predefined for immediate use:
747 [table Predefined Policies
749 [[Policies] [Description]]
750 [[`ureal_policies<double>`] [Without sign.]]
751 [[`real_policies<double>`] [With sign.]]
752 [[`strict_ureal_policies<double>`] [Without sign, dot required.]]
753 [[`strict_real_policies<double>`] [With sign, dot required.]]
756 [note Integers are considered a subset of real numbers, so for instance,
757 `double_` recognizes integer numbers (without a dot) just as well. To
758 avoid this ambiguity, `strict_ureal_policies` and `strict_real_policies`
759 require a dot to be present for a number to be considered a successful
762 [heading `RealPolicies` Expression Requirements]
764 For models of `RealPolicies` the following expressions must be valid:
767 [[Expression] [Semantics]]
768 [[`RP::allow_leading_dot`] [Allow leading dot.]]
769 [[`RP::allow_trailing_dot`] [Allow trailing dot.]]
770 [[`RP::expect_dot`] [Require a dot.]]
771 [[`RP::parse_sign(f, l)`] [Parse the prefix sign (e.g. '-').
772 Return `true` if successful, otherwise `false`.]]
773 [[`RP::parse_n(f, l, n)`] [Parse the integer at the left of the decimal point.
774 Return `true` if successful, otherwise `false`.
775 If successful, place the result into `n`.]]
776 [[`RP::parse_dot(f, l)`] [Parse the decimal point.
777 Return `true` if successful, otherwise `false`.]]
778 [[`RP::parse_frac_n(f, l, n)`] [Parse the fraction after the decimal point.
779 Return `true` if successful, otherwise `false`.
780 If successful, place the result into `n`.]]
781 [[`RP::parse_exp(f, l)`] [Parse the exponent prefix (e.g. 'e').
782 Return `true` if successful, otherwise `false`.]]
783 [[`RP::parse_exp_n(f, l, n)`] [Parse the actual exponent.
784 Return `true` if successful, otherwise `false`.
785 If successful, place the result into `n`.]]
786 [[`RP::parse_nan(f, l, n)`] [Parse a NaN.
787 Return `true` if successful, otherwise `false`.
788 If successful, place the result into `n`.]]
789 [[`RP::parse_inf(f, l, n)`] [Parse an Inf.
790 Return `true` if successful, otherwise `false`.
791 If successful, place the result into `n`.]]
794 The `parse_nan` and `parse_inf` functions get called whenever:
796 [:a number to parse does not start with a digit (after having
797 successfully parsed an optional sign)]
801 [:after a real number of the value 1 (having no exponential
802 part and a fractional part value of 0) has been parsed.]
804 The first call recognizes representations of NaN or Inf starting with a
805 non-digit character (such as NaN, Inf, QNaN etc.). The second call
806 recognizes representation formats starting with a `1.0` (such as
807 `"1.0#NAN"` or `"1.0#INF"` etc.).
809 The functions should return true if a Nan or Inf has been found. In this
810 case the attribute `n` should be set to the matched value (NaN or Inf).
811 The optional sign will be automatically applied afterwards.
813 [heading `RealPolicies` Specializations]
815 The easiest way to implement a proper real parsing policy is to derive a
816 new type from the type `real_policies` while overriding the aspects
817 of the parsing which need to be changed. For example, here's the
818 implementation of the predefined `strict_real_policies`:
820 template <typename T>
821 struct strict_real_policies : real_policies<T>
823 static bool const expect_dot = true;
828 [note The test harness for the example(s) below is presented in the
829 __qi_basics_examples__ section.]
831 Some using declarations:
833 [reference_using_declarations_real]
835 Basic real number parsing:
839 A custom real number policy:
841 [reference_test_real_policy]
845 [reference_custom_real]
847 [endsect] [/ Real Numbers]
849 [/------------------------------------------------------------------------------]
850 [section:boolean Boolean Parser (`bool_`)]
852 [heading Description]
854 The `bool_parser` can parse booleans of arbitrary type, `B`. The boolean base
855 type `T` can be a user defined boolean type as long as the type follows certain
856 expression requirements (documented below).
860 // forwards to <boost/spirit/home/qi/numeric/bool.hpp>
861 #include <boost/spirit/include/qi_bool.hpp>
863 Also, see __include_structure__.
869 [[`boost::spirit::bool_ // alias: boost::spirit::qi::bool_`]]
870 [[`boost::spirit::true_ // alias: boost::spirit::qi::true_`]]
871 [[`boost::spirit::false_ // alias: boost::spirit::qi::false_`]]
876 template <typename T, typename BooleanPolicies>
879 [heading Template parameters]
882 [[Parameter] [Description] [Default]]
883 [[`B`] [The boolean type of the
884 boolean parser.] [`bool`]]
885 [[`BooleanPolicies`] [Policies control the
886 parser's behavior.] [`bool_policies<B>`]]
891 [:__primitive_parser_concept__]
893 [variablelist Notation
894 [[`BP`] [A boolean `Policies` (type).]]
895 [[`b`] [An object of `B`, the numeric base type.]]
896 [[`boolean`] [Numeric literal, any boolean value, or a
897 __qi_lazy_argument__ that evaluates to a boolean value.]]
898 [[`f`, `l`] [__fwditer__. first/last iterator pair.]]
899 [[`attr`] [An attribute value.]]
900 [[`Context`] [The type of the parse context of the current invocation of
901 the `bool_` parser.]]
902 [[`ctx`] [An instance of the parse context, `Context`.]]
905 [heading Expression Semantics]
907 Semantics of an expression is defined only where it differs from, or is
908 not defined in __primitive_parser_concept__.
918 [Parse a boolean using the default policies (`bool_policies<T>`).]
924 [Match the literal `boolean` using the default policies (`bool_policies<T>`).
925 The parser will fail if the parsed value is not equal to the specified
932 [Match `"true"` and `"false"`, respectively.]
939 [Parse a real of type `T` using `BoolPolicies`.]
946 [Match the literal `boolean` of type `T` using `BoolPolicies`. The parser will fail
947 if the parsed value is not equal to the specified value.]
951 [note All boolean parsers properly respect the __qi_no_case__`[]` directive.]
987 [:O(N), where N is the number of characters being parsed.]
989 [heading Minimum Expression Requirements for `B`]
991 The boolean type, `B`, the minimum expression requirements listed
992 below must be valid. Take note that additional requirements may be
993 imposed by custom policies.
996 [[Expression] [Semantics]]
997 [[`B(bool)`] [Constructible from a `bool`.]]
1000 [heading Boolean `Policies`]
1002 The boolean `Policies` template parameter is a class that groups all the
1003 policies that control the parser's behavior. Policies control the boolean
1006 The default is `bool_policies<bool>`. The default is provided to take care
1007 of the most common case (there are many ways to represent, and hence
1008 parse, boolean numbers). In most cases, the default policies are sufficient
1009 and can be used straight out of the box. They are designed to parse
1010 boolean value of the form `"true"` and `"false"`.
1012 [heading Boolean `Policies` Expression Requirements]
1014 For models of boolean `Policies` the following expressions must be valid:
1017 [[Expression] [Semantics]]
1018 [[`BP::parse_true(f, l, attr, ctx)`] [Parse a `true` value.]]
1019 [[`BP::parse_false(f, l, attr, ctx)`] [Parse a `false` value.]]
1022 The functions should return true if the required representations of `true` or
1023 `false` have been found. In this case the attribute `n` should be set to the
1024 matched value (`true` or `false`).
1026 [heading Boolean `Policies` Specializations]
1028 The easiest way to implement a proper boolean parsing policy is to derive a
1029 new type from the type `bool_policies` while overriding the aspects
1030 of the parsing which need to be changed. For example, here's the
1031 implementation of a boolean parsing policy interpreting the string `"eurt"`
1032 (i.e. "true" spelled backwards) as `false`:
1034 struct backwards_bool_policies : qi::bool_policies<>
1036 // we want to interpret a 'true' spelled backwards as 'false'
1037 template <typename Iterator, typename Attribute, typename Context>
1039 parse_false(Iterator& first, Iterator const& last, Attribute& attr, Context& ctx)
1041 namespace qi = boost::spirit::qi;
1042 if (qi::detail::string_parse("eurt", first, last, qi::unused, qi::unused))
1044 spirit::traits::assign_to(false, attr, ctx); // result is false
1053 [note The test harness for the example(s) below is presented in the
1054 __qi_basics_examples__ section.]
1056 Some using declarations:
1058 [reference_using_declarations_bool]
1060 Basic real number parsing:
1064 A custom real number policy:
1066 [reference_test_bool_policy]
1070 [reference_custom_bool]
1072 [endsect] [/ Real Numbers]