Share via


numpunct クラス

数値とブール式の書式設定および区切りに関する情報を表すために使用される、CharType 型のシーケンスを表すロケール ファセットとして使用できるオブジェクトを表すクラス テンプレート。

構文

template <class CharType>
class numpunct : public locale::facet;

パラメーター

CharType
ロケールの文字をエンコードするためにプログラム内で使用される型。

解説

すべてのロケールのファセットと同様、静的オブジェクト ID に最初に格納されている値は 0 です。 格納されている値に初めてアクセスしようとすると、id に一意の正の値が格納されます。

コンストラクター

コンストラクター 説明
numpunct numpunct 型のオブジェクトのコンストラクター。

Typedefs

型名 説明
char_type ロケールによって使用される文字を表すために使用される型。
string_type CharType 型の文字を格納する文字列を表す型。

メンバー関数

メンバー関数 説明
decimal_point 小数点として使用するロケール固有の要素を返します。
do_decimal_point 小数点として使用するロケール固有の要素を返すために呼び出されるプロテクト仮想メンバー関数。
do_falsename false 値のテキスト表現として使用する文字列を返すために呼び出されるプロテクト仮想メンバー関数。
do_grouping 小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返すために呼び出されるプロテクト仮想メンバー関数。
do_thousands_sep 桁区切り記号として使用するロケール固有の要素を返すために呼び出されるプロテクト仮想メンバー関数。
do_truename true 値のテキスト表現として使用する文字列を返すために呼び出されるプロテクト仮想メンバー関数。
falsename false 値のテキスト表現として使用する文字列を返します。
grouping 小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返します。
thousands_sep 桁区切り記号として使用するロケール固有の要素を返します。
truename true 値のテキスト表現として使用する文字列を返します。

必要条件

ヘッダー:<locale>

名前空間: std

numpunct::char_type

ロケールによって使用される文字を表すために使用される型。

typedef CharType char_type;

解説

この型は、テンプレート パラメーター CharType のシノニムです。

numpunct::d ecimal_point

小数点として使用するロケール固有の要素を返します。

CharType decimal_point() const;

戻り値

小数点として使用するロケール固有の要素。

解説

このメンバー関数は、do_decimal_point を返します。

// numpunct_decimal_point.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
   locale loc( "german_germany" );

   const numpunct <char> &npunct =
   use_facet <numpunct <char> >( loc);
   cout << loc.name( ) << " decimal point "<<
   npunct.decimal_point( ) << endl;
   cout << loc.name( ) << " thousands separator "
   << npunct.thousands_sep( ) << endl;
};
German_Germany.1252 decimal point ,
German_Germany.1252 thousands separator .

numpunct::d o_decimal_point

小数点として使用するロケール固有の要素を返すために呼び出されるプロテクト仮想メンバー関数。

virtual CharType do_decimal_point() const;

戻り値

小数点として使用するロケール固有の要素。

decimal_point の例 (仮想メンバー関数が decimal_point で呼び出される) を参照してください。

numpunct::d o_falsename

このプロテクト仮想メンバー関数は、false 値のテキスト表現として使用するシーケンスを返します。

virtual string_type do_falsename() const;

戻り値

false 値のテキスト表現として使用するシーケンスを含む文字列。

解説

このメンバー関数は、すべてのロケールで false 値を表す文字列 "false" を返します。

falsename の例 (仮想メンバー関数が falsename で呼び出される) をご覧ください。

numpunct::d o_grouping

小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返すために呼び出されるプロテクト仮想メンバー関数。

virtual string do_grouping() const;

戻り値

小数点の左側の数字をグループ化する方法を決定するロケール固有の規則。

解説

このプロテクト仮想メンバー関数は、小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返します。 エンコーディングは lconv::grouping の場合と同じです。

grouping の例 (仮想メンバー関数が grouping で呼び出される) をご覧ください。

numpunct::d o_thousands_sep

桁区切り記号として使用するロケール固有の要素を返すために呼び出されるプロテクト仮想メンバー関数。

virtual CharType do_thousands_sep() const;

戻り値

桁区切り記号として使用するロケール固有の要素を返します。

解説

このプロテクト仮想メンバー関数は、小数点の左側の桁区切り記号として使用する、CharType 型のロケール固有の要素を返します。

thousands_sep の例 (仮想メンバー関数が thousands_sep で呼び出される) を参照してください。

numpunct::d o_truename

true 値のテキスト表現として使用する文字列を返すために呼び出されるプロテクト仮想メンバー関数。

virtual string_type do_truename() const;

解説

true 値のテキスト表現として使用する文字列。

すべてのロケールは、true 値を表す文字列 "true" を返します。

truename の例 (仮想メンバー関数が truename で呼び出される) をご覧ください。

numpunct::falsename

false 値のテキスト表現として使用する文字列を返します。

string_type falsename() const;

戻り値

false 値のテキスト表現として使用する CharType のシーケンスを含む文字列。

解説

このメンバー関数は、すべてのロケールで false 値を表す文字列 "false" を返します。

このメンバー関数は、do_falsename を返します。

// numpunct_falsename.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
   locale loc( "English" );

   const numpunct <char> &npunct = use_facet <numpunct <char> >( loc );
   cout << loc.name( ) << " truename "<< npunct.truename( ) << endl;
   cout << loc.name( ) << " falsename "<< npunct.falsename( ) << endl;

   locale loc2( "French" );
   const numpunct <char> &npunct2 = use_facet <numpunct <char> >(loc2);
   cout << loc2.name( ) << " truename "<< npunct2.truename( ) << endl;
   cout << loc2.name( ) << " falsename "<< npunct2.falsename( ) << endl;
}
English_United States.1252 truename true
English_United States.1252 falsename false
French_France.1252 truename true
French_France.1252 falsename false

numpunct::grouping

小数点の左側の数字をグループ化する方法を決定するロケール固有の規則を返します。

string grouping() const;

戻り値

小数点の左側の数字をグループ化する方法を決定するロケール固有の規則。

解説

このメンバー関数は、do_grouping を返します。

// numpunct_grouping.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
   locale loc( "german_germany");

   const numpunct <char> &npunct =
       use_facet < numpunct <char> >( loc );
   for (unsigned int i = 0; i < npunct.grouping( ).length( ); i++)
   {
      cout << loc.name( ) << " international grouping:\n the "
           << i <<"th group to the left of the radix character "
           << "is of size " << (int)(npunct.grouping ( )[i])
           << endl;
   }
}
German_Germany.1252 international grouping:
the 0th group to the left of the radix character is of size 3

numpunct::numpunct

numpunct 型のオブジェクトのコンストラクター。

explicit numpunct(size_t _Refs = 0);

パラメーター

_Refs
オブジェクトのメモリ管理の種類を指定するために使用する整数値。

解説

_Refs パラメーターの可能な値とその重要性は次のとおりです。

  • 0: オブジェクトの有効期間はそれが含まれるロケールによって管理されます。

  • 1: オブジェクトの有効期間を手動で管理する必要があります。

  • > 1: これらの値は定義されていません。

デストラクターが保護されているため、利用できる直接的な例はありません。

コンストラクターは、locale::facet(_Refs) を使用して、その基本オブジェクトを初期化します。

numpunct::string_type

CharType 型の文字を格納する文字列を表す型。

typedef basic_string<CharType, Traits, Allocator> string_type;

解説

この型は、オブジェクトに区切り記号シーケンスのコピーを格納できるクラス テンプレート basic_string の特殊化を表します。

numpunct::thousands_sep

桁区切り記号として使用するロケール固有の要素を返します。

CharType thousands_sep() const;

戻り値

桁区切り記号として使用するロケール固有の要素。

解説

このメンバー関数は、do_thousands_sep を返します。

// numpunct_thou_sep.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
   locale loc( "german_germany" );

   const numpunct <char> &npunct =
   use_facet < numpunct < char > >( loc );
   cout << loc.name( ) << " decimal point "<<
   npunct.decimal_point( ) << endl;
   cout << loc.name( ) << " thousands separator "
   << npunct.thousands_sep( ) << endl;
};
German_Germany.1252 decimal point ,
German_Germany.1252 thousands separator .

numpunct::truename

true 値のテキスト表現として使用する文字列を返します。

string_type falsename() const;

戻り値

true 値のテキスト表現として使用する文字列。

解説

このメンバー関数は、do_truename を返します。

すべてのロケールは、true 値を表す文字列 "true" を返します。

// numpunct_truename.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
   locale loc( "English" );

   const numpunct < char> &npunct = use_facet <numpunct <char> >( loc );
   cout << loc.name( ) << " truename "<< npunct.truename( ) << endl;
   cout << loc.name( ) << " falsename "<< npunct.falsename( ) << endl;

   locale loc2("French");
   const numpunct <char> &npunct2 = use_facet <numpunct <char> >( loc2 );
   cout << loc2.name( ) << " truename "<< npunct2.truename( ) << endl;
   cout << loc2.name( ) << " falsename "<< npunct2.falsename( ) << endl;
}
English_United States.1252 truename true
English_United States.1252 falsename false
French_France.1252 truename true
French_France.1252 falsename false

関連項目

<ロケール>
facet クラス
C++ 標準ライブラリ内のスレッド セーフ