...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The uint_parser
class
is the simplest among the members of the numerics package. The uint_parser
can parse unsigned integers
of arbitrary length and size. The uint_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). The uint_parser
is a template class. Template parameters fine tune its behavior.
// forwards to <boost/spirit/home/qi/numeric/uint.hpp> #include <boost/spirit/include/qi_uint.hpp>
Also, see Include Structure.
Name |
---|
|
|
|
|
|
|
|
Important | |
---|---|
|
template < typename T , unsigned Radix , unsigned MinDigits , int MaxDigits> struct uint_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 uint_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 a |
|
Create a |
|
Create a |
|
Create a |
|
Create a |
|
Create a |
|
Create a |
|
Create a |
T
, The numeric base type of the numeric parser.
O(N), where N is the number of digits being parsed.
T
For the numeric base type, T
,
the expression requirements below must be valid:
Expression |
Semantics |
---|---|
|
Default construct. |
|
Construct from an |
|
Addition. |
|
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::uint_; using boost::spirit::qi::uint_parser;
Basic unsigned integers:
test_parser("12345", uint_);
Thousand separated number parser:
uint_parser<unsigned, 10, 1, 3> uint3_p; // 1..3 digits uint_parser<unsigned, 10, 3, 3> uint3_3_p; // exactly 3 digits test_parser("12,345,678", uint3_p >> *(',' >> uint3_3_p));