#include <Character.h>
Inheritance diagram for Core::Character:
Public Member Functions | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual int | byteSize (void) |
virtual int | digitValue (void) |
virtual long | hash (void) const |
Answer object hash value. | |
virtual bool | isEqual (const Object *object) const |
Compare receiver with given object. | |
virtual bool | isEqual (const Object &object) const |
Compare receiver with given object. | |
virtual bool | isEqual (char cChar) const |
virtual unsigned long | asInteger (void) |
virtual Character * | asLowercase (void) |
Convert character to its lowercase form. | |
virtual Character * | asUppercase (void) |
Convert character to its uppercase form. | |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual bool | isCharacter (void) const |
Answer if the receiver is a Character. | |
virtual bool | isDigit (void) const |
virtual bool | isLowercase (void) const |
virtual bool | isSeparator (void) const |
virtual bool | isUppercase (void) const |
virtual bool | isVowel (void) const |
virtual void | visitBy (Visitor *visitor) |
Static Public Member Functions | |
static Dictionary * | characterStore (void) |
static Character * | cr (void) |
static Character * | lf (void) |
static Character * | space (void) |
static Character * | tab (void) |
static Character * | value (unsigned long val) |
static Character * | value (Integer *val) |
Protected Member Functions | |
Character (unsigned long val) | |
Protected Attributes | |
unsigned long | _value |
Static Protected Attributes | |
static Dictionary * | character_store = nil |
Definition at line 38 of file Character.h.
|
Definition at line 36 of file Character.cc. References _value. Referenced by value(). 00037 { 00038 _value = val; 00039 }
|
|
Definition at line 139 of file Character.cc. References _value. Referenced by digitValue(), Core::UTF8StreamEncoder::encodeTo(), Core::UCS2StreamEncoder::encodeTo(), Tools::CommandLineArgument::fillGetOptLongOption(), Core::EncodedStreamFactory::normalizedEncoding(), Core::TwoByteString::put(), and Core::ByteString::put(). 00140 { 00141 return _value; 00142 }
|
|
Convert character to its lowercase form.
Definition at line 144 of file Character.cc. References _value, and value().
|
|
Convert character to its uppercase form.
Definition at line 149 of file Character.cc. References _value, and value(). Referenced by Core::String::matchesPattern().
|
|
Definition at line 100 of file Character.cc. References _value. Referenced by Core::StringImpl::asByteString(), Core::StringImpl::asTwoByteString(), Core::UCS2StreamEncoder::encodeTo(), and Core::String::put(). 00101 { 00102 if (_value < 256) return 1; 00103 if (_value < 65536) return 2; 00104 return 4; 00105 }
|
|
Definition at line 47 of file Character.cc. References character_store, and nil. Referenced by value(). 00048 { 00049 if (character_store == nil) 00050 character_store = new Dictionary(128); 00051 return character_store; 00052 }
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Object. Definition at line 42 of file Character.cc. 00043 { 00044 return new String("Character"); 00045 }
|
|
Definition at line 55 of file Character.cc. References value(). Referenced by Core::Stream::cr(), Core::LineEndConvertor::nextPut(), and Core::LineEndConvertor::setLineEndCharacter(). 00056 { 00057 return value('\r'); 00058 }
|
|
Definition at line 107 of file Character.cc. References asInteger(). Referenced by Core::ByteCharacterEncoder::integerValueFrom(). 00108 { 00109 int code = asInteger(); 00110 int val = code - '0'; 00111 if (val <= 9) return val; 00112 val = code - 'A'; 00113 if (val >= 0 && val < 26) return val + 10; 00114 val = code - 'a'; 00115 if (val >= 0 && val < 26) return val + 10; 00116 return -1; 00117 }
|
|
Answer object hash value. The value should be same for objects found equal with isEqual() method. So if you rewrite this method you should rewrite isEqual() method too. Reimplemented from Core::Object. Definition at line 120 of file Character.cc. References _value. 00121 { 00122 return (long) _value; 00123 }
|
|
Answer if the receiver is a Character.
Reimplemented from Core::Object. Definition at line 165 of file Character.cc. 00166 { 00167 return true; 00168 }
|
|
Definition at line 182 of file Character.cc. References _value. Referenced by Core::EncodedStreamFactory::normalizedEncoding(). 00183 { 00184 return isdigit(_value); 00185 }
|
|
Definition at line 133 of file Character.cc. References _value. 00134 { 00135 return _value == cChar; 00136 }
|
|
Compare receiver with given object. Do not rewrite this method. It just a sugar for Object::isEqual(Object *).
Reimplemented from Core::Object. Definition at line 69 of file Character.h. References Core::Object::isEqual(). 00070 { return Object::isEqual(object); }
|
|
Compare receiver with given object. This method could compare objects with more sophisticated algorithm (eg. based on instance variables comparing or so). If you rewrite this method you should rewrite hash() too.
Reimplemented from Core::Object. Definition at line 125 of file Character.cc. Referenced by Core::String::matchesPattern(), Tools::CommandLineArgument::matchShortArgument(), and Core::LineEndConvertor::next(). 00126 { 00127 if (object == nil) return false; 00128 00129 return object->isCharacter() && 00130 _value == ((Character *) object)->_value; 00131 }
|
|
Definition at line 187 of file Character.cc. References _value. 00188 { 00189 return islower(_value); 00190 }
|
|
Definition at line 170 of file Character.cc. References _value. 00171 { 00172 return isspace(_value); 00173 }
|
|
Definition at line 192 of file Character.cc. References _value. 00193 { 00194 return isupper(_value); 00195 }
|
|
Definition at line 175 of file Character.cc. References _value. 00176 { 00177 char upperCase = toupper(_value); 00178 return upperCase == 'A' || upperCase == 'E' || upperCase == 'I' || 00179 upperCase == 'Y' || upperCase == 'O' || upperCase == 'U'; 00180 }
|
|
Definition at line 60 of file Character.cc. References value(). Referenced by Core::Stream::lf(), Core::LineEndConvertor::next(), Core::Stream::nextLine(), and Core::LineEndConvertor::nextPut(). 00061 { 00062 return value('\n'); 00063 }
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented from Core::Object. Definition at line 155 of file Character.cc. References _value, Core::String::format(), Core::Stream::nextPut(), and Core::Stream::nextPutAll(). 00156 { 00157 stream->nextPut('\''); 00158 stream->nextPut(_value); 00159 stream->nextPutAll("\' /* "); 00160 stream->nextPutAll(String::format("0x%02X", _value)); 00161 stream->nextPutAll(" */"); 00162 }
|
|
Definition at line 65 of file Character.cc. References value(). Referenced by Core::String::asArrayOfSubstrings(), Core::ByteCharacterEncoder::parseLine(), and Core::Stream::space(). 00066 { 00067 return value(32); 00068 }
|
|
Definition at line 70 of file Character.cc. References value(). Referenced by Core::ByteCharacterEncoder::parseLine(), and Core::Stream::tab(). 00071 { 00072 return value('\t'); 00073 }
|
|
Definition at line 81 of file Character.cc. References Core::Number::asUnsignedLong(), Character(), characterStore(), and Core::Association::value(). 00082 { 00083 /* Can't use Dictionary>>#at:ifAbsent: method 'cause it raises exception 00084 that may need to construct more Characters. */ 00085 Character *chr; 00086 int index = characterStore()->findKeyOrNil(val); 00087 if (characterStore()->isEmptyAt(index)) { 00088 /* Need to construct new one */ 00089 chr = new Character(val->asUnsignedLong()); 00090 characterStore()->atNewIndexPut(index, new Association(val, chr)); 00091 } else { 00092 /* OK now. Sure it's there. */ 00093 Association *assoc = dynamic_cast<Association *>(characterStore()->privAtIndex(index)); 00094 chr = dynamic_cast<Character *>(assoc->value()); 00095 } 00096 return chr; 00097 }
|
|
|
Reimplemented from Core::Object. Definition at line 198 of file Character.cc. References Core::Visitor::visitCharacter(). 00199 { 00200 visitor->visitCharacter(this); 00201 }
|
|
Definition at line 41 of file Character.h. Referenced by asInteger(), asLowercase(), asUppercase(), byteSize(), Character(), hash(), isDigit(), isEqual(), isLowercase(), isSeparator(), isUppercase(), isVowel(), and printOn(). |
|
Definition at line 34 of file Character.cc. Referenced by characterStore(). |