名前空間
変種
操作

std::num_get

提供: cppreference.com
< cpp‎ | locale

 
 
ローカライゼーションライブラリ
ロケールおよびファセット
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
文字分類
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリの基底クラスです
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリ
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ロケール固有のファセット
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コー​​ド変換ファセット
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8(C++11)
codecvt_utf16(C++11)
Cロケール
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
std::num_get
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
num_get::num_get
num_get::~num_get
num_get::get
num_get::do_get
 
Defined in header <locale>
template<

    class CharT,
    class InputIt = std::istreambuf_iterator<CharT>

> class num_get;
クラスstd::num_getは、型の値の文字列表現を解析するための規則をカプセル化boolunsigned shortunsigned intlongunsigned longlong longunsigned long longfloatdoublelong double、とvoid*。標準の書式設定、入力演算子(例えば、cin >> n;AS)番号のテキス​​ト表現を解析するために、I / Oストリームのロケールのstd::num_getファセットを使用し.
Original:
Class std::num_get encapsulates the rules for parsing string representations of values of type bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, and void*. The standard formatting input operators (such as cin >> n;) use the std::num_get facet of the I/O stream's locale to parse the text representations of the numbers.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cpp/locale/locale/facetstd-num get-inheritance.svg
画像の詳細

Inheritance diagram

目次

[編集] 型の要件

-
InputIt must meet the requirements of InputIterator.

[編集] スペシャ

2つの専門分野と2部分的な特殊化は、標準ライブラリによって提供されており、C + +プログラムで作成されたすべてのロケール·オブジェクトによって実装されます
Original:
Two specializations and two partial specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <locale>
std::num_get<char>
数字の狭い文字列のパースを作成します
Original:
creates narrow string parsing of numbers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::num_get<wchar_t>
数字のワイド文字列のパースを作成します
Original:
creates wide string parsing of numbers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::num_get<char, InputIt>
カスタム入力イテレータを使用して数値の狭い文字列のパースを作成します
Original:
creates narrow string parsing of numbers using custom input iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::num_get<wchar_t, InputIt>
カスタム入力イテレータを使用して数値のワイド文字列のパースを作成します
Original:
creates wide string parsing of numbers using custom input iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] メンバータイプ

メンバー·タイプ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
char_type CharT
iter_type InputIt

[編集] メンバ関数

新しいnum_getファセットを構築します
Original:
constructs a new num_get facet
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数)
num_getファセットを破棄します
Original:
destructs a num_get facet
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(protectedメンバー関数)
do_getを呼び出します
Original:
invokes do_get
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数)

[編集] メンバーオブジェクト

static std::locale::id id
idはロケールの
Original:
id of the locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバオブジェクト)

[編集] メンバ関数を保護しました

[仮想]
入力ストリームから数を解析します
Original:
parses a number from an input stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(仮想protectedメンバ関数)

[編集]

#include <iostream>
#include <locale>
#include <string>
#include <sstream>
#include <iterator>
int main()
{
    std::string de_double = "1.234.567,89";
    std::string us_double = "1,234,567.89";
 
    // parse using streams
    std::istringstream de_in(de_double);
    de_in.imbue(std::locale("de_DE"));
    double f1;
    de_in >> f1;
 
    std::istringstream us_in(de_double);
    us_in.imbue(std::locale("en_US.UTF-8"));
    double f2;
    us_in >> f2;
 
    std::cout << "Parsing " << de_double << " as double gives " << std::fixed
              << f1 << " in de_DE locale and " << f2 << " in en_US\n";
 
    // use the facet directly
    std::istringstream s3(us_double);
    s3.imbue(std::locale("en_US.UTF-8"));
    auto& f = std::use_facet<std::num_get<char>>(s3.getloc());
    std::istreambuf_iterator<char> beg(s3), end;
    double f3;
    std::ios::iostate err;
    f.get(beg, end, s3, err, f3);
    std::cout << "parsing " << us_double
              << " as double using raw en_US facet gives " << f3 << '\n';
}

Output:

Parsing 1.234.567,89 as double gives 1234567.890000 in de_DE locale and 1.234000 in en_US
parsing 1,234,567.89 as double using raw en_US facet gives 1234567.890000

[編集] も参照してください

数値の区切り文字の規則を定義します
Original:
defines numeric punctuation rules
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレート) [edit]
文字シーケンスとして出力するための書式の数値
Original:
formats numeric values for output as character sequence
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレート) [edit]
抽出は、データをフォーマットします
Original:
extracts formatted data
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数of std::basic_istream) [edit]