New instances are usually created via str:, which initializes the object to a copy of the argument (a C string). Another factory method is the sprintf: method which supports the options of the C library function, sprintf().
It's possible to compare ObjStr instances using the methods compare: and dictCompare:. These methods return an integer which is less than, equal to, or greater than zero, if the receiver is less than, equal to, or greater than the argument object.
You can randomly access the characters in a string object using the charAt: and charAt:put: methods. The latter method replaces the character at the indicated offset by a new character, and returns the old value.
Finally, using such methods as toLower, toUpper etc., instances can do various conversions on their contents.
+ newCreates an instance whose value is set to the empty string.
+ str :(STR) strValueCreates an instance whose value is set to a copy of strValue. If strValue is NULL, creates an instance whose value is set to the empty string.
+ sprintf :(STR) format,...Returns a new instace initialized just as the standard C library sprintf(). See the documentation on sprintf() for the formats and variable declarations.
- copyReturns a copy of the receiver with its internal C string copied as well.
See also: - strCopy
- deepCopyFor this class, this method acts as copy.
- freeFrees the receiver and its internal C string as well.
- (int) compare : aStrCompares the receiver's string to another instance of this class (or its subclasses). Returns the comparison value.
- (int) compareSTR :(STR) strValueCompares the receiver's string to strValue. Returns the comparison value.
- (unsigned) hashReturns a hash value based upon the contents of the string held in the receiver.
- (int) dictCompare : aStrCompares the receiver's string to another instance of this class, or its subclasses, according to dictionary ordering, i.e., all characters other than letters and numbers are ignored and case is ignored. Returns the comparison value.
- (BOOL) isEqual : aStrReturns YES if the value contained by aStr is equal to the contents of the receiver.
- (BOOL) isEqualSTR :(STR) strValueReturns YES if the ordinary C string strValue is equal to the contents of the receiver.
- (unsigned) sizeReturns the number of actual characters in the string, excluding the NULL terminator.
- (char) charAt :(unsigned) anOffsetReturns the character at anOffset or zero if anOffset is greater than the length of the C string.
- (char) charAt :(unsigned) anOffset put :(char) aCharReplaces the character at anOffset with aChar and returns the old character which was in that location. Returns zero if anOffset is greater than the length of the C string.
- (STR) strcat :(STR) aBufferConcatenates the receiver's C string to aBuffer. No length checking is possible to ensure that aBuffer is large enough. Returns aBuffer.
- concatSTR :(STR) strValueConcatenates strValue, an ordinary C string, to the end of the receiver. Returns self.
- assignSTR :(STR) strValueCopies the C string strValue into the receiver's string. Returns the receiver.
- assignSTR :(STR) strValue length :(unsigned) nCharsCopies the C string strValue into the receiver's string, truncating at nChars. Returns the receiver.
- (double) asDoubleReturns the double value of the C string, using the standard C function atof().
- (int) asIntReturns the integer value of the C string, using the standard C function atoi().
- (long) asLongReturns the long value of the C string, using the standard C function atol().
- asSTR :(STR) aBuffer maxSize :(int) aSizeCopies the value of the object into aBuffer, truncating at aSize, and returns the receiver.
- (STR) strReturns a pointer to the NULL-terminated C string stored in the receiver.
- (STR) strCopyReturns a malloc()'ed copy of the NULL-terminated C string stored in the receiver. You are responsible for free()'ing the pointer.
- toLowerConverts the receiver string to lower case.
- toUpperConverts the receiver string to upper case.
- printToFile :(FILE *) aFilePrints the string to aFile without appending a newline. Returns the receiver.
- write :(NXTypedStream *) streamWrites the string to stream. Returns the receiver.
- read :(NXTypedStream *) streamReads a string object from stream. Returns the receiver.