Espaços nominais
Variantes
Acções

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

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

 
 
Biblioteca localizações
Localidades e 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
Classificação de caracteres
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.
Conversões
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 classes base da categoria
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.
Categorias 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íficos da localidade 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 de conversão de código
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 localidade
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
Funções de membro
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)
função de membro público, chama a do_get função de membro da classe derivada mais.
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)
lê os caracteres a partir da in iterador entrada e gera o valor do tipo de v, tendo em conta as bandeiras IO formatação de fluxo de str.flags(), regras de classificação de caracteres a partir de std::use_facet<std::ctype<charT>>(str.getloc()), e caracteres de pontuação numéricos de std::use_facet<std::numpunct<charT>>(str.getloc()). Esta função é chamada por todos os operadores de entrada de fluxo formatados 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.
A conversão ocorre em três fases
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.

Índice

[editar] Fase 1: conversão seleção especificador

  • I / O formato bandeiras são obtidos, como se 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);
  • Se o tipo de v é um tipo inteiro, a escolha do primeiro dos cinco aplicável seguinte é selecionado:
    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, vai usar especificador de conversão %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, vai usar especificador de conversão %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, vai usar especificador de conversão %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 o tipo de v é assinado, vai usar a conversão 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.
Se o tipo de v não é assinado, vai usar a conversão 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 os tipos inteiros, modificador de comprimento é adicionado à especificação de conversão, se necessário: h para short e unsigned short, l para long e unsigned long, ll para 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 o tipo de v é float, vai usar especificador de conversão %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 o tipo de v é double, vai usar especificador de conversão %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 o tipo de v é long double, vai usar especificador de conversão %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 o tipo de v é void*, vai usar especificador de conversão %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 o tipo de v é bool e boolalpha==0, procede como se o tipo de v é long, excepto para o valor a ser armazenado no v na 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.
  • Se o tipo de v é bool e boolalpha!=0, a seguir substitui as fases 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.
  • * Caracteres sucessivos obtidos a partir da entrada iterator in são comparados com os obtidos a partir de sequências de caracteres e std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() std::use_facet<std::numpunct<charT> >(str.getloc()).truename() apenas quando necessário, para identificar o jogo original. O in iterador de entrada é comparada com end apenas quando necessário para se obter um 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.
  • * Se a sequência-alvo é exclusivamente combinado, v está definido para o valor bool correspondente. Caso contrário false é armazenado em v e std::ios_base::failbit é atribuído a err. Se correspondência única não pôde ser encontrado antes da entrada terminou (in==end), err|=std::ios_base::eofbit é executado.
    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] Fase 2: extração de caráter

  • Se in==end, Fase 2 é rescindido imediatamente, sem outros caracteres são extraídos
    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.
  • O próximo personagem é extraído in como se 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.
  • * Se o personagem corresponde a um dos "0123456789abcdefxABCDEFX+-", aumentou para char_type da localidade, como se por std::use_facet<std::ctype<charT>>(str.getloc()).widen(), é convertido para o correspondente 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 o personagem corresponde ao separador de decimal (std::use_facet<std::numpunct<charT>>(str.getloc()).decimal_point())), ele é substituído 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.
  • * Se o personagem corresponde ao separador de milhares (std::use_facet<std::numpunct<charT>>(str.getloc()).thousands_sep()) e a separação de milhares está em uso em todos std::use_facet<std::numpunct<charT>>(str.getloc()).grouping().length() != 0, em seguida, se o ponto decimal '.' ainda não tiver sido acumulada, a posição do caracter é rememebered, mas o caracter é outra forma ignoradas. Se o ponto decimal já foi acumulado, o personagem é descartado 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.
  • * Em qualquer dos casos, a verificação é feita se o char obtidos a partir dos passos anteriores é permitida no campo de entrada que seria analisado por std::scanf dado o especificador de conversão seleccionada na Fase 1. Se for permitido, é acumulada num buffer temporário e da fase 2 repetições. Se não for permitido, Stage 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: conversão e armazenagem

  • A sequência de chars acumulados na fase 2 é convertido para um 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.
  • * A entrada é analisado como se por std::scanf com o especificador de conversão selecionados na Fase 1 (até C + 11)
    Original:
    * The input is parsed as if by std::scanf with the conversion specifier selected in Stage 1 (até C + 11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * A entrada é analisado como se por std::strtoll para o inteiro assinado v, std::strtoull para v inteiro sem sinal, ou std::strtold para ponto flutuante v (a partir do 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 (a partir do 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 a função de conversão não consegue converter todo o campo, o 0 valor é armazenado em v (a partir do C++ 11)
    Original:
    If the conversion function fails to convert the entire field, the value 0 is stored in v (a partir do 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 os resultados da conversão de função de um valor positivo muito grande para caber no tipo de v, o valor mais positivo representável é armazenado em v (a partir do 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 (a partir do 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 os resultados da conversão de função em um valor negativo muito grande para caber no tipo de v, o valor mais negativo representável é armazenado em v (a partir do 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 (a partir do C++ 11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Em todo o caso, se a função de conversão não é atribuído a std::ios_base::failbit 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.
  • Caso contrário, o resultado numérico da conversão é armazenado em 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 o tipo de v é bool boolalpha e não está definida, então, se o valor a ser armazenado é 0, false é armazenado, se o valor a ser armazenado é 1, true é armazenado, por qualquer outro valor std::ios_base::failbit é atribuído 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.
  • Depois disso, agrupamento de dígitos é verificado. , se a posição de qualquer um dos separadores de milhares descartados no Estágio 2 não coincidir com o agrupamento fornecida por std::use_facet<std::numpunct<charT>>(str.getloc()).grouping(), std::ios_base::failbit é atribuído 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.
  • Se Fase 2 foi encerrado pelo teste in==end, err|=std::ios_base::eofbit é executado para definir o 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.

[editar] Valor de retorno

in

[editar] Notas

Em C + +98 / C + 03, se ocorrer um erro, v é deixado inalterado. Em C + 11, ela é definida como um valor, como descrito acima.
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] Exemplo

[editar] Veja também

extratos dados formatados
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 função pública membro) [edit]