Espaços nominais
Variantes
Acções

std::num_get

Da cppreference.com
< cpp‎ | locale

 
 
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>
template<

    class CharT,
    class InputIt = std::istreambuf_iterator<CharT>

> class num_get;
Classe std::num_get encapsula as regras para análise de representações de seqüência de valores do tipo bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, e void*. Os operadores de formatação padrão de entrada (como cin >> n;) usar a faceta std::num_get da localidade do fluxo de I / O para analisar as representações de texto dos números.
Original:
Class std::num_get encapsulates the rules for parsing string representations of values of type bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, and void*. The standard formatting input operators (such as cin >> n;) use the std::num_get facet of the I/O stream's locale to parse the text representations of the numbers.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cpp/locale/locale/facetstd-num get-inheritance.svg
Sobre esta imagem

Inheritance diagram

Índice

[editar] Requisitos de tipo

-
InputIt must meet the requirements of InputIterator.

[editar] Especializações

Duas especializações e duas especializações parciais são fornecidos pela biblioteca padrão e são implementadas por todos os objetos localidade criado em um programa em C + +:
Original:
Two specializations and two partial specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <locale>
std::num_get<char>
cria análise de cadeia estreita de números
Original:
creates narrow string parsing of numbers
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<wchar_t>
cria análise de cadeia gama de números
Original:
creates wide string parsing of numbers
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<char, InputIt>
cria análise de cadeia estreita de números usando iterador de entrada personalizado
Original:
creates narrow string parsing of numbers using custom input iterator
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<wchar_t, InputIt>
cria análise de cadeia gama de números usando iterador de entrada personalizado
Original:
creates wide string parsing of numbers using custom input iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Tipos de membro

Tipo de membro
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
char_type CharT
iter_type InputIt

[editar] Funções de membro

constrói uma faceta num_get novo
Original:
constructs a new num_get facet
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
destrói uma faceta num_get
Original:
destructs a num_get facet
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(protegido função de membro)
Invoca do_get
Original:
invokes do_get
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)

[editar] Objetos Membros

static std::locale::id id
' ID da localidade
Original:
id of the locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(objeto membro público)

[editar] Protegido funções de membro

[virtual]
analisa um número a partir de um fluxo de entrada
Original:
parses a number from an input stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(virtual protegido função de membro)

[editar] Exemplo

#include <iostream>
#include <locale>
#include <string>
#include <sstream>
#include <iterator>
int main()
{
    std::string de_double = "1.234.567,89";
    std::string us_double = "1,234,567.89";
 
    // parse using streams
    std::istringstream de_in(de_double);
    de_in.imbue(std::locale("de_DE"));
    double f1;
    de_in >> f1;
 
    std::istringstream us_in(de_double);
    us_in.imbue(std::locale("en_US.UTF-8"));
    double f2;
    us_in >> f2;
 
    std::cout << "Parsing " << de_double << " as double gives " << std::fixed
              << f1 << " in de_DE locale and " << f2 << " in en_US\n";
 
    // use the facet directly
    std::istringstream s3(us_double);
    s3.imbue(std::locale("en_US.UTF-8"));
    auto& f = std::use_facet<std::num_get<char>>(s3.getloc());
    std::istreambuf_iterator<char> beg(s3), end;
    double f3;
    std::ios::iostate err;
    f.get(beg, end, s3, err, f3);
    std::cout << "parsing " << us_double
              << " as double using raw en_US facet gives " << f3 << '\n';
}

Output:

Parsing 1.234.567,89 as double gives 1234567.890000 in de_DE locale and 1.234000 in en_US
parsing 1,234,567.89 as double using raw en_US facet gives 1234567.890000

[editar] Veja também

define as regras de pontuação numéricos
Original:
defines numeric punctuation rules
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de classe) [edit]
formatos de valores numéricos para a saída como uma seqüência de caracteres
Original:
formats numeric values for output as character sequence
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de classe) [edit]
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]