std::locale
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>
|
||
class locale; |
||
Um objeto de std::locale classe é um conjunto de ponteiros de referência, contados a facetas. Cada objeto de fluxo do C + + biblioteca de entrada / saída está associada a um std::locale e usa suas facetas para análise e formatação de todos os dados. Além disso, um objecto localidade é associada com cada objeto basic_regex. Local objetos também podem ser usados como predicados que realizam agrupamento string com os contêineres padrão e algoritmos e pode ser acessado diretamente para obter ou modificar as facetas que possuem.
Original:
An object of class std::locale is an indexed set of reference-counted pointers to facets. Each stream object of the C++ input/output library is associated with an std::locale and uses its facets for parsing and formatting of all data. In addition, a locale object is associated with each basic_regex object. Locale objects can also be used as predicates that perform string collation with the standard containers and algorithms and can be accessed directly to obtain or modify the facets they hold.
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.
Cada localidade construída em um programa C + + tem, pelo menos, os seguintes aspectos padrão, mas um programa pode definir especializações adicionais ou facetas completamente novos e adicioná-los a qualquer objeto localidade existente.
Original:
Each locale constructed in a C++ program holds at least the following standard facets, but a program may define additional specializations or completely new facets and add them to any existing locale object.
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.
| Supported facets | |
|---|---|
std::collate<char>
|
std::collate<wchar_t>
|
std::ctype<char>
|
std::ctype<wchar_t>
|
std::codecvt<char,char,mbstate_t>std::codecvt<char16_t,char,mbstate_t>
|
std::codecvt<char32_t,char,mbstate_t>std::codecvt<wchar_t,char,mbstate_t>
|
std::moneypunct<char> std::moneypunct<char,true>
|
std::moneypunct<wchar_t>std::moneypunct<wchar_t,true>
|
std::money_get<char>
|
std::money_get<wchar_t>
|
std::money_put<char>
|
std::money_put<wchar_t>
|
std::numpunct<char>
|
std::numpunct<wchar_t>
|
std::num_get<char>
|
std::num_get<wchar_t>
|
std::num_put<char>
|
std::num_put<wchar_t>
|
std::time_get<char>
|
std::time_get<wchar_t>
|
std::time_put<char>
|
std::time_put<wchar_t>
|
std::messages<char>
|
std::messages<wchar_t>
|
Tipos de membro
o tipo de índice faceta: cada classe faceta deve declarar ou herdar um membro estático público deste tipo Original: the facet index type: each facet class must declare or inherit a public static member of this type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe) | |
a classe base para todas as categorias faceta: cada faceta de qualquer categoria é derivado deste tipo Original: the base class for all facet categories: each facet of any category is derived from this type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe) | |
category |
int (typedef) |
Objetos Membros
none [estática] |
um valor zero do tipo category indicando nenhuma categoria faceta Original: a zero value of type category indicating no facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
collate [estática] |
um valor bitmask de category tipo indicando a categoria faceta de agrupamento Original: a bitmask value of type category indicating the collate facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
ctype [estática] |
um valor bitmask de category tipo indicando a categoria faceta ctype Original: a bitmask value of type category indicating the ctype facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
monetary [estática] |
um valor bitmask de category tipo indicando a categoria faceta monetária Original: a bitmask value of type category indicating the monetary facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
numeric [estática] |
um valor bitmask de category tipo indicando a categoria faceta numérico Original: a bitmask value of type category indicating the numeric facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
time [estática] |
um valor de máscara de bits indicando o tipo category categoria faceta tempo Original: a bitmask value of type category indicating the time facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
messages [estática] |
um valor de máscara de bits indicando o tipo category categoria faceta mensagens Original: a bitmask value of type category indicating the messages facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (membro estático público constante) |
all [estática] |
collate | ctype | monetary | numeric | time | messages (membro estático público constante) |
Funções de membro
constrói uma nova localidade Original: constructs a new locale 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 o local e as facetas cuja referência contagem torna-se zero Original: destructs the locale and the facets whose reference count becomes zero 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) | |
substitui uma localidade Original: replaces a locale 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) | |
constrói uma localidade com tempo de compilação faceta identificada copiado de outro local Original: constructs a locale with compile-time identified facet copied from another locale 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) | |
retorna o nome da localidade ou "*" se sem nome Original: returns the name of the locale or "*" if unnamed 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) | |
comparação de igualdade entre os objetos de localidade Original: equality comparison between locale objects 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) | |
| lexicographically compares two strings using this locale's collate facet (função pública membro) | |
[estática] |
muda a localidade global Original: changes the global locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função public static membro) |
[estática] |
obtém-se uma referência ao local "C" Original: obtains a reference to the "C" locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função public static membro) |
Exemplo
Demonstra o prólogo típico de um programa local e minúsculas (multi-plataforma)
Original:
Demonstrates the typical prologue of a locale-sensitive program (cross-platform)
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.
#include <iostream>
#include <locale>
int main()
{
std::wcout << "User-preferred locale setting is " << std::locale("").name().c_str() << '\n';
// on startup, the global locale is the "C" locale
std::wcout << 1000.01 << '\n';
// replace the C++ global locale as well as the C locale with the user-preferred locale
std::locale::global(std::locale("") );
// use the new global locale for future wide character output
std::wcout.imbue(std::locale());
// output the same number again
std::wcout << 1000.01 << '\n';
}
Saída:
User-preferred locale setting is en_US.UTF8
1000.01
1,000.01
Veja também
obtém um aspecto de uma localidade Original: obtains a facet from a locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |
verifica se um local implementa um aspecto específico Original: checks if a locale implements a specific facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |
define localidade Original: sets locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::ios_base função pública membro)
| |
retorna local atual Original: returns current locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (of std::ios_base função pública membro)
|