num_get::do_get

A virtual function that is called to extracts a numerical or Boolean value from a character sequence.

virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    long& _Val
) const;virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    unsigned short& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    unsigned int& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    unsigned long& _Val
) const;
virtual iter_type do_get(
    iter_type _First, 
    iter_type _Last,
    ios_base& _Iosbase, 
    ios_base::iostate& _State,
    long long& _Val
) const;
virtual iter_type do_get(
    iter_type _First, 
    iter_type _Last,
    ios_base& _Iosbase, 
    ios_base::iostate& _State,
    unsigned long long& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    float& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    double& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    long double& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    void *& _Val
) const;
virtual iter_type do_get(
    iter_type _First,
    iter_type _Last,
    ios_base& _Iosbase,
    ios_base::iostate& _State,
    bool& _Val
) const;

Parameters

  • _First
    The beginning of the range of characters from which to read the number.

  • _Last
    The end of the range of characters from which to read the number.

  • _Iosbase
    The ios_base whose flags are used by the conversion.

  • _State
    The state to which failbit (see ios_base::iostate) is added upon failure.

  • _Val
    The value that was read.

Return Value

The iterator after the value has been read.

Remarks

The first virtual protected member function,

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

long& _Val

) const;

matches sequential elements beginning at _First in the sequence [_First, _Last) until it has recognized a complete, nonempty integer input field. If successful, it converts this field to its equivalent value as type long, and stores the result in _Val. It returns an iterator designating the first element beyond the numeric input field. Otherwise, the function stores nothing in _Val and sets ios_base::failbit in state. It returns an iterator designating the first element beyond any prefix of a valid integer input field. In either case, if the return value equals last, the function sets ios_base::eofbit in state.

The integer input field is converted by the same rules used by the scan functions for matching and converting a series of char elements from a file. (Each such char element is assumed to map to an equivalent element of type Elem by a simple, one-to-one, mapping.) The equivalent scan conversion specification is determined as follows:

If iosbase.ios_base::flags() & ios_base::basefield == ios_base::oct, the conversion specification is lo.

If iosbase.flags() & ios_base::basefield == ios_base::hex, the conversion specification is lx.

If iosbase.flags() & ios_base::basefield == 0, the conversion specification is li.

Otherwise, the conversion specification is ld.

The format of an integer input field is further determined by the locale facet fac returned by the call use_facet <numpunct<Elem>(iosbase. ios_base::getloc()). Specifically:

fac.numpunct::grouping() determines how digits are grouped to the left of any decimal point

fac.numpunct::thousands_sep() determines the sequence that separates groups of digits to the left of any decimal point.

If no instances of fac.thousands_sep() occur in the numeric input field, no grouping constraint is imposed. Otherwise, any grouping constraints imposed by fac.grouping() are enforced and separators are removed before the scan conversion occurs.

The fourth virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

unsigned long& _Val

) const;

behaves the same as the first, except that it replaces a conversion specification of ld with lu. If successful it converts the numeric input field to a value of type unsigned long and stores that value in _Val.

The fifth virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

long long& _Val

) const;

behaves the same as the first, except that it replaces a conversion specification of ld with lld. If successful it converts the numeric input field to a value of type long long and stores that value in _Val.

The sixth virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

unsigned long long& _Val

) const;

behaves the same as the first, except that it replaces a conversion specification of ld with llu. If successful it converts the numeric input field to a value of type unsigned long long and stores that value in _Val.

The seventh virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

float& _Val

) const;

behaves the same as the first, except that it endeavors to match a complete, nonempty floating-point input field. fac.numpunct::decimal_point() determines the sequence that separates the integer digits from the fraction digits. The equivalent scan conversion specifier is lf.

The eighth virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

double& _Val

) const;

behaves the same as the first, except that it endeavors to match a complete, nonempty floating-point input field. fac.numpunct::decimal_point() determines the sequence that separates the integer digits from the fraction digits. The equivalent scan conversion specifier is lf.

The ninth virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

long double& _Val

) const;

behaves the same as the eighth, except that the equivalent scan conversion specifier is Lf.

The ninth virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

void *& _Val

) const;

behaves the same the first, except that the equivalent scan conversion specifier is p.

The last (eleventh) virtual protected member function:

virtual iter_type do_get(

iter_type _First,

iter_type _Last,

ios_base& _Iosbase,

ios_base::iostate& _State,

bool& _Val

) const;

behaves the same as the first, except that it endeavors to match a complete, nonempty Boolean input field. If successful it converts the Boolean input field to a value of type bool and stores that value in _Val.

A Boolean input field takes one of two forms. If iosbase.flags() & ios_base::boolalpha is false, it is the same as an integer input field, except that the converted value must be either 0 (for false) or 1 (for true). Otherwise, the sequence must match either fac.numpunct::falsename() (for false), or fac.numpunct::truename() (for true).

Example

See the example for get, where the virtual member function is called by do_get.

Requirements

Header: <locale>

Namespace: std

See Also

Reference

num_get Class

Other Resources

num_get Members