std::ctype
De cppreference.com
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
| Definido en el archivo de encabezado <locale>
|
||
template< class CharT >
class ctype;
|
||
Clase ctype encapsula rasgos de carácter de clasificación. Todas las operaciones realizadas a través de flujo de entrada
std::basic_istream<charT> utilizar el std::ctype<charT> de la configuración regional imbuida en la corriente de identificar espacios en blanco para tokenización entrada. Las operaciones de flujo de salida se aplican a std::ctype<charT>::widen() estrechas caracteres argumentos antes de la salida .Original:
Class ctype encapsulates character classification features. All stream input operations performed through
std::basic_istream<charT> use the std::ctype<charT> of the locale imbued in the stream to identify whitespace characters for input tokenization. Stream output operations apply std::ctype<charT>::widen() to narrow-character arguments prior to output.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.
Inheritance diagram
Dos especializaciones son proporcionados por la biblioteca estándar
Original:
Two specializations are provided by the standard library
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.
Definido en el encabezado
<locale> | |
| std::ctype<char> | proporciona equivalentes de la clasificación "C" locale. Esta especialización se utiliza para consultar la tabla de clasificación de caracteres
Original: provides equivalents of the "C" locale classification. This specialization uses table lookup for character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::ctype<wchar_t>
|
proporciona equivalentes de carácter ancho de la clasificación "C" locale
Original: provides wide character equivalents of the "C" locale classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Sumario
Tipos de miembros
Miembro de tipo
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
|
Las funciones miembro
construye una nueva faceta ctype Original: constructs a new ctype facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
destructs una faceta ctype Original: destructs a ctype facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro protegida) | |
Invoca do_is Original: invokes do_is The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Invoca do_scan_is Original: invokes do_scan_is The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Invoca do_scan_not Original: invokes do_scan_not The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Invoca do_toupper Original: invokes do_toupper The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Invoca do_tolowerOriginal: invokes do_tolowerThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Invoca do_widen Original: invokes do_widen The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
Invoca do_narrow. (función miembro pública) |
Protegido funciones miembro
[virtual] |
clasifica un carácter o una secuencia de caracteres Original: classifies a character or a character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
[virtual] |
localiza el primer carácter en una secuencia que se ajusta a la clasificación dada Original: locates the first character in a sequence that conforms to given classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
[virtual] |
localiza el primer carácter en una secuencia que no givne clasificación Original: locates the first character in a sequence that fails givne classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
[virtual] |
convierte un carácter o los caracteres a mayúsculas Original: converts a character or characters to uppercase The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
[virtual] |
convierte un carácter o caracteres en minúsculas Original: converts a character or characters to lowercase The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
[virtual] |
convierte un carácter o caracteres de char a charT Original: converts a character or characters from char to charT The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
[virtual] |
convierte un carácter o caracteres de charT a char Original: converts a character or characters from charT to char The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida) |
Objetos miembros
static std::locale::id id |
Identificador de la configuración regional 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 miembro público) |
Heredado de std::ctype_base
Member types
Tipo
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
mask
|
Tipo de máscara de bits sin especificar (enumeración, de tipo entero, o bitset)
Original: unspecified bitmask type (enumeration, integer type, or bitset) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Member constants
space [estático] |
el valor de mask clasificación de caracteres Identificar espacios en blanco Original: the value of mask identifying whitespace character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
print [estático] |
el valor de mask identificación de clasificación de caracteres imprimibles Original: the value of mask identifying printable character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
cntrl [estático] |
el valor de mask identificación de clasificación de caracteres de control Original: the value of mask identifying control character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
upper [estático] |
el valor de mask identificación de clasificación de caracteres en mayúscula Original: the value of mask identifying uppercase character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
lower [estático] |
el valor de mask identificación de clasificación de caracteres en minúsculas Original: the value of mask identifying lowercase character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
alpha [estático] |
el valor de mask identificación de clasificación de caracteres alfabéticos Original: the value of mask identifying alphabetic character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
digit [estático] |
el valor de mask identificación de clasificación de caracteres dígitos Original: the value of mask identifying digit character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
punct [estático] |
el valor de mask identificación de clasificación de caracteres puntuacion Original: the value of mask identifying punctuation character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
xdigit [estático] |
el valor de mask identificar clasificación hexadecimal dígito Original: the value of mask identifying hexadecimal digit character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
blank [estático] (C++11) |
el valor de mask identificación de clasificación de caracteres en blanco Original: the value of mask identifying blank character classification The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante miembro pública estática) |
alnum [estático] |
alpha | digit (constante miembro pública estática) |
graph [estático] |
alnum | punct (constante miembro pública estática) |
Ejemplo
El ejemplo siguiente muestra la modificación de un ctype que no sea <char> ctype para dividir un archivo CSV
Original:
The following example demonstrates modification of a ctype other than ctype<char> to tokenize of a CSV file
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.
Ejecuta este código
#include <iostream>
#include <locale>
#include <sstream>
struct csv_whitespace : std::ctype<wchar_t> {
bool do_is(mask m, char_type c) const
{
if ((m & space) && c == L' ') {
return false; // space will NOT be classified as whitespace
}
if ((m & space) && c == L',') {
return true; // comma will be classified as whitespace
}
return ctype::do_is(m, c); // leave the rest to the parent class
}
};
int main()
{
std::wstring in = L"Column 1,Column 2,Column 3\n123,456,789";
std::wstring token;
std::wcout << "default locale:\n";
std::wistringstream s1(in);
while (s1 >> token) {
std::wcout << " " << token << '\n';
}
std::wcout << "locale with modified ctype:\n";
std::wistringstream s2(in);
s2.imbue(std::locale(s2.getloc(), new csv_whitespace()));
while (s2 >> token) {
std::wcout << " " << token<< '\n';
}
}
Salida:
default locale:
Column
1,Column
2,Column
3
123,456,789
locale with modified ctype:
Column 1
Column 2
Column 3
123
456
789
Ver también
especialización de std::ctype para char tipo Original: specialization of std::ctype for type char The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (especialización de plantilla de clase) | |
define las categorías de clasificación de caracteres Original: defines character classification categories The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (plantilla de clase) | |
crea una faceta ctype para la localidad nombrada Original: creates a ctype facet for the named locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (plantilla de clase) |