moneypunct クラス
このクラス テンプレートは、通貨入力フィールドまたは通貨出力フィールドを表すために使用される CharType 型のシーケンスを表すロケール ファセットとして使用できるオブジェクトを表します。 テンプレート パラメーター Intl が true である場合、国際的な規則が遵守されます。
構文
template <class CharType, bool Intl>
class moneypunct;
パラメーター
CharType
文字をエンコードするためにプログラム内で使用される型。
Intl
国際的な規則を確認するかどうかを指定するフラグ。
注釈
すべてのロケールのファセットと同様、静的オブジェクト ID に最初に格納されている値は 0 です。 格納されている値に初めてアクセスしようとすると、id に一意の正の値が格納されます。
const 静的オブジェクト intl は、テンプレート パラメーター Intl の値を格納します。
コンストラクター
| コンストラクター | 説明 |
|---|---|
| moneypunct | moneypunct 型のオブジェクトのコンストラクター。 |
Typedefs
| 型名 | 説明 |
|---|---|
| char_type | ロケールによって使用される文字を表すために使用される型。 |
| string_type | CharType 型の文字を格納する文字列を表す型。 |
メンバー関数
| メンバー関数 | 説明 |
|---|---|
| curr_symbol | 通貨記号として使用する要素のロケール固有のシーケンスを返します。 |
| decimal_point | 小数点記号として使用する要素のロケール固有のシーケンスを返します。 |
| do_curr_symbol | 通貨記号として使用する要素のロケール固有のシーケンスを返すプロテクト仮想メンバー関数。 |
| do_decimal_point | 小数点記号として使用する要素のロケール固有のシーケンスを返すために呼び出されるプロテクト仮想メンバー関数。 |
| do_frac_digits | このプロテクト仮想メンバー関数は、小数点の右側に表示する桁数のロケール固有の数を返します。 |
| do_grouping | このプロテクト仮想メンバー関数は、小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返します。 |
| do_neg_format | 負の値の出力を書式設定するためのロケール固有の規則を返すために呼び出されるプロテクト仮想メンバー関数。 |
| do_negative_sign | 負の記号として使用する要素のロケール固有のシーケンスを返すために呼び出されるプロテクト仮想メンバー関数。 |
| do_pos_format | 正の値の出力を書式設定するためのロケール固有の規則を返すために呼び出されるプロテクト仮想メンバー関数。 |
| do_positive_sign | 正の記号として使用する要素のロケール固有のシーケンスを返すために呼び出されるプロテクト仮想メンバー関数。 |
| do_thousands_sep | 桁区切り記号として使用する要素のロケール固有のシーケンスを返すために呼び出されるプロテクト仮想メンバー関数。 |
| frac_digits | 小数点の右側に表示する桁数のロケール固有の数を返します。 |
| grouping | 小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返します。 |
| neg_format | 負の値の出力を書式設定するためのロケール固有の規則を返します。 |
| negative_sign | 負の記号として使用する要素のロケール固有のシーケンスを返します。 |
| pos_format | 正の値の出力を書式設定するためのロケール固有の規則を返します。 |
| positive_sign | 正の記号として使用する要素のロケール固有のシーケンスを返します。 |
| thousands_sep | 桁区切り記号として使用する要素のロケール固有のシーケンスを返します。 |
要件
ヘッダー:<locale>
名前空間: std
moneypunct::char_type
ロケールによって使用される文字を表すために使用される型。
typedef CharType char_type;
注釈
この型は、テンプレート パラメーター CharType のシノニムです。
moneypunct::curr_symbol
通貨記号として使用する要素のロケール固有のシーケンスを返します。
string_type curr_symbol() const;
戻り値
通貨記号を含む文字列。
注釈
このメンバー関数は、do_curr_symbol を返します。
例
// moneypunct_curr_symbol.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
const moneypunct < char, true > &mpunct = use_facet < moneypunct < char, true > >(loc);
cout << loc.name( ) << " international currency symbol "<< mpunct.curr_symbol( ) << endl;
const moneypunct < char, false> &mpunct2 = use_facet < moneypunct < char, false> >(loc);
cout << loc.name( ) << " domestic currency symbol "<< mpunct2.curr_symbol( ) << endl;
};
moneypunct::decimal_point
小数点記号として使用する要素のロケール固有のシーケンスを返します。
CharType decimal_point() const;
戻り値
小数点記号として使用する要素のロケール固有のシーケンス。
注釈
このメンバー関数は、do_decimal_point を返します。
例
// moneypunct_decimal_pt.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc("german_germany");
const moneypunct < char, true > &mpunct = use_facet
< moneypunct < char, true > >(loc);
cout << loc.name( ) << " international decimal point "
<< mpunct.decimal_point( ) << endl;
const moneypunct < char, false> &mpunct2 = use_facet
< moneypunct < char, false> >(loc);
cout << loc.name( ) << " domestic decimal point "
<< mpunct2.decimal_point( ) << endl;
}
German_Germany.1252 international decimal point ,
German_Germany.1252 domestic decimal point ,
moneypunct::do_curr_symbol
通貨記号として使用する要素のロケール固有のシーケンスを返すプロテクト仮想メンバー関数。
virtual string_type do_curr_symbol() const;
戻り値
小数点記号として使用する要素のロケール固有のシーケンス。
例
curr_symbol の例 (仮想メンバー関数が curr_symbol で呼び出される) を参照してください。
moneypunct::do_decimal_point
小数点記号として使用する要素のロケール固有のシーケンスを返すプロテクト仮想メンバー関数。
virtual CharType do_decimal_point() const;
戻り値
小数点記号として使用する要素のロケール固有のシーケンス。
例
decimal_point の例 (仮想メンバー関数が decimal_point で呼び出される) を参照してください。
moneypunct::do_frac_digits
小数点の右側に表示する桁数のロケール固有の数を返すプロテクト仮想メンバー関数。
virtual int do_frac_digits() const;
戻り値
小数点の右側に表示する桁数のロケール固有の数。
例
frac_digits の例 (仮想メンバー関数が frac_digits で呼び出される) を参照してください。
moneypunct::do_grouping
小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返すプロテクト仮想メンバー関数。
virtual string do_grouping() const;
戻り値
小数点の左側の数字をグループ化する方法を決定するロケール固有の規則。
例
grouping の例 (仮想メンバー関数が grouping で呼び出される) をご覧ください。
moneypunct::do_neg_format
負の値の出力を書式設定するためのロケール固有の規則を返すために呼び出されるプロテクト仮想メンバー関数。
virtual pattern do_neg_format() const;
戻り値
このプロテクト仮想メンバー関数は、負の値の通貨出力フィールドを生成する方法を決定する、ロケール固有の規則を返します。 pattern::field の 4 つの要素のそれぞれに値を設定できます。
none: 0 個以上の空白に一致するか、何も生成しません。sign: 正の記号または負の記号に一致するか、正の記号または負の記号を生成します。space: 0 個以上の空白に一致するか、1 個の空白を生成します。symbol: 通貨記号に一致するか、通貨記号を生成します。value: 通貨の値に一致するか、通貨の値を生成します。
通貨出力フィールドのコンポーネントが生成され、通貨入力フィールドのコンポーネントが、これらの要素が pattern::field に出現する順序で一致します。 値 sign、symbol、value、および none か space のいずれかが、それぞれ 1 回のみ出現している必要があります。 値 none を最初に出現させることはできません。 値 space を最初または最後に出現させることはできません。 Intl が true の場合、順序は symbol、sign、none、value です。
moneypunct< CharType, Intl > のテンプレート バージョンは、{money_base::symbol, money_base::sign, money_base::value, money_base::none} を返します。
例
neg_format の例 (仮想メンバー関数が neg_format で呼び出される) を参照してください。
moneypunct::do_negative_sign
負の記号として使用する要素のロケール固有のシーケンスを返すために呼び出されるプロテクト仮想メンバー関数。
virtual string_type do_negative_sign() const;
戻り値
負の記号として使用する要素のロケール固有のシーケンス。
例
negative_sign の例 (仮想メンバー関数が negative_sign で呼び出される) を参照してください。
moneypunct::do_pos_format
正の値の出力を書式設定するためのロケール固有の規則を返すために呼び出されるプロテクト仮想メンバー関数。
virtual pattern do_pos_format() const;
戻り値
このプロテクト仮想メンバー関数は、正の値の通貨出力フィールドを生成する方法を決定する、ロケール固有の規則を返します。 (また、通貨入力フィールドのコンポーネントを照合する方法も決定します)。エンコードは、 do_neg_formatの場合と同じです。
moneypunct< CharType, Inputlterator > のテンプレート バージョンは、{ money_base::symbol, money_base::sign, money_base::value, money_base::none } を返します。
例
pos_format の例 (仮想メンバー関数が pos_format で呼び出される) を参照してください。
moneypunct::do_positive_sign
正の記号として使用する要素のロケール固有のシーケンスを返すプロテクト仮想メンバー関数。
virtual string_type do_positive_sign() const;
戻り値
正の記号として使用する要素のロケール固有のシーケンス。
例
positive_sign の例 (仮想メンバー関数が positive_sign で呼び出される) を参照してください。
moneypunct::do_thousands_sep
小数点の左側の桁区切り記号として使用するロケール固有の要素を返すプロテクト仮想メンバー関数。
virtual CharType do_thousands_sep() const;
戻り値
小数点の左側の桁区切り記号として使用するロケール固有の要素。
例
thousands_sep の例 (仮想メンバー関数が thousands_sep で呼び出される) を参照してください。
moneypunct::frac_digits
小数点の右側に表示する桁数のロケール固有の数を返します。
int frac_digits() const;
戻り値
小数点の右側に表示する桁数のロケール固有の数。
注釈
このメンバー関数は、do_frac_digits を返します。
例
// moneypunct_frac_digits.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true> >(loc);
for (unsigned int i = 0; i <mpunct.grouping( ).length( ); i++ )
{
cout << loc.name( ) << " international grouping:\n the "
<< i <<"th group to the left of the radix character "
<< "is of size " << (int)(mpunct.grouping ( )[i])
<< endl;
}
cout << loc.name( ) << " international frac_digits\n to the right"
<< " of the radix character: "
<< mpunct.frac_digits ( ) << endl << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >(loc);
for (unsigned int i = 0; i <mpunct2.grouping( ).length( ); i++ )
{
cout << loc.name( ) << " domestic grouping:\n the "
<< i <<"th group to the left of the radix character "
<< "is of size " << (int)(mpunct2.grouping ( )[i])
<< endl;
}
cout << loc.name( ) << " domestic frac_digits\n to the right"
<< " of the radix character: "
<< mpunct2.frac_digits ( ) << endl << endl;
}
German_Germany.1252 international grouping:
the 0th group to the left of the radix character is of size 3
German_Germany.1252 international frac_digits
to the right of the radix character: 2
German_Germany.1252 domestic grouping:
the 0th group to the left of the radix character is of size 3
German_Germany.1252 domestic frac_digits
to the right of the radix character: 2
moneypunct::grouping
小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返します。
string grouping() const;
戻り値
小数点の左側の数字をグループ化する方法を決定するロケール固有の規則。
注釈
このメンバー関数は、do_grouping を返します。
例
// moneypunct_grouping.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true> >( loc );
for (unsigned int i = 0; i <mpunct.grouping( ).length( ); i++ )
{
cout << loc.name( ) << " international grouping:\n the "
<< i <<"th group to the left of the radix character "
<< "is of size " << (int)(mpunct.grouping ( )[i])
<< endl;
}
cout << loc.name( ) << " international frac_digits\n to the right"
<< " of the radix character: "
<< mpunct.frac_digits ( ) << endl << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >( loc );
for (unsigned int i = 0; i <mpunct2.grouping( ).length( ); i++ )
{
cout << loc.name( ) << " domestic grouping:\n the "
<< i <<"th group to the left of the radix character "
<< "is of size " << (int)(mpunct2.grouping ( )[i])
<< endl;
}
cout << loc.name( ) << " domestic frac_digits\n to the right"
<< " of the radix character: "
<< mpunct2.frac_digits ( ) << endl << endl;
}
German_Germany.1252 international grouping:
the 0th group to the left of the radix character is of size 3
German_Germany.1252 international frac_digits
to the right of the radix character: 2
German_Germany.1252 domestic grouping:
the 0th group to the left of the radix character is of size 3
German_Germany.1252 domestic frac_digits
to the right of the radix character: 2
moneypunct::moneypunct
moneypunct 型のオブジェクトのコンストラクター。
explicit moneypunct(size_t _Refs = 0);
パラメーター
_Refs
オブジェクトのメモリ管理の種類を指定するために使用する整数値。
注釈
_Refs パラメーターの可能な値とその重要性は次のとおりです。
0: オブジェクトの有効期間はそれが含まれるロケールによって管理されます。
1: オブジェクトの有効期間を手動で管理する必要があります。
> 1: これらの値は定義されていません。
デストラクターが保護されているため、利用できる直接的な例はありません。
コンストラクターは、locale::facet(_ Refs) を使用して、その基本オブジェクトを初期化します。
moneypunct::neg_format
負の値の出力を書式設定するためのロケール固有の規則を返します。
pattern neg_format() const;
戻り値
負の値の出力を書式設定するためのロケール固有の規則。
注釈
このメンバー関数は、do_neg_format を返します。
例
// moneypunct_neg_format.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( ) {
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true > >(loc);
cout << loc.name( ) << " international negative number format: "
<< mpunct.neg_format( ).field[0]
<< mpunct.neg_format( ).field[1]
<< mpunct.neg_format( ).field[2]
<< mpunct.neg_format( ).field[3] << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >(loc);
cout << loc.name( ) << " domestic negative number format: "
<< mpunct2.neg_format( ).field[0]
<< mpunct2.neg_format( ).field[1]
<< mpunct2.neg_format( ).field[2]
<< mpunct2.neg_format( ).field[3] << endl;
}
moneypunct::negative_sign
負の記号として使用する要素のロケール固有のシーケンスを返します。
string_type negative_sign() const;
戻り値
負の記号として使用する要素のロケール固有のシーケンスを返します。
注釈
このメンバー関数は、do_negative_sign を返します。
例
// moneypunct_neg_sign.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true> >(loc);
cout << loc.name( ) << " international negative sign: "
<< mpunct.negative_sign( ) << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >(loc);
cout << loc.name( ) << " domestic negative sign: "
<< mpunct2.negative_sign( ) << endl;
locale loc2( "French" );
const moneypunct <char, true> &mpunct3 =
use_facet <moneypunct <char, true> >(loc2);
cout << loc2.name( ) << " international negative sign: "
<< mpunct3.negative_sign( ) << endl;
const moneypunct <char, false> &mpunct4 =
use_facet <moneypunct <char, false> >(loc2);
cout << loc2.name( ) << " domestic negative sign: "
<< mpunct4.negative_sign( ) << endl;
};
German_Germany.1252 international negative sign: -
German_Germany.1252 domestic negative sign: -
French_France.1252 international negative sign: -
French_France.1252 domestic negative sign: -
moneypunct::pos_format
正の値の出力を書式設定するためのロケール固有の規則を返します。
pattern pos_format() const;
戻り値
正の値の出力を書式設定するためのロケール固有の規則。
注釈
このメンバー関数は、do_pos_format を返します。
例
// moneypunct_pos_format.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main() {
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true> >(loc);
cout << loc.name( ) << " international positive number format: "
<< mpunct.pos_format( ).field[0]
<< mpunct.pos_format( ).field[1]
<< mpunct.pos_format( ).field[2]
<< mpunct.pos_format( ).field[3] << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >(loc);
cout << loc.name( ) << " domestic positive number format: "
<< mpunct2.pos_format( ).field[0]
<< mpunct2.pos_format( ).field[1]
<< mpunct2.pos_format( ).field[2]
<< mpunct2.pos_format( ).field[3] << endl;
}
moneypunct::positive_sign
正の記号として使用する要素のロケール固有のシーケンスを返します。
string_type positive_sign() const;
戻り値
正の記号として使用する要素のロケール固有のシーケンス。
注釈
このメンバー関数は、do_positive_sign を返します。
例
// moneypunct_pos_sign.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true > >(loc);
cout << loc.name( ) << " international positive sign:"
<< mpunct.positive_sign( ) << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >(loc);
cout << loc.name( ) << " domestic positive sign:"
<< mpunct2.positive_sign( ) << endl;
locale loc2( "French" );
const moneypunct <char, true> &mpunct3 =
use_facet <moneypunct <char, true> >(loc2);
cout << loc2.name( ) << " international positive sign:"
<< mpunct3.positive_sign( ) << endl;
const moneypunct <char, false> &mpunct4 =
use_facet <moneypunct <char, false> >(loc2);
cout << loc2.name( ) << " domestic positive sign:"
<< mpunct4.positive_sign( ) << endl;
};
German_Germany.1252 international positive sign:
German_Germany.1252 domestic positive sign:
French_France.1252 international positive sign:
French_France.1252 domestic positive sign:
moneypunct::string_type
CharType 型の文字を格納する文字列を表す型。
typedef basic_string<CharType, Traits, Allocator> string_type;
注釈
この型は、オブジェクトに区切り記号シーケンスのコピーを格納できるクラス テンプレート basic_string の特殊化を表します。
moneypunct::thousands_sep
桁区切り記号として使用する要素のロケール固有のシーケンスを返します。
CharType thousands_sep() const;
戻り値
桁区切り記号として使用する要素のロケール固有のシーケンス。
注釈
このメンバー関数は、do_thousands_sep を返します。
例
// moneypunct_thou_sep.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
const moneypunct <char, true> &mpunct =
use_facet <moneypunct <char, true > >(loc);
cout << loc.name( ) << " international thousands separator: "
<< mpunct.thousands_sep( ) << endl;
const moneypunct <char, false> &mpunct2 =
use_facet <moneypunct <char, false> >(loc);
cout << loc.name( ) << " domestic thousands separator: "
<< mpunct2.thousands_sep( ) << endl << endl;
locale loc2( "english_canada" );
const moneypunct <char, true> &mpunct3 =
use_facet <moneypunct <char, true> >(loc2);
cout << loc2.name( ) << " international thousands separator: "
<< mpunct3.thousands_sep( ) << endl;
const moneypunct <char, false> &mpunct4 =
use_facet <moneypunct <char, false> >(loc2);
cout << loc2.name( ) << " domestic thousands separator: "
<< mpunct4.thousands_sep( ) << endl;
}
German_Germany.1252 international thousands separator: .
German_Germany.1252 domestic thousands separator: .
English_Canada.1252 international thousands separator: ,
English_Canada.1252 domestic thousands separator: ,