std::num_get::get, std::num_get::do_get
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <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)
fonction de membre du public, appelle le
do_get fonction membre de la classe la plus dérivée .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.
You can help to correct and verify the translation. Click here for instructions.
2)
lit les caractères à partir de la
in itérateur d'entrée et génère la valeur du type de v, en tenant compte des drapeaux d'entrée-sortie de flux de mise en page à partir de str.flags(), à partir de règles de classification de caractères std::use_facet<std::ctype<charT>>(str.getloc()), et les signes de ponctuation numériques à partir std::use_facet<std::numpunct<charT>>(str.getloc()). Cette fonction est appelée par tous les opérateurs format de flux d'entrée tels que 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.
You can help to correct and verify the translation. Click here for instructions.
Conversion a lieu en trois étapes
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.
You can help to correct and verify the translation. Click here for instructions.
Étape 1: spécificateur de conversion de sélection
- I / O indicateurs de format sont obtenus, comme parOriginal:I/O format flags are obtained, as if byThe 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);
- Si le type de
vest un type entier, le choix du premier lieu des cinq suivantes est sélectionnée:Original:If the type ofvis 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.
- Si
basefield == oct, utilisera spécificateur de conversion%oOriginal:Ifbasefield == oct, will use conversion specifier%oThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si
basefield == hex, utilisera spécificateur de conversion%XOriginal:Ifbasefield == hex, will use conversion specifier%XThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si
basefield == 0, utilisera spécificateur de conversion%iOriginal:Ifbasefield == 0, will use conversion specifier%iThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vest signé, va utiliser spécificateur de conversion%dOriginal:If the type ofvis signed, will use conversion specifier%dThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vn'est pas signé, utilisera spécificateur de conversion%uOriginal:If the type ofvis unsigned, will use conversion specifier%uThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Pour les types entiers, modificateur de longueur est ajoutée à la spécification de conversion si nécessaire:
hpourshortetunsigned short,lpourlongetunsigned long,llpourlong longetunsigned long longOriginal:For integer types, length modifier is added to the conversion specification if necessary:hforshortandunsigned short,lforlongandunsigned long,llforlong longandunsigned long longThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vestfloat, utilisera spécificateur de conversion%gOriginal:If the type ofvisfloat, will use conversion specifier%gThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vestdouble, utilisera spécificateur de conversion%lgOriginal:If the type ofvisdouble, will use conversion specifier%lgThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vestlong double, utilisera spécificateur de conversion%LgOriginal:If the type ofvislong double, will use conversion specifier%LgThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vestvoid*, utilisera spécificateur de conversion%pOriginal:If the type ofvisvoid*, will use conversion specifier%pThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vestbooletboolalpha==0, procède comme si le type devestlong, à l'exception de la valeur à stocker dansvl'étape 3 .Original:If the type ofvisboolandboolalpha==0, proceeds as if the type ofvislong, except for the value to be stored invin stage 3.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si le type de
vestbooletboolalpha!=0, les dispositions suivantes remplacent les étapes 2 et 3:Original:If the type ofvisboolandboolalpha!=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. - * Caractères successifs obtenus à partir de l'itérateur d'entrée
insont comparés aux séquences de caractères obtenus à partir destd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()etstd::use_facet<std::numpunct<charT> >(str.getloc()).truename()seulement comme nécessaire pour identifier la correspondance unique. Leinitérateur d'entrée est comparée àenduniquement lorsque c'est nécessaire pour obtenir un caractère .Original:* Successive characters obtained from the input iteratorinare matched against the character sequences obtained fromstd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()andstd::use_facet<std::numpunct<charT> >(str.getloc()).truename()only as necessary as to identify the unique match. The input iteratorinis compared toendonly 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. - * Si la séquence cible est idéalement adapté,
vest réglé sur la valeurboolcorrespondant. Sinonfalseest stocké dansvet std::ios_base::failbit est attribué àerr. Si le match exceptionnel ne peut être trouvée avant l'entrée terminée (in==end),err|=std::ios_base::eofbitest exécuté .Original:* If the target sequence is uniquely matched,vis set to the correspondingboolvalue. Otherwisefalseis stored invand std::ios_base::failbit is assigned toerr. If unique match could not be found before the input ended (in==end),err|=std::ios_base::eofbitis executed.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Etape 2: extraction de caractères
- Si
in==end, étape 2 est immédiatement terminée, sans autres caractères sont extraitsOriginal:Ifin==end, Stage 2 is terminated immediately, no further characters are extractedThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Le caractère suivant est extrait de
incomme parchar_type ct = *in;Original:The next character is extracted frominas if bychar_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. - * Si le caractère correspond à l'une des
"0123456789abcdefxABCDEFX+-", élargie à type_caractere l'environnement local, comme parstd::use_facet<std::ctype<charT>>(str.getloc()).widen(), il est converti à l'charcorrespondante .Original:* If the character matches one of"0123456789abcdefxABCDEFX+-", widened to the locale's char_type as if bystd::use_facet<std::ctype<charT>>(str.getloc()).widen(), it is converted to the correspondingchar.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * Si le caractère correspond au séparateur décimal (
std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point())), il est remplacé par'.'.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. - * Si le caractère correspond au séparateur de milliers (
std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep()) et le séparateur de milliers est utilisé à toutes lesstd::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0, alors si le'.'point décimal n'a pas encore été accumulées, la position du personnage est rememebered, mais le personnage est autrement ignorés. Si la virgule a déjà été accumulé, le personnage est éliminé et la phase 2 se termine .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 allstd::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. - * Dans tous les cas, le contrôle est effectué si le
charobtenus à partir des étapes précédentes est autorisé dans le champ de saisie qui serait analysé par std::scanf donné le spécificateur de conversion sélectionné à l'étape 1. Si elle est autorisée, il est accumulée dans un tampon temporaire et l'étape 2 répétitions. Si ce n'est pas permis, étape 2 se termine .Original:* In any case, the check is made whether thecharobtained 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.
Étape 3: conversion et le stockage
- La séquence de
chars accumulées dans l'étape 2 est converti en une valeur numériqueOriginal:The sequence ofchars accumulated in Stage 2 is converted to a numeric valueThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * L'entrée est analysé comme par std::scanf avec le spécificateur de conversion sélectionné à l'étape 1 (avant C++11)Original:* The input is parsed as if by std::scanf with the conversion specifier selected in Stage 1 (avant C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * L'entrée est analysé comme par std::strtoll entier signé pour
v, std::strtoull pourventier non signé, ou std::strtold en virgule flottantev(depuis C++11)Original:* The input is parsed as if by std::strtoll for signed integerv, std::strtoull for unsigned integerv, or std::strtold for floating-pointv(depuis C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si la fonction de conversion ne parvient pas à convertir la totalité du champ, le
0valeur est stockée dansv(depuis C++11)Original:If the conversion function fails to convert the entire field, the value0is stored inv(depuis C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si les résultats de la fonction de conversion en une valeur positive trop volumineux pour tenir dans le type de
v, la valeur la plus positive représentable est stocké dansv(depuis C++11)Original:If the conversion function results in a positive value too large to fit in the type ofv, the most positive representable value is stored inv(depuis C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si les résultats de la fonction de conversion en une valeur négative trop volumineux pour tenir dans le type de
v, la valeur la plus négative représentable est stocké dansv(depuis C++11)Original:If the conversion function results in a negative value too large to fit in the type ofv, the most negative representable value is stored inv(depuis C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Dans tous les cas, si la fonction de conversion échoue std::ios_base::failbit est attribué à
errOriginal:In any case, if the conversion function fails std::ios_base::failbit is assigned toerrThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Dans le cas contraire, le résultat de la conversion numérique est stockée dans
vOriginal:Otherwise, the numeric result of the conversion is stored invThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * Si le type de
vestboolet boolalpha n'est pas définie, alors si la valeur à stocker est0,falseest stockée, si la valeur à stocker est1,trueest stocké, pour tout std::ios_base::failbit autre valeur est affectée àerr.Original:* If the type ofvisbooland boolalpha is not set, then if the value to be stored is0,falseis stored, if the value to be stored is1,trueis stored, for any other value std::ios_base::failbit is assigned toerr.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Après cela, groupement des chiffres est cochée. si la position selon l'une quelconque des séparateurs de milliers de rebut de l'étape 2 ne correspond pas à l'groupement fourni par
std::use_facet<std::numpunct<charT>>(str.getloc()).grouping(), std::ios_base::failbit est affecté àerr.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 bystd::use_facet<std::numpunct<charT>>(str.getloc()).grouping(), std::ios_base::failbit is assigned toerr.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si l'étape 2 a été résilié par le test
in==end,err|=std::ios_base::eofbitest exécuté pour positionner le bit .. eofOriginal:If Stage 2 was terminated by the testin==end,err|=std::ios_base::eofbitis 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.
Retourne la valeur
in
Notes
En C + 98 / C + +03, si une erreur se produit,
v reste inchangé. En C + +11, il est réglé à une valeur telle que décrite ci-dessus .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.
You can help to correct and verify the translation. Click here for instructions.
Exemple
| This section is incomplete Reason: no example |
Voir aussi
extraits des données formatées 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. (fonction membre publique de std::basic_istream)
| |