Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/locale/moneypunct"

From cppreference.com
< cpp‎ | locale
m (Update links.)
(move dsc items to templates)
Line 32: Line 32:
 
===Member functions===
 
===Member functions===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc mem ctor      | cpp/locale/moneypunct/moneypunct  | constructs a new moneypunct facet }}
+
{{dsc inc | cpp/locale/moneypunct/dsc constructor}}
{{dsc prot mem dtor | cpp/locale/moneypunct/~moneypunct | destructs a moneypunct facet }}
+
{{dsc inc | cpp/locale/moneypunct/dsc destructor}}
{{dsc h2 |  }}
+
{{dsc inc | cpp/locale/moneypunct/dsc decimal_point}}
{{dsc mem fun | cpp/locale/moneypunct/decimal_point | invokes {{tt|do_decimal_point}}  }}
+
{{dsc inc | cpp/locale/moneypunct/dsc grouping}}
{{dsc mem fun | cpp/locale/moneypunct/thousands_sep | invokes {{tt|do_thousands_sep}} }}
+
{{dsc inc | cpp/locale/moneypunct/dsc curr_symbol}}
{{dsc mem fun | cpp/locale/moneypunct/grouping | invokes {{tt|do_grouping}} }}
+
{{dsc inc | cpp/locale/moneypunct/dsc positive_sign}}
{{dsc mem fun | cpp/locale/moneypunct/curr_symbol | invokes {{tt|do_curr_symbol}} }}
+
{{dsc inc | cpp/locale/moneypunct/dsc negative_sign}}
{{dsc mem fun | cpp/locale/moneypunct/positive_sign | invokes {{tt|do_positive_sign}} }}
+
{{dsc inc | cpp/locale/moneypunct/dsc frac_digits}}
{{dsc mem fun | cpp/locale/moneypunct/negative_sign | invokes {{tt|do_negative_sign}} }}
+
{{dsc inc | cpp/locale/moneypunct/dsc pos_format}}
{{dsc mem fun | cpp/locale/moneypunct/frac_digits | invokes {{tt|do_frac_digits}} }}
+
{{dsc inc | cpp/locale/moneypunct/dsc neg_format}}
{{dsc mem fun | cpp/locale/moneypunct/pos_format | invokes {{tt|do_pos_format}} }}
+
{{dsc mem fun | cpp/locale/moneypunct/neg_format | invokes {{tt|do_neg_format}} }}
+
 
{{dsc end}}
 
{{dsc end}}
  
 
===Protected member functions===
 
===Protected member functions===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc prot mem vfun | cpp/locale/moneypunct/decimal_point | title=do_decimal_point | provides the character to use as decimal point}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_decimal_point}}
{{dsc prot mem vfun | cpp/locale/moneypunct/thousands_sep | title=do_thousands_sep | provides the character to use as thousands separator}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_grouping}}
{{dsc prot mem vfun | cpp/locale/moneypunct/grouping | title=do_grouping     | provides the numbers of digits between each pair of thousands separators}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_curr_symbol}}
{{dsc prot mem vfun | cpp/locale/moneypunct/curr_symbol | title=do_curr_symbol   | provides the string to use as the currency identifier}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_positive_sign}}
{{dsc prot mem vfun | cpp/locale/moneypunct/positive_sign | title=do_positive_sign | provides the string to indicate a positive value}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_negative_sign}}
{{dsc prot mem vfun | cpp/locale/moneypunct/negative_sign | title=do_negative_sign | provides the string to indicate a negative value}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_frac_digits}}
{{dsc prot mem vfun | cpp/locale/moneypunct/frac_digits | title=do_frac_digits   | provides the number of digits to display after the decimal point}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_pos_format}}
{{dsc prot mem vfun | cpp/locale/moneypunct/pos_format | title=do_pos_format   | provides the formatting pattern for positive values}}
+
{{dsc inc | cpp/locale/moneypunct/dsc do_neg_format}}
{{dsc prot mem vfun | cpp/locale/moneypunct/neg_format | title=do_neg_format   | provides the formatting pattern for negative values}}
+
 
{{dsc end}}
 
{{dsc end}}
  

Revision as of 18:47, 5 June 2013

 
 
 
 
Defined in header <locale>
template< class CharT, bool International = false >
class moneypunct;

The facet std::moneypunct encapsulates monetary value format preferences. Stream I/O manipulators std::get_money and std::put_money use std::moneypunct through std::money_get and std::money_put for parsing monetary value input and formatting monetary value output.

cpp/locale/money basecpp/locale/locale/facetstd-moneypunct-inheritance.svg

Inheritance diagram

Four specializations are provided by the standard library

Defined in header <locale>
std::moneypunct<char> provides equivalents of the "C" locale preferences
std::moneypunct<wchar_t> provides wide character equivalents of the "C" locale preferences
std::moneypunct<char, true> provides equivalents of the "C" locale preferences, with international currency symbols
std::moneypunct<wchar_t, true> provides wide character equivalents of the "C" locale preferences, with international currency symbols

Contents

Member types

Member type Definition
char_type charT
string_type std::basic_string<charT>

Member functions

constructs a new moneypunct facet
(public member function) [edit]
destructs a moneypunct facet
(protected member function) [edit]
invokes do_decimal_point
(public member function) [edit]
invokes do_grouping
(public member function) [edit]
invokes do_curr_symbol
(public member function) [edit]
invokes do_positive_sign or do_negative_sign
(public member function) [edit]
invokes do_negative_sign
(public member function) [edit]
invokes do_frac_digits
(public member function) [edit]
invokes do_pos_format/do_neg_format
(public member function) [edit]
invokes do_neg_format
(public member function) [edit]

Protected member functions

provides the character to use as decimal point
(virtual protected member function) [edit]
[virtual]
provides the numbers of digits between each pair of thousands separators
(virtual protected member function) [edit]
provides the string to use as the currency identifier
(virtual protected member function) [edit]
provides the string to indicate a positive or negative value
(virtual protected member function) [edit]
provides the string to indicate a negative value
(virtual protected member function) [edit]
provides the number of digits to display after the decimal point
(virtual protected member function) [edit]
provides the formatting pattern for currency values
(virtual protected member function) [edit]
provides the formatting pattern for negative values
(virtual protected member function) [edit]

Member constants

Member Definition
const bool intl (static) International

Member objects

static std::locale::id id
id of the locale
(public member object)

Inherited from std::money_base

Member type Definition
enum part { none, space, symbol, sign, value }; unscoped enumeration type
struct pattern { char field[4]; }; the monetary format type
Enumeration constant Definition
none whitespace is permitted but not required except in the last position, where whitespace is not permitted
space one or more whitespace characters are required
symbol the sequence of characters returned by moneypunct::curr_symbol is required
sign the first of the characters returned by moneypunct::positive_sign or moneypunct::negative_sign is required
value the absolute numeric monetary value is required

Example

#include <iostream>
#include <locale>
int main()
{
    std::locale jp("ja_JP.UTF-8");
    std::cout << "japanese currency symbol is "
              << std::use_facet<std::moneypunct<char, true>>(jp).curr_symbol()
              << "or "
              << std::use_facet<std::moneypunct<char>>(jp).curr_symbol()
              << " for short\n";
}

Output:

japanese currency symbol is JPY or ¥ for short

See also

defines monetary formatting patterns
(class) [edit]
represents the system-supplied std::moneypunct for the named locale
(class template) [edit]
parses and constructs a monetary value from an input character sequence
(class template) [edit]
formats a monetary value for output as a character sequence
(class template) [edit]