![]() |
Home | Libraries | People | FAQ | More |
The int_parser can parse
signed integers of arbitrary length and size. This is almost the same
as the uint_parser. The
only difference is the additional task of parsing the '+'
or '-' sign preceding the number.
The class interface is the same as that of the uint_parser.
The int_parser parser
can be used to parse ordinary primitive C/C++ integers or even user defined
scalars such as bigints (unlimited precision integers) as long as the
type follows certain expression requirements (documented below).
// forwards to <boost/spirit/home/qi/numeric/int.hpp> #include <boost/spirit/include/qi_int.hpp>
Also, see Include Structure.
|
Name |
|---|
|
|
|
|
|
|
|
|
![]() |
Important |
|---|---|
|
template < typename T , unsigned Radix , unsigned MinDigits , int MaxDigits> struct int_parser;
|
Parameter |
Description |
Default |
|---|---|---|
|
|
The numeric base type of the numeric parser. |
none |
|
|
The radix base. This can be either 2: binary, 8: octal, 10: decimal and 16: hexadecimal. |
10 |
|
|
The minimum number of digits allowable. |
1 |
|
|
The maximum number of digits allowable. If this is -1, then the maximum limit becomes unbounded. |
-1 |
Notation
NP
An instance of int_parser
(type).
n
An object of T,
the numeric base type.
Semantics of an expression is defined only where it differs from, or
is not defined in PrimitiveParser.
|
Expression |
Semantics |
|---|---|
|
|
Instantiate and (default) construct an |
|
|
Create an |
|
|
Create an |
|
|
Create an |
|
|
Create an |
T, The numeric base type of the numeric parser.
O(N), where N is the number of digits being parsed plus the sign.
T
For the numeric base type, T,
the expression requirements below must be valid:
|
Expression |
Semantics |
|---|---|
|
|
Default construct. |
|
|
Construct from an |
|
|
Addition. |
|
|
Subtraction. |
|
|
Multiplication. |
|
|
|
|
|
Maximum Digits for |
|
|
Maximum Digits for |
|
|
Maximum value for |
|
|
Minimum value for |
![]() |
Note |
|---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some using declarations:
using boost::spirit::qi::int_;
Basic signed integers:
test_parser("+12345", int_); test_parser("-12345", int_);