|  | Home | Libraries | People | FAQ | More | 
            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 | 
|---|
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
               | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
               | 
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 any base from 2..10 and 16 | 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
n
                  An object of T,
                  the numeric base type.
                
numNumeric literal, any unsigned integer value, or a Lazy Argument that evaluates to a unsigned integer value.
            Semantics of an expression is defined only where it differs from, or
            is not defined in PrimitiveParser.
          
| Expression | Semantics | 
|---|---|
| 
 ushort_ uint_ ulong_ ulong_long 
 | Parse an unsigned integer using the default radix (10). | 
| 
 lit(num) ushort_(num) uint_(num) ulong_(num) ulong_long(num) 
 | 
                      Match the literal  | 
| 
 bin oct hex 
 | 
                      Parse an unsigned integer using radix 2 for  | 
| 
 bin(num) oct(num) hex(num) 
 | 
                      Match the literal  | 
| 
 uint_parser< T, Radix, MinDigits, MaxDigits >() 
 | 
                      Parse an unsigned integer of type  | 
| 
 uint_parser< T, Radix, MinDigits, MaxDigits >()(num) 
 | 
                      Match the literal  | 
| ![[Important]](../../../../images/important.png) | Important | 
|---|---|
| 
              All numeric parsers check for overflow conditions based on the type
               | 
| Expression | Attribute | 
|---|---|
| 
 lit(num) 
 | 
                       | 
| 
 ushort_ ushort_(num) 
 | 
                       | 
| 
 uint_ uint_(num) bin bin(num) oct oct(num) hex hex(num) 
 | 
                       | 
| 
 ulong_ ulong_(num) 
 | 
                       | 
| 
 ulong_long ulong_long(num) 
 | 
                       | 
| 
 uint_parser< T, Radix, MinDigits, MaxDigits >() uint_parser< T, Radix, MinDigits, MaxDigits >()(num) 
 | 
                       | 
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]](../../../../images/note.png) | Note | 
|---|---|
| The test harness for the example(s) below is presented in the Basics Examples section. | 
Some using declarations:
using boost::phoenix::val; using boost::spirit::qi::lit; using boost::spirit::qi::uint_; using boost::spirit::qi::uint_parser;
Basic unsigned integers:
// unsigned int test_parser("12345", uint_); test_parser("12345", uint_(12345)); test_parser("12345", uint_(val(12345))); // literals test_parser("12345", lit(12345)); test_parser("12345", lit(val(12345)));
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));