|  | 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 | 
|---|
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
               | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
               | 
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 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 signed integer value, or a Lazy Argument that evaluates to a signed integer value.
            Semantics of an expression is defined only where it differs from, or
            is not defined in PrimitiveParser.
          
| Expression | Semantics | 
|---|---|
| 
 short_ int_ long_ long_long 
 | Parse a signed integer using the default radix (10). | 
| 
 lit(num) short_(num) int_(num) long_(num) long_long(num) 
 | 
                      Match the literal  | 
| 
 int_parser< T, Radix, MinDigits, MaxDigits >() 
 | 
                      Parse a signed integer of type  | 
| 
 int_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) 
 | 
                       | 
| 
 short_ short_(num) 
 | 
                       | 
| 
 int_ int_(num) 
 | 
                       | 
| 
 long_ long_(num) 
 | 
                       | 
| 
 long_long long_long(num) 
 | 
                       | 
| 
 int_parser< T, Radix, MinDigits, MaxDigits >() int_parser< T, Radix, MinDigits, MaxDigits >()(num) 
 | 
                       | 
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]](../../../../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::int_;
Basic signed integers:
// signed int test_parser("+12345", int_); test_parser("-12345", int_); test_parser("+12345", int_(12345)); test_parser("-12345", int_(-12345)); test_parser("+12345", int_(val(12345))); test_parser("-12345", int_(val(-12345))); // literals test_parser("+12345", lit(12345)); test_parser("-12345", lit(-12345)); test_parser("+12345", lit(val(12345))); test_parser("-12345", lit(val(-12345)));