struct integer_constant
encapsulates an integer constant
More...
#include <integer_constant.h>
|
template<class CharSeq > |
static unsigned long long | decode_utf8 (chewer< CharSeq > &chew) |
| Decode an UTF-8 encoded character from a text offset. More...
|
|
template<class CharSeq > |
static int | read_char_escaping (chewer< CharSeq > &chew) |
| Read a possibly escaped ASCII character from a text offset, returning its escaped value. More...
|
|
template<class CharSeq > |
static std::pair< unsigned
long long, bool > | read_based_numeral (unsigned base, chewer< CharSeq > &chew) |
| Read a numeral of known base from a text pointer, returning a value and overflow indicator. More...
|
|
template<class CharSeq > |
static unsigned long long | read_encoded_char (int base, chewer< CharSeq > &chew) |
| Read a numerically encoded character constant from a text offset, returning its value as an integer . More...
|
|
struct integer_constant
encapsulates an integer constant
Definition at line 49 of file integer_constant.h.
template<class CharSeq >
static unsigned long long integer_constant::decode_utf8 |
( |
chewer< CharSeq > & |
chew | ) |
|
|
staticprivate |
Decode an UTF-8 encoded character from a text offset.
- Template Parameters
-
CharSeq | A character-sequence type |
- Parameters
-
chew | On entry, a chewer<CharSeq> positioned at the offset in the associated CharSeq from which to scan. On returnchew is positioned to the first offset not consumed. |
- Returns
- The integer value of the UTF-8 character parsed, or
ULLONG_MAX
if none is parsed.
template<class CharSeq >
static std::pair<unsigned long long,bool> integer_constant::read_based_numeral |
( |
unsigned |
base, |
|
|
chewer< CharSeq > & |
chew |
|
) |
| |
|
staticprivate |
Read a numeral of known base from a text pointer, returning a value and overflow indicator.
- Template Parameters
-
CharSeq | A character-sequence type. |
- Parameters
-
base | The arithmetic base in which the numeral is to be evaluated. |
chew | On entry, a chewer<CharSeq> positioned at the offset in the associated CharSeq from which to scan. On returnchew is positioned to the first offset not consumed. |
- Returns
- An
std::pair
containing, first, the integer value of the parsed numeral; second, a bool that is true if the value of the parsed numeral overflows unsigned long long, in which case the returned integer value is not valid.
The function consumes characters from chew
for as long as they can form part of a numeral with the indicated base.
template<class CharSeq >
static integer integer_constant::read_char |
( |
chewer< CharSeq > & |
chew | ) |
|
|
static |
Read a character constant from a text offset, returning its value as an integer
.
- Template Parameters
-
CharSeq | A character-sequence type |
- Parameters
-
chew | On entry, a chewer<CharSeq> positioned at the offset in the associated CharSeq from which to scan. On returnchew is positioned to the first offset not consumed. |
- Returns
- An
integer
that represents the integer value of the parsed character constant, or integer(UNDEF)
is no valid constant is parsed.
template<class CharSeq >
static int integer_constant::read_char_escaping |
( |
chewer< CharSeq > & |
chew | ) |
|
|
staticprivate |
Read a possibly escaped ASCII character from a text offset, returning its escaped value.
- Template Parameters
-
CharSeq | A character-sequence type |
- Parameters
-
chew | On entry, a chewer<CharSeq> positioned at the offset in the associated CharSeq from which to scan. On returnchew is positioned to the first offset not consumed. |
- Returns
- The integer value of the possibly escaped character consumed, if any, else
EOF
.
If chew
is not out of range and addresses the escape character '\' on entry then that character is consumed and, if chew + 1
is not out of range, the escaped value of the next character is returned. If chew + 1
is out of range then EOF
is returned.
If chew
does not address the escape character on entry and is is not out range, the integer value of the character addressed is returned; otherwise EOF.
template<class CharSeq >
static unsigned long long integer_constant::read_encoded_char |
( |
int |
base, |
|
|
chewer< CharSeq > & |
chew |
|
) |
| |
|
staticprivate |
Read a numerically encoded character constant from a text offset, returning its value as an integer
.
- Template Parameters
-
CharSeq | A character-sequence type. |
- Parameters
-
base | The presumed base of the constant, either 8 (octal) or 16 (hex). |
chew | On entry, a chewer<CharSeq> positioned at the offset in the associated CharSeq from which to scan. On returnchew is positioned to the first offset not consumed. |
- Returns
- The integer value of encoded constant, if any is found, else
ULONG_MAX
.
A constant at chew
will be enclosed in single quotes. On entry chew
shall address the opening single quote.
template<class CharSeq >
static integer integer_constant::read_numeral |
( |
chewer< CharSeq > & |
chew | ) |
|
|
static |
Read a numeral from a chewer<CharSeq>
- Template Parameters
-
CharSeq | A character-sequence type |
- Parameters
-
chew | On entry, a chewer<CharSeq> positioned at the offset in the associated CharSeq from which to scan. On returnchew is positioned to the first offset not consumed. |
- Returns
- An
integer
that represents the integer value of the numeral, unless the value is too big for the explicit or implied type of the numeral in which case integer(INT_UNDEF)
is returned.
The parsed numeral is attributed type signed int unless an a type suffix indicates otherwise.
The numeral may include any of the type-indicating suffixes 'L', 'LL' 'UL', 'LU', 'ULL', 'LLU' or their case-variants.
The string "0x" or "0X" is parsed as a valid numeral "0" followed by 'x' or 'X'.
The documentation for this struct was generated from the following file: