Name

money_get class template — Facet for input of monetary values

Example

As with other facets, the public members call virtual, protected members with the same name prefaced by do_. Thus, to use the facet, call the public function get, which calls do_get. The description below is for the virtual functions because they do the real work. Imagine that for each virtual-function description, there is a corresponding description for a public, nonvirtual function, such as:

The following are the virtual, protected members of money_get:

virtual iter_type do_get (iter_type begin, iter_type end, bool intl, ios_base& stream, ios_base::iostate& err, long double& units) const, virtual iter_type do_get (iter_type begin, iter_type end, bool intl, ios_base& stream, ios_base::iostate& err, string_type& digits) const

Reads characters in the range [begin, end) and interprets them as a monetary value. If intl is true, the value is parsed using international format; otherwise, local format is used. That is, the intl value is used as the Intl template parameter to moneypunct<char_type, Intl>. If a valid monetary value is read from the input stream, the integral value is stored in units or is formatted as a string in digits. (For example, the input "$1,234.56" yields the units 123456 or the digits "123456".) The digit string starts with an optional minus sign ('-') followed by digits ('0'-'9'), in which each character c is produced by calling ctype<char_type>.widen(c).

If a valid sequence is not found, err is modified to include stream.failbit. If the end of the input is reached without forming a valid monetary value, stream.eofbit is also set.

If the showbase flag is set (stream.flags( ) & stream.showbase is not 0), the currency symbol is required; otherwise, it is optional. Thousands grouping, if the local format supports it, is optional.

The sign of the result is dictated by positive_sign( ) and negative_sign( ) from the moneypunct facet.

The return value is an iterator that points to one past the last character of the monetary value.