X-Git-Url: https://git.llucax.com/z.facultad/75.42/string.git/blobdiff_plain/b18e440563dabec6bef71cbfa954bc5e38c84ca6..79ed016f24d7b105a070d49ee40496499440544e:/unicode.cpp diff --git a/unicode.cpp b/unicode.cpp index 398f82c..85512f7 100644 --- a/unicode.cpp +++ b/unicode.cpp @@ -38,15 +38,6 @@ Unicode::~Unicode(void) { #endif } -bool Unicode::is_endl(void) const { -#ifdef DEBUG - std::cerr << "En Unicode::is_endl()." << std::endl; -#endif - // Si los primeros o últimos 8 bits son 0xA = 10 = '\n' devuelve true. - return (static_cast(caracter) == '\n') - || (static_cast(caracter >> 8) == '\n'); -} - Unicode& Unicode::operator=(const Unicode& unicode) { #ifdef DEBUG std::cerr << "En operator= de Unicode." << std::endl; @@ -55,14 +46,6 @@ Unicode& Unicode::operator=(const Unicode& unicode) { return *this; } -Unicode& Unicode::operator=(short c) { -#ifdef DEBUG - std::cerr << "En operator= de Unicode (short)." << std::endl; -#endif - caracter = c; - return *this; -} - bool Unicode::operator<(const Unicode& unicode) const { #ifdef DEBUG std::cerr << "En operator< de Unicode." << std::endl; @@ -77,13 +60,6 @@ bool Unicode::operator==(const Unicode& unicode) const { return caracter == unicode.caracter; } -Unicode::operator short(void) const { -#ifdef DEBUG - std::cerr << "En cast de Unicode a char." << std::endl; -#endif - return static_cast(caracter); -} - Unicode::operator char(void) const { #ifdef DEBUG std::cerr << "En cast de Unicode a char." << std::endl; @@ -108,13 +84,12 @@ std::istream& operator>>(std::istream& in, Unicode& unicode) { #ifdef DEBUG std::cerr << "En operator>> de Unicode." << std::endl; #endif - char c1; - char c2; - // Lee los 2 primeros caracteres que no sean espacio. - in >> c1 >> std::noskipws >> c2 >> std::skipws; - // Los asigno como un short cuyos bits mas significativos corresponden al - // caracter 1 y los menos significativos al caracter 2. - unicode.caracter = (static_cast(c1) << 8) + c2; + char c; + // Lee el primer caracter ASCII. + in >> c; + // Lo asigno como un short cuyos bits menos significativos son los del + // caracter leído. + unicode.caracter = static_cast(c); return in; }