名前空間
変種
操作

std::num_get::get, std::num_get::do_get

提供: cppreference.com
< cpp‎ | locale‎ | num get

 
 
ローカライゼーションライブラリ
ロケールおよびファセット
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>
public:

iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, bool& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, long& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, long long& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, unsigned short& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, unsigned int& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, unsigned long& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, unsigned long long& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, float& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, double& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,
               std::ios_base::iostate& err, long double& v );
iter_type get( iter_type in, iter_type end, std::ios_base& str,

               std::ios_base::iostate& err, void*& v );
(1)
protected:

iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, bool& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, long& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, long long& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, unsigned short& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, unsigned int& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, unsigned long& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, unsigned long long& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, float& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, double& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,
                  std::ios_base::iostate& err, long double& v );
iter_type do_get( iter_type in, iter_type end, std::ios_base& str,

                  std::ios_base::iostate& err, void*& v );
(2)
1)
パブリックメンバ関数は、最派生クラスのメンバ関数を呼び出しdo_get.
Original:
public member function, calls the member function do_get of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
入力イテレータinから文字を読み取り、vの型の値を生成し、str.flags()std::use_facet<std::ctype<charT>>(str.getloc())から文字分類ルール、およびstd::use_facet<std::numpunct<charT>>(str.getloc())から数値句読点から考慮入出力ストリームの書式化フラグを取る。この関数は、std::cin >> n;などのすべての書式設定された入力ストリーム演算子によって呼び出されます.
Original:
reads characters from the input iterator in and generates the value of the type of v, taking into account IO stream formatting flags from str.flags(), character classification rules from std::use_facet<std::ctype<charT>>(str.getloc()), and numeric punctuation characters from std::use_facet<std::numpunct<charT>>(str.getloc()). This function is called by all formatted input stream operators such as std::cin >> n;.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換は、次の3つの段階で行われます
Original:
Conversion occurs in three stages
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] ステージ1:変換指定子の選択

  • I / Oフォーマットフラグがあるかのようにすることによって、得られる
    Original:
    I/O format flags are obtained, as if by
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
fmtflags basefield = (str.flags() & std::ios_base::basefield);
fmtflags boolalpha = (str.flags() & std::ios_base::boolalpha);
  • vの型は整数型である場合は、次の5つの適用可能な最初の選択肢が選択されています
    Original:
    If the type of v is an integer type, the the first applicable choice of the following five is selected:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
basefield == oct場合は、変換指定子%oを使用します
Original:
If basefield == oct, will use conversion specifier %o
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basefield == hex場合は、変換指定子%Xを使用します
Original:
If basefield == hex, will use conversion specifier %X
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basefield == 0場合は、変換指定子%iを使用します
Original:
If basefield == 0, will use conversion specifier %i
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vの種類は署名されている場合は、変換指定子%dを使用します
Original:
If the type of v is signed, will use conversion specifier %d
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vの型がunsignedである場合、変換指定子%uを使用します
Original:
If the type of v is unsigned, will use conversion specifier %u
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 整数型の場合、長さ修飾子は、変換仕様に追加され、必要に応じて:hshortおよびunsigned shortllongおよびunsigned longlllong longおよびunsigned long long
    Original:
    For integer types, length modifier is added to the conversion specification if necessary: h for short and unsigned short, l for long and unsigned long, ll for long long and unsigned long long
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがfloatである場合は、変換指定子%gを使用します
    Original:
    If the type of v is float, will use conversion specifier %g
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがdoubleである場合は、変換指定子%lgを使用します
    Original:
    If the type of v is double, will use conversion specifier %lg
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがlong doubleである場合は、変換指定子%Lgを使用します
    Original:
    If the type of v is long double, will use conversion specifier %Lg
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがvoid*である場合は、変換指定子%pを使用します
    Original:
    If the type of v is void*, will use conversion specifier %p
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがある場合boolboolalpha==0、収益あたかもvのタイプですlong、ステージ3にvに格納される値を除いて.
    Original:
    If the type of v is bool and boolalpha==0, proceeds as if the type of v is long, except for the value to be stored in v in stage 3.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがある場合boolboolalpha!=0、次はステージ2と3のように置き換えます
    Original:
    If the type of v is bool and boolalpha!=0, the following replaces stages 2 and 3:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 入力反復inから得*連続文字が一意の照合を識別するようstd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()std::use_facet<std::numpunct<charT> >(str.getloc()).truename()のみ必要に応じてから取得した文字シーケンスと照合されます。入力イテレータinは、文字を取得するために必要な場合にのみendと比較されます.
    Original:
    * Successive characters obtained from the input iterator in are matched against the character sequences obtained from std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() and std::use_facet<std::numpunct<charT> >(str.getloc()).truename() only as necessary as to identify the unique match. The input iterator in is compared to end only when necessary to obtain a character.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 標的配列が一意に一致した場合*、vは対応bool値に設定されます。それ以外の場合はfalsevに格納されており、std::ios_base::failbiterrに割り当てられています。入力(in==end)が終了する前に一意の一致が見つからなかった場合には、err|=std::ios_base::eofbitが実行されます.
    Original:
    * If the target sequence is uniquely matched, v is set to the corresponding bool value. Otherwise false is stored in v and std::ios_base::failbit is assigned to err. If unique match could not be found before the input ended (in==end), err|=std::ios_base::eofbit is executed.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ステージ2:文字抽出

  • in==end、ステージ2は直ちに終了された場合は、それ以上の文字が抽出されません
    Original:
    If in==end, Stage 2 is terminated immediately, no further characters are extracted
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 次の文字はinたかのようにchar_type ct = *in;から抽出されます
    Original:
    The next character is extracted from in as if by char_type ct = *in;
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *文字が"0123456789abcdefxABCDEFX+-"たかのようにロケールのCHAR_TYPEに拡大std::use_facet<std::ctype<charT>>(str.getloc()).widen()の1つに一致する場合は、それが対応するcharに変換されます.
    Original:
    * If the character matches one of "0123456789abcdefxABCDEFX+-", widened to the locale's char_type as if by std::use_facet<std::ctype<charT>>(str.getloc()).widen(), it is converted to the corresponding char.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *文字は、小数点セパレータ(std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point()))と一致した場合、それは'.'で置き換えられます.
    Original:
    * If the character matches the decimal point separator (std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point())), it is replaced by '.'.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 文字は千単位の区切りを(std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep())と一致し、数千分離が小数点std::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0がまだ蓄積されていない場合、その後、すべての'.'で使用されている場合*、文字の位置がrememeberedされていますが、文字がない場合は無視されます。小数点が既に蓄積されている場合、その文字は破棄され、第2段階は終了します.
    Original:
    * If the character matches the thousands separator (std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep()) and the thousands separation is in use at all std::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0, then if the decimal point '.' has not yet been accumulated, the position of the character is rememebered, but the character is otherwise ignored. If the decimal point has already been accumulated, the character is discarded and Stage 2 terminates.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *いずれの場合でも、チェックは前のステップから得charstd::scanfステージ1で選択した変換指定子を与えられたことによって解析される入力フィールドで許可されているかどうかの判断がなされる。それが許されるのであれば、それは一時的なバッファとステージ2を繰り返し蓄積される。それが許可されていない場合、第2段階は終了.
    Original:
    * In any case, the check is made whether the char obtained from the previous steps is allowed in the input field that would be parsed by std::scanf given the conversion specifier selected in Stage 1. If it is allowed, it is accumulated in a temporary buffer and Stage 2 repeats. If it is not allowed, Stage 2 terminates.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ステージ3:変換·貯蔵

  • ステージ2に蓄積charsのシーケンスが数値に変換されます
    Original:
    The sequence of chars accumulated in Stage 2 is converted to a numeric value
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *入力は、ステージ1std::scanfで選択変換指定子を持つ(C + + 11時まで)たかのように解析されます
    Original:
    * The input is parsed as if by std::scanf with the conversion specifier selected in Stage 1 (C + + 11時まで)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *入力は符号付き整数のためstd::strtollかのように解析されvstd::strtoull符号なし整数v、または浮動小数点std::strtoldvため​​(C + + 11以来)ため
    Original:
    * The input is parsed as if by std::strtoll for signed integer v, std::strtoull for unsigned integer v, or std::strtold for floating-point v (C + + 11以来)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 変換関数は、フィールド全体の変換に失敗した場合、値は0v(C + + 11以来)に格納されています
    Original:
    If the conversion function fails to convert the entire field, the value 0 is stored in v (C + + 11以来)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vの型に収まらないほど大きな正の値に変換関数が発生する場合、最も肯定的に表現可能な値はv(C + + 11以来)に格納されています
    Original:
    If the conversion function results in a positive value too large to fit in the type of v, the most positive representable value is stored in v (C + + 11以来)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vの型に収まらないほど大きな負の値に変換関数が発生する場合、表現可能な負の値はv(C + + 11以来)に格納されています
    Original:
    If the conversion function results in a negative value too large to fit in the type of v, the most negative representable value is stored in v (C + + 11以来)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 変換関数が失敗した場合にどのような場合でも、std::ios_base::failbiterrに割り当てられています
    Original:
    In any case, if the conversion function fails std::ios_base::failbit is assigned to err
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • そうしないと、変換結果の数値はvに格納されています
    Original:
    Otherwise, the numeric result of the conversion is stored in v
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *vのタイプはboolとboolalphaは格納される値は0false格納されている場合、他の値1trueに割り当てられているために格納される値がstd::ios_base::failbiterr、格納されている場合、次に設定されていないとされている場合.
    Original:
    * If the type of v is bool and boolalpha is not set, then if the value to be stored is 0, false is stored, if the value to be stored is 1, true is stored, for any other value std::ios_base::failbit is assigned to err.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • この後、桁区切りがチェックされています。ステージ2で廃棄桁区切りの任意の位置がstd::use_facet<std::numpunct<charT>>(str.getloc()).grouping()が提供するグループと一致しない場合、std::ios_base::failbiterrに割り当てられています.
    Original:
    After this, digit grouping is checked. if the position of any of the thousands separators discarded in Stage 2 does not match the grouping provided by std::use_facet<std::numpunct<charT>>(str.getloc()).grouping(), std::ios_base::failbit is assigned to err.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ステージ2は、テストが中断された場合in==enderr|=std::ios_base::eofbitはeofビットを設定するために実行されます.
    Original:
    If Stage 2 was terminated by the test in==end, err|=std::ios_base::eofbit is executed to set the eof bit.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

in

[編集] ノート

エラーが発生した場合、Cで+ 98 / C + +03、vは変更されません。上記のように、C + +11では、それが値に設定されています.
Original:
In C++98/C++03, if an error occurs, v is left unchanged. In C++11, it is set to a value as described above.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

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

抽出は、データをフォーマットします
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]