Namespace
Varianti

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

Da cppreference.com.
< cpp‎ | locale‎ | num get

 
 
Localizzazioni libreria
Impostazioni internazionali e sfaccettature
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
Carattere classificazione
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.
Conversioni
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facet categoria classi di base
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.
Facet categorie
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.
Locale specifici aspetti
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.
Codice di conversione sfaccettature
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 locale
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
Membri funzioni
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)
funzione membro pubblica, chiama la do_get funzione membro della classe più derivata.
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)
legge i caratteri dal in iteratore di input e genera il valore del tipo di v, tenendo conto di formattazione bandiere streaming IO da str.flags(), regole di classificazione dei caratteri da std::use_facet<std::ctype<charT>>(str.getloc()), e caratteri di punteggiatura numerici da std::use_facet<std::numpunct<charT>>(str.getloc()). Questa funzione viene chiamata da tutti gli operatori in formato streaming di input quali 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.
La conversione avviene in tre fasi
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.

Indice

[modifica] Fase 1: selezione specificatore di conversione

  • I / O flags formato sono ottenuti, come per
    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);
  • Se il tipo di v è di tipo intero, la prima scelta applicabili delle seguenti cinque è selezionato:
    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.
Se basefield == oct, utilizzerà specificatore di conversione %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.
Se basefield == hex, utilizzerà specificatore di conversione %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.
Se basefield == 0, utilizzerà specificatore di conversione %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.
Se il tipo di v è firmato, utilizzerà specificatore di conversione %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.
Se il tipo di v non è firmato, userà specificatore di conversione %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.
  • Per i tipi interi, modificatore di lunghezza viene aggiunto alla specifica di conversione, se necessario: h per short e unsigned short, l per long e unsigned long, ll per long long e 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.
  • Se il tipo di v è float, userà specificatore di conversione %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.
  • Se il tipo di v è double, userà specificatore di conversione %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.
  • Se il tipo di v è long double, userà specificatore di conversione %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.
  • Se il tipo di v è void*, userà specificatore di conversione %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.
  • Se il tipo di v è bool e boolalpha==0, procede come se il tipo di v è long, tranne per il valore da memorizzare in v in fase 3.
    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.
  • Se il tipo di v è bool e boolalpha!=0, il seguente sostituisce fasi 2 e 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.
  • * Caratteri successivi ottenuta dalla in iteratore di input vengono confrontati con le sequenze di caratteri ottenuti std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() e std::use_facet<std::numpunct<charT> >(str.getloc()).truename() solamente come necessario per identificare la corrispondenza univoca. Il in iteratore di input viene confrontato end solo quando necessario per ottenere un carattere.
    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.
  • * Se la sequenza bersaglio è corrispondenza univoca, v viene impostato al valore bool corrispondente. In caso contrario, viene memorizzato in false v e std::ios_base::failbit viene assegnato a err. Se corrispondenza univoca non è stato trovato prima dell'ingresso chiuso (in==end), err|=std::ios_base::eofbit viene eseguito.
    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.

[modifica] Fase 2: estrazione carattere

  • Se in==end, Fase 2 è terminata immediatamente, non vengono estratti altri caratteri
    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.
  • Il carattere successivo viene estratto dal in come per 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.
  • * Se il carattere corrisponde a una delle "0123456789abcdefxABCDEFX+-", allargato a char_type dell'unità locale come per std::use_facet<std::ctype<charT>>(str.getloc()).widen(), viene convertito nel corrispondente 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.
  • * Se il carattere corrisponde al separatore decimale punto (std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point())), è sostituito da '.'.
    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.
  • * Se il carattere corrisponde al separatore di migliaia (std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep()) e la separazione delle migliaia è usato da tutte std::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0, quindi se il '.' punto decimale non è ancora stata accumulata, la posizione del carattere viene rememebered, ma il carattere è altrimenti ignorato. Se il punto decimale è già stato accumulato, il carattere viene scartato e fase 2 termina.
    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.
  • * In ogni caso, il controllo viene effettuato se il char ottenuta dai passaggi precedenti è ammesso nel campo di immissione che sarebbe analizzato da std::scanf data l'indicatore di conversione selezionato nella fase 1. Se è consentito, viene accumulata in un buffer temporaneo e Stage 2 ripete. Se non è consentito, fase 2 termina.
    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.

[modifica] Fase 3: conversione e lo stoccaggio

  • La sequenza di chars accumulati nella fase 2 viene convertito in un valore numerico
    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.
  • * L'ingresso viene analizzato come per std::scanf con lo specificatore di conversione selezionato nella fase 1 (C fino + 11)
    Original:
    * The input is parsed as if by std::scanf with the conversion specifier selected in Stage 1 (C fino + 11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * L'ingresso viene analizzato come per std::strtoll per intero con segno v, std::strtoull per v numero intero senza segno, o std::strtold per virgola mobile v (dal 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 (dal C++11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Se la funzione di conversione non riesce a convertire l'intero campo, il 0 valore viene memorizzato in v (dal C++11)
    Original:
    If the conversion function fails to convert the entire field, the value 0 is stored in v (dal C++11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Se i risultati delle funzioni di conversione in un valore positivo troppo grande per il tipo di v, il valore più positivo rappresentabile è memorizzato in v (dal 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 (dal C++11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Se i risultati delle funzioni di conversione in un valore negativo troppo grande per il tipo di v, il valore più negativo rappresentabile è memorizzato in v (dal 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 (dal 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 ogni caso, se la funzione di conversione non riesce std::ios_base::failbit è assegnato err
    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.
  • Altrimenti, il risultato numerico della conversione è memorizzato in 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.
  • * Se il tipo di v è bool e boolalpha non è impostato, se il valore da memorizzare è 0, false viene memorizzato, se il valore da memorizzare è 1, true viene memorizzato, per qualsiasi std::ios_base::failbit altro valore viene assegnato err.
    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.
  • Dopo questo, raggruppamento cifre è selezionata. Se la posizione di uno dei separatori di migliaia scartati nella fase 2 non corrisponde al raggruppamento fornito da std::use_facet<std::numpunct<charT>>(str.getloc()).grouping(), std::ios_base::failbit è assegnato 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 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.
  • Se Fase 2 si è concluso con la prova in==end, err|=std::ios_base::eofbit viene eseguito per impostare il bit 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.

[modifica] Valore di ritorno

in

[modifica] Note

In C + +98 / C + 03, se si verifica un errore, v rimane invariato. In C + 11, è impostato ad un valore come descritto sopra.
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.

[modifica] Esempio

[modifica] Vedi anche

estratti i dati formattati
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.

(membro pubblico of std::basic_istream funzione) [edit]