Espacios de nombres
Variantes
Acciones

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

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

 
 
Localizaciones biblioteca
Locales y facetas
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
Carácter clasificación
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.
Conversiones
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 clases categoría 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.
Categorías faceta
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.
Específico de la localidad facetas
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.
Facetas código de conversión
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
Las funciones miembro
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)
función miembro pública, llama a la función do_get miembro de la clase más derivada .
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)
lee los caracteres de la in iterador de entrada y genera el valor del tipo de v, teniendo en cuenta indicadores de formato de flujo IO de str.flags(), las reglas de clasificación de caracteres de std::use_facet<std::ctype<charT>>(str.getloc()), y caracteres numéricos de puntuación de std::use_facet<std::numpunct<charT>>(str.getloc()). Esta función es llamada por todos los operadores de flujo con formato de entrada como 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 conversión ocurre en tres etapas
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.

Contenido

[editar] Etapa 1: Conversión de selección especificador

  • I / O banderas de formato se obtienen, como por
    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);
  • Si el tipo de v es un tipo entero, la elección de la primera aplicable de las cinco siguientes se selecciona:
    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.
Si basefield == oct, utilizará especificador de conversión %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.
Si basefield == hex, utilizará especificador de conversión %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.
Si basefield == 0, utilizará especificador de conversión %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.
Si el tipo de v está firmado, usaremos la conversión especificador %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.
Si el tipo de v no está firmado, usaremos la conversión especificador %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.
  • Para tipos de enteros, modificador de longitud se añade a la especificación de la conversión si es necesario: h para short y unsigned short, l para long y unsigned long, ll para long long y 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.
  • Si el tipo de v es float, se utilizan la conversión especificador %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.
  • Si el tipo de v es double, se utilizan la conversión especificador %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.
  • Si el tipo de v es long double, se utilizan la conversión especificador %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.
  • Si el tipo de v es void*, se utilizan la conversión especificador %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.
  • Si el tipo de v es bool y boolalpha==0, procede como si el tipo de v es long, excepto para el valor que se almacena en v en la etapa 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.
  • Si el tipo de v es bool y boolalpha!=0, la siguiente sustituye a las etapas 2 y 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.
  • * Caracteres sucesivos obtenidos a partir de la iterador de entrada in se comparan con las secuencias de caracteres obtenidos de std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() y sólo std::use_facet<std::numpunct<charT> >(str.getloc()).truename() tan necesario como para identificar la coincidencia única. El in iterador de entrada se compara con end sólo cuando sea necesario para obtener un carácter .
    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.
  • * Si la secuencia diana es coincidente y único, v se establece en el valor bool correspondiente. De lo contrario false se almacena en v y std::ios_base::failbit se asigna a err. Si el partido único no se ha encontrado antes de la entrada terminó (in==end), err|=std::ios_base::eofbit se ejecuta .
    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.

[editar] Etapa 2: extracción carácter

  • Si in==end, nivel 2 se termina inmediatamente, sin caracteres adicionales se extraen
    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.
  • El siguiente carácter se extrae de in como por 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.
  • * Si el carácter coincide con uno de "0123456789abcdefxABCDEFX+-", se amplió a char_type de la localización como por std::use_facet<std::ctype<charT>>(str.getloc()).widen(), que se convierte en el correspondiente 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.
  • * Si el personaje coincide con el separador decimal (std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point())), se sustituye por '.' .
    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 el carácter coincide con el separador de miles (std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep()) y la separación de miles está en uso en todo std::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0, a continuación, si el '.' punto decimal aún no ha sido acumulada, la posición del carácter se rememebered, pero el carácter de lo contrario se ignora. Si el punto decimal se ha acumulado ya, el carácter se descarta y se termina la etapa 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.
  • * En cualquier caso, la comprobación se realiza si el char obtenido a partir de los pasos anteriores se permite en el campo de entrada que se va a analizar por std::scanf dado el especificador de conversión seleccionado en la Etapa 1. Si se permite, se acumula en una memoria intermedia temporal y la Etapa 2 se repite. Si no se permite, Etapa 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.

[editar] Etapa 3: la conversión y almacenamiento

  • La secuencia de chars acumulados en la Etapa 2 se convierte en un valor numérico
    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.
  • * La entrada es interpretada como por std::scanf con el especificador de conversión seleccionado en la Etapa 1 (hasta C++11)
    Original:
    * The input is parsed as if by std::scanf with the conversion specifier selected in Stage 1 (hasta C++11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * La entrada es interpretada como por std::strtoll por entero con signo v, std::strtoull para v entero sin signo, o std::strtold de punto flotante v (desde 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 (desde 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 función de error de conversión para convertir el campo entero, la 0 valor se almacena en v (desde C++11)
    Original:
    If the conversion function fails to convert the entire field, the value 0 is stored in v (desde 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 los resultados de la función de conversión de un valor positivo demasiado grande para caber en el tipo de v, el valor representable más positivo se almacena en v (desde 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 (desde 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 los resultados de la función de conversión en un valor negativo demasiado grande para caber en el tipo de v, el valor representable más negativo se almacena en v (desde 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 (desde C++11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • En cualquier caso, si la función de error de conversión std::ios_base::failbit se asigna a 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.
  • De lo contrario, el resultado numérico de la conversión se almacena en 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.
  • * Si el tipo de v es bool y boolalpha no se establece, entonces, si el valor a almacenar es 0, false está almacenado, si el valor a almacenar es 1, true se almacena, para cualquier std::ios_base::failbit otro valor se asigna a 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.
  • Después de esto, agrupación de dígitos está marcada. Si la posición de cualquiera de los separadores de miles desechadas en la etapa 2 no está de acuerdo con el agrupamiento proporcionado por std::use_facet<std::numpunct<charT>>(str.getloc()).grouping(), std::ios_base::failbit se asigna a 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.
  • Si la etapa 2 se terminó mediante la prueba in==end, err|=std::ios_base::eofbit se ejecuta para establecer el bit de 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.

[editar] Valor de retorno

in

[editar] Notas

En C + +98 / C + 03, si se produce un error, v se deja sin cambios. En C + 11, se establece en un valor tal como se describe más arriba .
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.

[editar] Ejemplo

[editar] Ver también

extractos de formato de datos
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.

(miembro público of std::basic_istream función) [edit]