std::num_get::get, std::num_get::do_get
Aus 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>| definiert 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)
öffentliche Member-Funktion ruft die Member-Funktion
do_get der am meisten abgeleiteten Klasse .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)
liest Zeichen aus dem Eingabe-Iterator
in und erzeugt den Wert von der Art der v unter Berücksichtigung IO-Stream Formatierung Flaggen aus str.flags(), Charakter Klassifizierung Regeln std::use_facet<std::ctype<charT>>(str.getloc()) und numerische Satzzeichen aus std::use_facet<std::numpunct<charT>>(str.getloc()). Diese Funktion wird von allen formatierte Eingabe-Stream Operatoren wie std::cin >> n; genannt .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.
Umsetzung erfolgt in drei Stufen
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.
Inhaltsverzeichnis
Stufe 1: Konvertierungsspezifizierer Auswahl
- I / O-Format Flags erhalten werden, wie durchOriginal: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);
- Wenn die Art der
vist ein Integer-Typ, wird die die erste anwendbare Wahl der folgenden fünf ausgewähltOriginal: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.
- Wenn
basefield == oct, verwenden Konvertierungsspezifizierer%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. - Wenn
basefield == hex, verwenden Konvertierungsspezifizierer%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. - Wenn
basefield == 0, verwenden Konvertierungsspezifizierer%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. - Wenn die Art der
vunterzeichnet wird, verwenden Konvertierungsspezifizierer%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. - Wenn die Art der
vunsigned ist, wird verwendet Konvertierungsspezifizierer%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.
- Für Integer-Typen wird die Länge Modifier für die Umwandlung Spezifikation, falls erforderlich:
hfürshortundunsigned short,lfürlongundunsigned long,llfürlong longundunsigned 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. - Wenn die Art der
vistfloat, verwenden Konvertierungsspezifizierer%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. - Wenn die Art der
vistdouble, verwenden Konvertierungsspezifizierer%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. - Wenn die Art der
vistlong double, verwenden Konvertierungsspezifizierer%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. - Wenn die Art der
vistvoid*, verwenden Konvertierungsspezifizierer%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. - Wenn der Typ der
vistboolundboolalpha==0, verläuft, als ob der Typ desvistlong, außer dem Wert, der invin Stufe 3 gespeichert werden .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. - Wenn die Art der
vistboolundboolalpha!=0der folgende Text ersetzt die Stufen 2 und 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. - * Nachfolgende Zeichen aus dem Eingabe-Iterator
inerhalten werden gegen die Zeichenfolgen ausstd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()undstd::use_facet<std::numpunct<charT> >(str.getloc()).truename()nur nach Bedarf erhalten, um die eindeutige Übereinstimmung zu identifizieren abgestimmt. Die Eingabe Iteratorinwirdendnur bei Bedarf, um ein Zeichen zu erhalten verglichen .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. - * Wenn die Zielsequenz eindeutig abgestimmt wird, wird auf die entsprechende
vboolWert eingestellt. Andernfalls wird infalsevgespeichert und std::ios_base::failbit wirderrzugeordnet. Wenn eindeutige Übereinstimmung nicht gefunden werden konnte, bevor die Eingabe beendet (in==end), wirderr|=std::ios_base::eofbitausgeführt .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.
Stufe 2: Charakter-Extraktion
- Wenn
in==end, Stufe 2 sofort beendet wird, werden keine weiteren Zeichen extrahiertOriginal: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. - Das nächste Zeichen wird von
inextrahiert, wie wenn sie vonchar_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. - * Wenn die Zeichen entspricht einem
"0123456789abcdefxABCDEFX+-", erweitert, um der Ländereinstellung char_type wie vonstd::use_facet<std::ctype<charT>>(str.getloc()).widen(), wird es an die entsprechendecharumgewandelt .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. - * Wenn der Charakter entspricht dem Dezimaltrennzeichen (
std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point())), wird es durch'.'ersetzt .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. - * Wenn die Zeichen entspricht das Tausendertrennzeichen (
std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep()) und die Tausende Trennung in Gebrauch ist überhauptstd::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0, dann, wenn der Dezimalpunkt'.'wurde noch nicht angesammelt, wird die Position des Zeichens rememebered, aber der Charakter ansonsten ignoriert. Wenn der Dezimalpunkt bereits angesammelt, wird das Zeichen verworfen und Stage 2 endet .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. - * Auf jeden Fall wird die Prüfung durchgeführt, ob die
charaus den vorherigen Schritten erhalten wird in dem Eingabefeld die durch die gegebene std::scanf Konvertierungsspezifizierer in Stufe 1 ausgewählt geparst werden würde, erlaubt. Wenn es erlaubt ist, wird es in einem temporären Puffer und Stufe 2 Wiederholungen akkumuliert. Wenn es nicht erlaubt ist, endet Stage 2 .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.
Stufe 3: Umwandlung und Speicherung
- Die Sequenz des in Stufe 2
chars akkumuliert wird, um einen numerischen Wert umgewandeltOriginal: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. - * Die Eingabe erfolgt wie von std::scanf mit der Umwandlung Spezifizierer in Stage 1 (bis C + +11) gewählt analysiertOriginal:* The input is parsed as if by std::scanf with the conversion specifier selected in Stage 1 (bis C + +11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * Die Eingabe erfolgt wie von std::strtoll für Ganzzahl analysiert
v, std::strtoull für unsigned integervoder std::strtold für Fließkomma-v(seit 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(seit C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Wenn die Umwandlung Funktion ausfällt, um das gesamte Feld zu überführen, wird der Wert in
0v(seit C++11) gespeichertOriginal:If the conversion function fails to convert the entire field, the value0is stored inv(seit C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Wenn die Umwandlung Funktion führt einen positiven Wert zu groß, um in der Art der
vpasst, wird die positive darstellbare Wert inv(seit C++11) gespeichertOriginal: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(seit C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Wenn die Umwandlung Funktion führt einen negativen Wert zu groß, um in der Art der
vpassen, wird die meisten negativen darstellbare Wert inv(seit C++11) gespeichertOriginal: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(seit C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - In jedem Fall, wenn die Umsetzungsfunktion ausfällt std::ios_base::failbit wird
errzugeordnetOriginal: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. - Andernfalls wird das numerische Ergebnis der Umwandlung in
vgespeichertOriginal: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. - * Wenn der Typ
vistboolund boolalpha nicht gesetzt ist, dann, wenn der Wert gespeichert werden soll0wirdfalsegespeichert, wenn der Wert gespeichert werden soll1,truegespeichert ist, für jeden anderen Wert std::ios_base::failbit zugeordnet isterr.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. - Danach wird Zifferngruppierung überprüft. wenn die Position eines der Tausender-Trennzeichen in Stage 2 verworfen nicht mit der Gruppierung nach
std::use_facet<std::numpunct<charT>>(str.getloc()).grouping()vorgesehen ist, std::ios_base::failbit umerrzugeordnet .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. - Wenn Stufe 2 durch den Test beendet wurde
in==endwirderr|=std::ios_base::eofbitausgeführt, um die eof-Bit gesetzt .Original: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.
Rückgabewert
in
Notes
In C + 98 / C 03 +, wenn ein Fehler auftritt,
v bleibt unverändert. In C + 11, wird auf einen Wert eingestellt, wie oben beschrieben .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.
Beispiel
| This section is incomplete Reason: no example |
Siehe auch
Extrakte formatierte Daten 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. (öffentliche Elementfunktion of std::basic_istream)
|