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>| Definido no cabeçalho <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.
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.
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.
You can help to correct and verify the translation. Click here for instructions.
Índice
Fase 1: conversão seleção especificador
- I / O formato bandeiras são obtidos, como se porOriginal: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);
- Se o tipo de
vé um tipo inteiro, a escolha do primeiro dos cinco aplicável seguinte é selecionado: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.
- Se
basefield == oct, vai usar especificador de conversão%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. - Se
basefield == hex, vai usar especificador de conversão%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. - Se
basefield == 0, vai usar especificador de conversão%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. - Se o tipo de
vé assinado, vai usar a conversão especificador%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. - Se o tipo de
vnão é assinado, vai usar a conversão especificador%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.
- Para os tipos inteiros, modificador de comprimento é adicionado à especificação de conversão, se necessário:
hparashorteunsigned short,lparalongeunsigned long,llparalong longeunsigned 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. - Se o tipo de
véfloat, vai usar especificador de conversão%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. - Se o tipo de
védouble, vai usar especificador de conversão%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. - Se o tipo de
vélong double, vai usar especificador de conversão%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. - Se o tipo de
vévoid*, vai usar especificador de conversão%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. - Se o tipo de
vébooleboolalpha==0, procede como se o tipo devélong, excepto para o valor a ser armazenado novna etapa 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. - Se o tipo de
vébooleboolalpha!=0, a seguir substitui as fases 2 e 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. - * Caracteres sucessivos obtidos a partir da entrada iterator
insão comparados com os obtidos a partir de sequências de caracteres estd::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. Oiniterador de entrada é comparada comendapenas quando necessário para se obter um carácter.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. - * Se a sequência-alvo é exclusivamente combinado,
vestá definido para o valorboolcorrespondente. Caso contráriofalseé armazenado emve std::ios_base::failbit é atribuído aerr. 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,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.
Fase 2: extração de caráter
- Se
in==end, Fase 2 é rescindido imediatamente, sem outros caracteres são extraídosOriginal: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. - O próximo personagem é extraído
incomo se porchar_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. - * Se o personagem corresponde a um dos
"0123456789abcdefxABCDEFX+-", aumentou para char_type da localidade, como se porstd::use_facet<std::ctype<charT>>(str.getloc()).widen(), é convertido para o correspondentechar.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. - * 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 todosstd::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 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. - * Em qualquer dos casos, a verificação é feita se o
charobtidos 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 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.
Etapa 3: conversão e armazenagem
- A sequência de
chars acumulados na fase 2 é convertido para um valor numéricoOriginal: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. - * 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 paravinteiro sem sinal, ou std::strtold para ponto flutuantev(desde 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(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. - Se a função de conversão não consegue converter todo o campo, o
0valor é armazenado emv(desde C++11)Original:If the conversion function fails to convert the entire field, the value0is stored inv(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. - 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 emv(desde 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(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. - 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 emv(desde 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(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. - Em todo o caso, se a função de conversão não é atribuído a std::ios_base::failbit
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. - Caso contrário, o resultado numérico da conversão é armazenado em
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. - * Se o tipo de
véboolboolalpha 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 aerr.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. - 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 aerr.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. - 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 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.
Valor de retorno
in
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.
You can help to correct and verify the translation. Click here for instructions.
Exemplo
| Esta seção está incompleta Motivo: sem exemplo |
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)
|