#include <String.h>
Inheritance diagram for Core::String:
Public Member Functions | |
String (long size=0) | |
Creates new empty string with specified size. | |
String (const char *str) | |
Creates new string from C-string. | |
String (const ByteArray *byteArray) | |
virtual | ~String (void) |
String (const String &origin) | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual Object * | at (int index) const |
virtual void | put (int index, Object *obj) |
virtual void | put (int index, char obj) |
virtual long | size (void) const |
Answer how many elements the collection includes. | |
virtual long | indexOf (Object *obj) const |
Finds first index of element in a collection. | |
virtual long | indexOf (const char obj) const |
virtual long | lastIndexOf (Object *obj) const |
Finds last index of element in a collection. | |
virtual long | lastIndexOf (const char obj) const |
virtual long | nextIndexOf (Object *element, long startIndex, long stopIndex) const |
virtual long | nextIndexOf (const char element, long startIndex, long stopIndex) const |
virtual long | prevIndexOf (Object *element, long startIndex, long stopIndex) const |
virtual long | prevIndexOf (const char element, long startIndex, long stopIndex) const |
virtual void | add (Object *obj) |
virtual void | changeSize (long newSize) |
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 (const char *string) const |
virtual bool | match (String *string) |
Answer whether a String matches the pattern in the receiver. | |
virtual bool | match (const char *string) |
virtual bool | match (String *string, bool ignoreCase) |
virtual bool | match (const char *string, bool ignoreCase) |
virtual bool | matchesPattern (String *string, bool ignoreCase) |
virtual char * | asCString (void) const |
Returns C-string, ie. | |
virtual | operator char * (void) const |
virtual Array * | asArrayOfSubstrings (void) |
Answer Array of substrings separated by one or more spaces. | |
virtual Array * | asArrayOfSubstringsSeparatedBy (Character *ch) |
Answers Array of substrings separated by one or more occurences of given character. | |
virtual Array * | asArrayOfSubstringsSeparatedBy (const char ch) |
virtual ByteArray * | asByteArray (void) const |
virtual ByteArray * | asByteArrayEncoding (String *encoding) const |
virtual ByteArray * | asByteArrayEncoding (const char *encoding) const |
virtual String * | asLowercase (void) |
virtual Number * | asNumber (void) |
virtual Number * | asNumberRadix (int radix) |
virtual String * | asUppercase (void) |
virtual String * | asUppercaseFirst (void) |
virtual String * | asString (void) |
virtual Object * | copy (void) |
virtual Object * | copy (long from, long to) |
Returns a new collection with the same items as the specified portion of this collection. | |
virtual Object * | copyEmpty (long size) |
virtual SequenceableCollection & | operator+ (SequenceableCollection &collection) |
virtual String & | operator+ (const char *string) |
virtual String * | concatenateWith (String *string) |
virtual String * | concatenateWith (const char *string) |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual bool | includes (Object *object) |
virtual bool | includes (const char element) |
virtual bool | includesSubcollection (SequenceableCollection *coll) const |
virtual bool | includesSubcollection (const char *coll) const |
virtual bool | isString (void) const |
Answer if the receiver is a String. | |
virtual bool | isByteString (void) const |
virtual bool | isTwoByteString (void) const |
virtual bool | isCharacterArray (void) const |
virtual bool | isDigitString (void) |
Answers if the string contains only decimal digits. | |
virtual bool | startsWith (SequenceableCollection *coll) const |
virtual bool | startsWith (const char *str) const |
virtual bool | endsWith (SequenceableCollection *coll) const |
virtual bool | endsWith (const char *str) const |
virtual String * | trimBlanks (void) |
virtual String * | demangleMethodName (void) |
virtual void | visitBy (Visitor *visitor) |
Static Public Member Functions | |
static String * | format (const String *format,...) |
Creates new String instace from formatted string. | |
static String * | format (const char *format,...) |
Same as format(const String* format, . | |
static String * | with (Character *object) |
static String * | with (Character *obj1, Character *obj2) |
static String * | with (Character *obj1, Character *obj2, Character *obj3) |
static String * | with (Character *obj1, Character *obj2, Character *obj3, Character *obj4) |
static String * | withAll (Collection *coll) |
Protected Member Functions | |
virtual void | changeWideToFit (int width) |
Static Protected Member Functions | |
static String * | formatArgumentsIntoString (const char *format, va_list args) |
Protected Attributes | |
StringImpl * | implementor |
The characters themself are held by one of StringImpl subclasses.
Although could use different character sizes, it uses just ByteString implementor for now. So all strings are held in encoding depending on machine setup.
Definition at line 47 of file String.h.
|
Creates new empty string with specified size.
Definition at line 44 of file String.cc. References implementor. Referenced by add(), asByteArrayEncoding(), className(), concatenateWith(), copy(), copyEmpty(), demangleMethodName(), endsWith(), includesSubcollection(), match(), put(), startsWith(), String(), trimBlanks(), with(), and withAll(). 00045 { 00046 if (size < 0) { 00047 fprintf(stderr, "Warning: Constructing String with negative size. Creating empty.\n"); 00048 size = 0; 00049 } 00050 implementor = new ByteString(size); 00051 }
|
|
Creates new string from C-string.
Definition at line 53 of file String.cc. References implementor, Core::StringImpl::put(), String(), and Core::Character::value(). 00054 { 00055 if (str == NULL) { 00056 fprintf(stderr, "Warning: Constructing String from NULL argument. Creating empty.\n"); 00057 implementor = new ByteString(0); 00058 } else { 00059 int length = strlen(str); 00060 implementor = new ByteString(length); 00061 for (int i = 0; i < length; i++) { 00062 if (str[i] < 0) { 00063 (new Error(new String("Illegal character. 7-bit only accepted."), 00064 new String(__PRETTY_FUNCTION__)))->raise(); 00065 } 00066 implementor->put(i, Character::value((unsigned char) str[i])); 00067 } 00068 } 00069 }
|
|
Definition at line 71 of file String.cc. References implementor, Core::StringImpl::put(), and Core::Character::value(). 00072 { 00073 long length = byteArray->size(); 00074 const unsigned char *ba = byteArray->rawBytesReadOnly(); 00075 implementor = new ByteString(length); 00076 for (long i = 0; i < length; i++) { 00077 implementor->put(i, Character::value(ba[i])); 00078 } 00079 }
|
|
Definition at line 81 of file String.cc. References implementor. 00082 { 00083 delete implementor; 00084 }
|
|
Definition at line 87 of file String.cc. References at(), implementor, put(), and size(). 00088 { 00089 long tally = origin.size(); 00090 implementor = new ByteString(tally); 00091 for (long i = 0; i < tally; i++) { 00092 put(i, dynamic_cast<Character *>(origin.at(i))); 00093 } 00094 }
|
|
Reimplemented from Core::Collection. Definition at line 206 of file String.cc. References Core::Object::shouldNotImplement(), and String(). 00207 { 00208 shouldNotImplement(new String(__PRETTY_FUNCTION__)); 00209 }
|
|
Answer Array of substrings separated by one or more spaces.
Definition at line 381 of file String.cc. References asArrayOfSubstringsSeparatedBy(), and Core::Character::space(). 00382 { 00383 return asArrayOfSubstringsSeparatedBy(Character::space()); 00384 }
|
|
Definition at line 408 of file String.cc. References asArrayOfSubstringsSeparatedBy(), and Core::Character::value(). 00409 { 00410 return asArrayOfSubstringsSeparatedBy(Character::value(ch)); 00411 }
|
|
Answers Array of substrings separated by one or more occurences of given character.
Definition at line 386 of file String.cc. References Core::OrderedCollection::add(), Core::SequenceableCollection::asArray(), at(), copy(), and size(). Referenced by asArrayOfSubstrings(), asArrayOfSubstringsSeparatedBy(), and Net::IPSocketAddress::stringToBytes(). 00387 { 00388 OrderedCollection *answer = new OrderedCollection; 00389 long startIndex = 0, stopIndex; 00390 long length = size(); 00391 00392 while (startIndex < length) { 00393 while (startIndex < length && at(startIndex) == ch) { 00394 startIndex++; 00395 } 00396 stopIndex = startIndex; 00397 while (stopIndex < length && at(stopIndex) != ch) { 00398 stopIndex++; 00399 } 00400 if (stopIndex > startIndex) { 00401 answer->add(copy(startIndex, stopIndex)); 00402 startIndex = stopIndex; 00403 } 00404 } 00405 return answer->asArray(); 00406 }
|
|
Definition at line 413 of file String.cc. References asByteArrayEncoding(). 00414 { 00415 return asByteArrayEncoding("default"); 00416 }
|
|
Definition at line 423 of file String.cc. References asByteArrayEncoding(), and String(). 00424 { 00425 return asByteArrayEncoding(new String(encoding)); 00426 }
|
|
Definition at line 418 of file String.cc. References Core::ByteArray::fromStringEncoding(). Referenced by asByteArray(), and asByteArrayEncoding(). 00419 { 00420 return ByteArray::fromStringEncoding(this, encoding); 00421 }
|
|
|
Definition at line 428 of file String.cc. References at(), copyEmpty(), put(), and size(). Referenced by asUppercaseFirst(), and Core::EncodedStreamFactory::EncodedStreamFactory(). 00429 { 00430 long length = size(); 00431 String *newString = (String *) copyEmpty(length); 00432 for (long i = 0; i < length; i++) { 00433 newString->put(i, ((Character *) at(i))->asLowercase()); 00434 } 00435 return newString; 00436 }
|
|
Definition at line 438 of file String.cc. References Core::Number::fromString(). Referenced by demangleMethodName(), and Net::URL::parseHost(). 00439 { 00440 return Number::fromString(this); 00441 }
|
|
Definition at line 443 of file String.cc. References Core::Number::fromStringRadix(). 00444 { 00445 return Number::fromStringRadix(this, radix); 00446 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 470 of file String.cc. 00471 { 00472 return this; 00473 }
|
|
Definition at line 448 of file String.cc. References at(), copyEmpty(), put(), and size(). Referenced by asUppercaseFirst(). 00449 { 00450 long length = size(); 00451 String *newString = (String *) copyEmpty(length); 00452 for (long i = 0; i < length; i++) { 00453 newString->put(i, ((Character *) at(i))->asUppercase()); 00454 } 00455 return newString; 00456 }
|
|
Definition at line 458 of file String.cc. References asLowercase(), asUppercase(), at(), copyEmpty(), put(), and size(). 00459 { 00460 long length = size(); 00461 if (length <= 0) return this; 00462 String *newString = (String *) copyEmpty(length); 00463 newString->put(0, ((Character *) at(0))->asUppercase()); 00464 for (long i = 1; i < length; i++) { 00465 newString->put(i, ((Character *) at(i))->asLowercase()); 00466 } 00467 return newString; 00468 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 148 of file String.cc. References Core::StringImpl::at(), implementor, and size(). Referenced by asArrayOfSubstringsSeparatedBy(), asCString(), asLowercase(), asUppercase(), asUppercaseFirst(), demangleMethodName(), hash(), Core::ByteCharacterEncoder::integerValueFrom(), isDigitString(), isEqual(), matchesPattern(), Core::EncodedStreamFactory::normalizedEncoding(), and String(). 00149 { 00150 if (index < 0 || index >= size()) 00151 (new SubscriptOutOfBoundsError(__PRETTY_FUNCTION__, index))->raiseFrom(this); 00152 return implementor->at(index); 00153 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 211 of file String.cc. References Core::StringImpl::changeSize(), and implementor. 00212 { 00213 if (newSize < 0) { 00214 fprintf(stderr, "Warning: Changing size of String to negative. Making zero instead.\n"); 00215 newSize = 0; 00216 } 00217 implementor->changeSize(newSize); 00218 }
|
|
Definition at line 631 of file String.cc. References Core::StringImpl::asByteString(), Core::StringImpl::asCharacterArray(), Core::StringImpl::asTwoByteString(), and implementor. Referenced by put(). 00632 { 00633 switch (width) { 00634 case 1 : 00635 implementor = implementor->asByteString(); 00636 break; 00637 case 2 : 00638 implementor = implementor->asTwoByteString(); 00639 break; 00640 case 4 : 00641 implementor = implementor->asCharacterArray(); 00642 break; 00643 } 00644 }
|
|
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::Collection. Definition at line 97 of file String.cc. References String(). 00098 { 00099 return new String("String"); 00100 }
|
|
Definition at line 501 of file String.cc. References concatenateWith(), and String(). 00502 { 00503 return concatenateWith(new String(string)); 00504 }
|
|
Definition at line 496 of file String.cc. References Core::SequenceableCollection::copyReplace(), and size(). Referenced by concatenateWith(), and operator+(). 00497 { 00498 return (String *) copyReplace(size(), size(), string); 00499 }
|
|
Returns a new collection with the same items as the specified portion of this collection.
Reimplemented from Core::SequenceableCollection. Definition at line 171 of file String.h. References Core::SequenceableCollection::copy(). 00172 { return SequenceableCollection::copy(from, to); }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 476 of file String.cc. References String(). Referenced by asArrayOfSubstringsSeparatedBy(), Tools::Filename::constructString(), demangleMethodName(), Tools::Filename::extension(), Net::URL::fromString(), Tools::HierarchicalConfigurationReader::getConfigurationFor(), Tools::HierarchicalConfigurationReader::parseAssignment(), Tools::HierarchicalConfigurationReader::parseLine(), Core::GenericException::printStackOn(), Tools::HierarchicalConfigurationReader::readLine(), Tools::ConfigurationReader::readLine(), Tools::Filename::tail(), and trimBlanks(). 00477 { 00478 return new String(*this); 00479 }
|
|
Reimplemented from Core::Collection. Definition at line 481 of file String.cc. References String(). Referenced by asLowercase(), asUppercase(), and asUppercaseFirst().
|
|
Definition at line 576 of file String.cc. References asNumber(), at(), Core::Stream::contents(), copy(), Core::Stream::nextPutAll(), size(), String(), and Core::Character::value(). Referenced by Core::GenericException::printStackOn(). 00577 { 00578 #if __GNUC_PREREQ(3,0) 00579 Stream *stream = (new String(size()))->writeStream(); 00580 long segmentLength = 3, segmentStart = 0; 00581 String *buffer = this; 00582 String *segment; 00583 00584 /* Skip prefix */ 00585 while (!dynamic_cast<Character *>(buffer->at(segmentStart + segmentLength))->isDigit()) { 00586 segmentLength++; 00587 } 00588 00589 while (dynamic_cast<Character *>(buffer->at(segmentStart + segmentLength))->isDigit()) { 00590 if (buffer != this) stream->nextPutAll("::"); 00591 buffer = dynamic_cast<String *>(buffer->copy(segmentLength + segmentStart, buffer->size())); 00592 segmentStart = 0; 00593 segmentLength = buffer->asNumber()->asLong(); 00594 while (dynamic_cast<Character *>(buffer->at(segmentStart))->isDigit()) 00595 segmentStart++; 00596 segment = dynamic_cast<String *>(buffer->copy(segmentStart, segmentStart + segmentLength)); 00597 stream->nextPutAll(segment); 00598 if (buffer->at(segmentStart + segmentLength)->isEqual(Character::value('D'))) { 00599 stream->nextPutAll("::~"); 00600 stream->nextPutAll(segment); 00601 } 00602 } 00603 if (buffer == this) { 00604 /* Can't demangle */ 00605 return this; 00606 } 00607 stream->nextPutAll("()"); 00608 00609 return dynamic_cast<String *>(stream->contents()); 00610 #else 00611 /* Don't know how to demangle */ 00612 return this; 00613 #endif 00614 }
|
|
Definition at line 540 of file String.cc. References endsWith(), and String().
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 202 of file String.h. References Core::SequenceableCollection::endsWith(). Referenced by endsWith(). 00203 { return SequenceableCollection::endsWith(coll); }
|
|
Same as format(const String* format, . ..). Provide for convenience. Definition at line 353 of file String.cc. References formatArgumentsIntoString(). 00354 { 00355 String *result; 00356 va_list ap; 00357 00358 va_start(ap, format); 00359 result = formatArgumentsIntoString(format, ap); 00360 va_end(ap); 00361 00362 return result; 00363 }
|
|
Creates new String instace from formatted string.
Definition at line 365 of file String.cc. References asCString(), and formatArgumentsIntoString(). Referenced by Core::Stream::print(), Core::Time::printOn(), Core::Date::printOn(), and Core::Character::printOn(). 00366 { 00367 String *result; 00368 va_list ap; 00369 00370 va_start(ap, format); 00371 result = formatArgumentsIntoString(format->asCString(), ap); 00372 va_end(ap); 00373 return result; 00374 }
|
|
Definition at line 623 of file String.cc. Referenced by format(). 00624 { 00625 char buf[1025]; 00626 00627 vsnprintf(buf, 1024, format, args); 00628 return (new ByteArray(buf, strlen(buf)))->asString(); 00629 }
|
|
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 221 of file String.cc. 00222 { 00223 long hashConst = 0x12345; 00224 int length = size(); 00225 00226 if (length > 0) { 00227 hashConst ^= ((Character *) at(0))->asInteger(); 00228 if (length > 1) { 00229 hashConst ^= ((Character *) at(length-1))->asInteger(); 00230 if (length > 3) { 00231 hashConst ^= ((Character *) at(length/2-1))->asInteger() 00232 ^ ((Character *) at(length/2+1))->asInteger(); 00233 } 00234 } 00235 } 00236 return hashConst; 00237 }
|
|
Definition at line 515 of file String.cc. References includes(), and Core::Character::value(). 00516 { 00517 return includes(Character::value(element)); 00518 }
|
|
Reimplemented from Core::Collection. Definition at line 184 of file String.h. References Core::Collection::includes(). Referenced by includes(), Tools::Filename::privFilesMatchingAccessList(), and trimBlanks(). 00185 { return SequenceableCollection::includes(object); }
|
|
Definition at line 189 of file String.h. References Core::SequenceableCollection::includesSubcollection(), and String(). 00190 { return SequenceableCollection::includesSubcollection(new String(coll)); }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 187 of file String.h. References Core::SequenceableCollection::includesSubcollection(). Referenced by Net::URL::fromString(). 00188 { return SequenceableCollection::includesSubcollection(coll); }
|
|
Definition at line 183 of file String.cc. References Core::SequenceableCollection::indexOf(), and Core::Character::value(). 00184 { 00185 return SequenceableCollection::indexOf(Character::value(obj)); 00186 }
|
|
Finds first index of element in a collection. If none found returns -1. Reimplemented from Core::SequenceableCollection. Definition at line 100 of file String.h. References Core::SequenceableCollection::indexOf(). Referenced by Net::URL::fromString(), Tools::HierarchicalConfigurationReader::getConfigurationFor(), Tools::HierarchicalConfigurationReader::parseLine(), Core::GenericException::printStackOn(), Tools::HierarchicalConfigurationReader::readLine(), and Tools::ConfigurationReader::readLine(). 00101 { return SequenceableCollection::indexOf(obj); }
|
|
Definition at line 545 of file String.cc. References implementor, and Core::StringImpl::isByteString(). 00546 { 00547 return implementor->isByteString(); 00548 }
|
|
Definition at line 555 of file String.cc. References implementor, and Core::StringImpl::isCharacterArray(). 00556 { 00557 return implementor->isCharacterArray(); 00558 }
|
|
Answers if the string contains only decimal digits.
Definition at line 525 of file String.cc. 00526 { 00527 long length = size(); 00528 for (long i = 0; i < length; i++) { 00529 if (!((Character *) at(i))->isDigit()) 00530 return false; 00531 } 00532 return true; 00533 }
|
|
Definition at line 259 of file String.cc. References at(), isEqual(), and size(). 00260 { 00261 long i, length = size(); 00262 for (i = 0; i < length && string[i] != 0; i++) { 00263 if (!((Character *) at(i))->isEqual(string[i])) 00264 return false; 00265 } 00266 if (i < length || string[i] != 0) return false; 00267 return true; 00268 }
|
|
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 120 of file String.h. References Core::Object::isEqual(). 00121 { return SequenceableCollection::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 239 of file String.cc. References implementor, Core::StringImpl::isEqual(), Core::Object::isString(), and size(). Referenced by Core::EncodedStreamFactory::EncodedStreamFactory(), isEqual(), and Core::Object::isInstanceOf(). 00240 { 00241 /* long length = size(); 00242 if (object->isString() && 00243 length == ((String *) object)->size()) { 00244 String *charArray = (String *) object; 00245 for (long i = 0; i < length; i++) { 00246 if (!at(i)->isEqual(charArray->at(i))) 00247 return false; 00248 } 00249 return true; 00250 } 00251 return false; 00252 */ 00253 if (!object->isString()) return false; 00254 String *otherOne = (String *) object; 00255 if (otherOne->size() != this->size()) return false; 00256 return this->implementor->isEqual(otherOne->implementor); 00257 }
|
|
Answer if the receiver is a String.
Reimplemented from Core::Object. Definition at line 520 of file String.cc. 00521 { 00522 return true; 00523 }
|
|
Definition at line 550 of file String.cc. References implementor, and Core::StringImpl::isTwoByteString(). 00551 { 00552 return implementor->isTwoByteString(); 00553 }
|
|
Definition at line 188 of file String.cc. References Core::SequenceableCollection::lastIndexOf(), and Core::Character::value(). 00189 { 00190 return SequenceableCollection::lastIndexOf(Character::value(obj)); 00191 }
|
|
Finds last index of element in a collection. If none found returns -1. Reimplemented from Core::SequenceableCollection. Definition at line 103 of file String.h. References Core::SequenceableCollection::lastIndexOf(). Referenced by Tools::Filename::extension(), and Tools::HierarchicalConfigurationReader::parseAssignment(). 00104 { return SequenceableCollection::lastIndexOf(obj); }
|
|
Definition at line 285 of file String.cc. References String(). 00286 { 00287 return (new String(str))->matchesPattern(this, ignoreCase); 00288 }
|
|
Definition at line 280 of file String.cc. References matchesPattern(). 00281 { 00282 return str->matchesPattern(this, ignoreCase); 00283 }
|
|
Definition at line 275 of file String.cc. References match(), and String().
|
|
Answer whether a String matches the pattern in the receiver. Matching ignores upper/lower case differences. Where the receiver contains #, a String may contain any single character. Where the receiver contains *, a String may contain any sequence of characters. Examples: (new String("xyz"))->match(new String("Xyz")) == true (new String("x#z"))->match(new String("x@z")) == true (new String("x*z"))->match(new String("x whyNot? z")) == true (new String("*x"))->match(new String("xx")) == true Definition at line 270 of file String.cc. Referenced by match(), and Tools::Filename::privFilesMatchingAccessList(). 00271 { 00272 return match(str, true); 00273 }
|
|
Definition at line 290 of file String.cc. References Core::Character::asUppercase(), at(), Core::Character::isEqual(), and size(). Referenced by match(). 00291 { 00292 long stringSize, stringIndex, stringStartScan; 00293 long patternSize, patternIndex, patternStartScan; 00294 00295 stringSize = size(); 00296 stringIndex = 0; 00297 patternSize = pattern->size(); 00298 patternIndex = 0; 00299 stringStartScan = -1; 00300 patternStartScan = 0; 00301 00302 while (patternIndex < patternSize) { 00303 Character *p = (Character *) pattern->at(patternIndex); 00304 patternIndex++; 00305 if (p->isEqual('*')) { 00306 /* We found a successful match after the last *, if any. */ 00307 if (patternIndex >= patternSize) 00308 return true; 00309 stringStartScan = stringIndex; 00310 patternStartScan = patternIndex; 00311 } else { 00312 if (stringIndex >= stringSize) 00313 return false; 00314 Character *t = (Character *) at(stringIndex); 00315 stringIndex++; 00316 if (t->isEqual(p) || p->isEqual('#') || 00317 (ignoreCase && t->asUppercase()->isEqual(p->asUppercase()))) { 00318 if (patternIndex >= patternSize && stringIndex < stringSize) { 00319 if (stringStartScan < 0) 00320 return false; 00321 stringIndex = stringIndex + patternStartScan - patternIndex + 1; 00322 patternIndex = patternStartScan; 00323 } 00324 } else { 00325 if (stringStartScan < 0) 00326 return false; 00327 stringIndex = stringIndex + patternStartScan - patternIndex + 1; 00328 patternIndex = patternStartScan; 00329 } 00330 } 00331 } 00332 00333 if (stringIndex < stringSize) 00334 return false; 00335 return true; 00336 }
|
|
Definition at line 193 of file String.cc. References Core::SequenceableCollection::nextIndexOf(), and Core::Character::value(). 00194 { 00195 return SequenceableCollection::nextIndexOf(Character::value(element), 00196 startIndex, stopIndex); 00197 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 106 of file String.h. References Core::SequenceableCollection::nextIndexOf(). Referenced by Core::GenericException::printStackOn(). 00107 { return SequenceableCollection::nextIndexOf(element, startIndex, stopIndex); }
|
|
Definition at line 376 of file String.cc. References asCString(). 00377 { 00378 return asCString(); 00379 }
|
|
Definition at line 491 of file String.cc. References concatenateWith(). 00492 { 00493 return *concatenateWith(string); 00494 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 486 of file String.cc. References Core::SequenceableCollection::copyReplace(), and size(). 00487 { 00488 return *copyReplace(size(), size(), &collection); 00489 }
|
|
Definition at line 199 of file String.cc. References Core::SequenceableCollection::prevIndexOf(), and Core::Character::value(). 00200 { 00201 return SequenceableCollection::prevIndexOf(Character::value(element), 00202 startIndex, stopIndex); 00203 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 109 of file String.h. References Core::SequenceableCollection::prevIndexOf(). 00110 { return SequenceableCollection::prevIndexOf(element, startIndex, stopIndex); }
|
|
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::Collection. Definition at line 507 of file String.cc. References Core::Stream::nextPut(), and Core::Stream::nextPutAll(). 00508 { 00509 stream->nextPut('\"'); 00510 stream->nextPutAll(this); 00511 stream->nextPut('\"'); 00512 }
|
|
Definition at line 173 of file String.cc. References put(), and Core::Character::value(). 00174 { 00175 put(index, Character::value(obj)); 00176 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 155 of file String.cc. References Core::StringImpl::byteSize(), Core::Character::byteSize(), changeWideToFit(), Core::Object::error(), implementor, Core::Object::isCharacter(), nil, Core::StringImpl::put(), size(), and String(). Referenced by asLowercase(), asUppercase(), asUppercaseFirst(), put(), String(), with(), and withAll(). 00156 { 00157 if (obj == nil || !obj->isCharacter()) { 00158 error(new String("String stores only Characters."), 00159 new String(__PRETTY_FUNCTION__), obj); 00160 } 00161 if (index < 0 || index >= size()) 00162 (new SubscriptOutOfBoundsError(__PRETTY_FUNCTION__, index))->raiseFrom(this); 00163 00164 Character *chr = dynamic_cast<Character *>(obj); 00165 00166 if (chr->byteSize() > implementor->byteSize()) { 00167 changeWideToFit(chr->byteSize()); 00168 } 00169 00170 implementor->put(index, chr); 00171 }
|
|
Answer how many elements the collection includes.
Reimplemented from Core::SequenceableCollection. Definition at line 178 of file String.cc. References implementor, and Core::StringImpl::size(). Referenced by asArrayOfSubstringsSeparatedBy(), asCString(), asLowercase(), asUppercase(), asUppercaseFirst(), at(), concatenateWith(), Tools::Filename::constructString(), demangleMethodName(), Tools::Filename::extension(), Net::URL::fromString(), Core::ByteArray::fromStringEncoding(), Tools::HierarchicalConfigurationReader::getConfigurationFor(), hash(), isDigitString(), isEqual(), matchesPattern(), operator+(), Tools::HierarchicalConfigurationReader::parseAssignment(), Net::URL::parseHost(), Core::GenericException::printStackOn(), put(), Tools::HierarchicalConfigurationReader::readLine(), Tools::ConfigurationReader::readLine(), String(), Tools::Filename::tail(), and trimBlanks(). 00179 { 00180 return implementor->size(); 00181 }
|
|
Definition at line 535 of file String.cc. References startsWith(), and String(). 00536 { 00537 return startsWith(new String(str)); 00538 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 199 of file String.h. References Core::SequenceableCollection::startsWith(). Referenced by Core::ByteCharacterEncoder::integerValueFrom(), and startsWith(). 00200 { return SequenceableCollection::startsWith(coll); }
|
|
Definition at line 561 of file String.cc. References copy(), includes(), size(), and String(). Referenced by Tools::HierarchicalConfigurationReader::parseAssignment(), Tools::HierarchicalConfigurationReader::parseLine(), and Tools::ConfigurationReader::readLine(). 00562 { 00563 String *separators = new String(" \t\n\r"); 00564 long index = 0, length = size(); 00565 00566 if (length == 0) return this; 00567 while (index < length && separators->includes(this->at(index))) 00568 index++; 00569 while (index < length && separators->includes(this->at(length-1))) 00570 length--; 00571 if (index == length) return new String; 00572 if (index == 0 && length == size()) return this; 00573 return dynamic_cast<String *>(copy(index, length)); 00574 }
|
|
Reimplemented from Core::Collection. Definition at line 617 of file String.cc. 00618 { 00619 visitor->visitString(this); 00620 }
|
|
Definition at line 127 of file String.cc. References put(), and String(). 00128 { 00129 String *newString = new String(4); 00130 newString->put(0, obj1); 00131 newString->put(1, obj2); 00132 newString->put(2, obj3); 00133 newString->put(3, obj4); 00134 return newString; 00135 }
|
|
Definition at line 118 of file String.cc. References put(), and String(). 00119 { 00120 String *newString = new String(3); 00121 newString->put(0, obj1); 00122 newString->put(1, obj2); 00123 newString->put(2, obj3); 00124 return newString; 00125 }
|
|
Definition at line 110 of file String.cc. References put(), and String(). 00111 { 00112 String *newString = new String(2); 00113 newString->put(0, obj1); 00114 newString->put(1, obj2); 00115 return newString; 00116 }
|
|
Definition at line 103 of file String.cc. References put(), and String(). 00104 { 00105 String *newString = new String(1); 00106 newString->put(0, object); 00107 return newString; 00108 }
|
|
Definition at line 137 of file String.cc. References put(), and String(). 00138 { 00139 String *newString = new String(coll->size()); 00140 int index = 0; 00141 for (Iterator *i = coll->iterator(); !i->finished(); i->next()) { 00142 newString->put(index++, i->value()); 00143 } 00144 return newString; 00145 }
|
|
Definition at line 50 of file String.h. Referenced by at(), changeSize(), changeWideToFit(), isByteString(), isCharacterArray(), isEqual(), isTwoByteString(), put(), size(), String(), and ~String(). |