Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

money_get

Library:  Localization


money_get locale::facet

Local Index

Members

Summary

A monetary parsing facet.

Synopsis

#include <locale>

namespace std {
  template <class charT,
            class InputIterator = istreambuf_iterator<charT> >
  class money_get;
}

Specializations

The primary template can be implicitly or explicitly specialized on any character type that satisfies the requirements on the type of the character used by iostream class templates, and on any iterator type that satisfies the requirements of Output Iterator.

Description

The money_get facet includes facilities for parsing sequences of characters and interpreting them as monetary values. The facet is not used by any other C++ Standard Library components.

Interface

Member Types

char_type
iter_type
string_type

Constructor

explicit money_get(size_t refs = 0) 

Static Members

static locale::id id; 

Public Member Functions

The public members of the money_get facet include an interface to protected members. Each public member get() calls the corresponding protected virtual protected member do_get().

iter_type 
get(iter_type s, iter_type end, bool intl, ios_base& f,
    ios_base::iostate& err, long double& units) const;
iter_type 
get(iter_type s, iter_type end, bool intl, ios_base& f,
    ios_base::iostate& err, string_type& digits) const; 

Protected Member Functions

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

The io argument is used to obtain a reference to the moneypunct<char_type, intl> facet installed in the object's locale and containing locale-specific punctuation data (the format of the monetary value, the currency symbol, the negative and positive signs, the number of significant digits after the decimal point, the grouping, the thousands separator, and the decimal point), to obtain a reference to the ctype<char_type> facet installed in the same locale needed to interpret the parsed characters, and to determine whether the currency symbol is optional or required. If the functions reach the end of the input sequence while attempting to extract additional characters, they set ios_base::eofbit in err.

The functions use the result of use_facet<moneypunct<char_type, intl> >(io.getloc()).neg_format() to parse all sequences. Where money_base::none or money_base::space appears in the format, any optional whitespace characters, as determined by isspace(c, io.getloc ()), are extracted from the input sequence after the required space, if any. Trailing whitespace is never extracted, even when followed by the currency symbol, unless the latter is required (see below). Where money_base::sign appears in the format, the first character (if any) of either the negative sign or the positive sign, as determined by use_facet<moneypunct<char_type, intl> >(io.getloc()).negative_sign() and positive_sign(), respectively, is required. Any remaining characters of the sign are extracted only after all other components of the format, including any whitespace, have been successfully extracted. If the first character of the positive sign is equal to the first character of the negative sign, or if both are empty, the extracted value is assumed to be positive. Where money_base::value appears in the format, a sequence of digits, as determined by isdigit(c, io.getloc()), optionally iterspersed with thousands separators (see below), is extracted. If (use_facet<moneypunct<char_type, intl> >(io.getloc()).frac_digits() > 0) is true the sequence of digits may be immediately followed by the decimal point and, optionally, by additional digits (no thousands separators are allowed); in that case the extracted value is multiplied by 10 to the power of fd, where fd is the number of fractional digits, and truncated to an integer before storing.

If (io.flags () & ios_base::showbase) is non-zero, the currency symbol is required; otherwise the currency symbol is optional and is only extracted from the input sequence if other components of the monetary value are necessary to complete it.

If use_facet<moneypunct<char_type, intl> >(io.getloc()).grouping() returns a non-empty string, the positions of any characters found in the input sequence prior to the character returned by use_facet<moneypunct<char_type, intl> >(io.getloc()).decimal_point(), if any, which match that returned by use_facet<moneypunct<char_type> >(io.getloc()).thousands_sep() are checked for consistency with the grouping string. The functions indicate inconsistencies in the placement of thousands speratators by setting ios_base::failbit in err. If the grouping is empty, the first thousands separator terminates input.

Example

See Also

locale, Facets, money_put, moneypunct

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 22.2.6.1



Previous fileTop of DocumentContentsIndex pageNext file Copyright © 2003-2006, The Apache Software Foundation