ftp.nice.ch/pub/next/developer/resources/classes/MOKit.1.0.0.s.tar.gz#/MOKit_1.0.0/Documentation/Classes/MOString.rtf

This is MOString.rtf in view mode; [Download] [Up]

Version 1.0  Copyright ©1992, 1993, 1994 by Mike Ferris.  All Rights Reserved.
Mike Ferris  -  September 18th, 1993



MOString






Inherits From:	Object

Conforms To:	NXTransport

Declared In:	MOKit/MOString.h





Class Description

MOString provides a wrapper for a variable length character array.  It handles allocating and freeing the memory associated with the string and is great for filling List objects.

MOStrings in their simplest form are containers for regular C-style NULL-terminated strings.  The string can be set and queried.  A whole range of other operations and queries on the contents of a MOString are also supported.  Almost all of the standard ANSI string functions are supported with methods of the same name.  Operations for creating another MOString object containing a substring of the original are also supported as well as a sophisticated tokenizing feature based on the ANSI strtok() function.

MOStrings handle their own memory allocation and freeing by default, but they can be set not to free their contents is desired.  They can also be used to store NXAtoms or unique strings.  None of the methods that modify a MOString's contents are supported for unique strings.  If a MOString is set to be unique, the value it returns from the ± stringValue method can be cast to an NXAtom and used for the direct comparisons that NXAtoms support.

MOString is implemented in several categories.  This was done to break a humongous file into pieces, not to allow picking and choosing of features.  All the current categories of MOString must be present because they are interdependant.





Instance Variables

char 	*str;
NXAtom 	uStr;
size_t 	len;
BOOL	isUnique;
BOOL	shouldFree;



str 	A pointer to the string if it is not a unique string (or NULL if it is).

uStr	A pointer to the string if it is a unique string (or NULL if it is not).

len	The length of the string.

isUnique	Whether the string is unique.

shouldFree	Whether the MOString should free its contents' memory.





Method Types

Initializing the class	+ initialize

Creating and freeing instances	- init
- initStringValue:
- initStringValueNoCopy:
- initStringValueNoCopy: shouldFree:
- initStringValueUnique:
- initFromFormat: , ...
- copyFromZone:
- deepCopy
- deepCopyFromZone:
- shallowCopy
- shallowCopyFromZone:
- free

Configuring the string	- setStringValue:
- setStringValueNoCopy:
- setStringValueNoCopy: shouldFree:
- setStringValueUnique:
- setFromFormat: , ...

- setIntValue:
- setFloatValue:
- setDoubleValue:

- setNull
- makeUnique
- setShouldFree:

Querying the string	- stringValue
- intValue
- floatValue
- doubleValue
- getCopyInto:

- length
- count
- isNull
- isEmpty
- isUnique
- shouldFree

Parsing the string	- charAt:
(Parsing) Category	- substringFrom: to:
- positionOf: nthOccurrence:
- countOccurrencesOf:
- tokenize: into:

Modifying the string	- takeStringValueFrom:
(Modifying) Category	- takeIntValueFrom:
- takeFloatValueFrom:
- takeDoubleValueFrom:

- replaceAllOccurrencesOfChar: with:
- replaceCharAt: with:
- recalcLength

- cat:
- catStringValue:
- catFromFormat:, ...

- preCat:
- preCatStringValue:
- preCatFromFormat:, ...

- insert:at:
- insertStringValue:at:

- convertToLower
- convertToUpper

Comparing strings	- compare:
(Comparing) Category	- compare: caseSensitive:
- compare: caseSensitive: length:
- compare: caseSensitive: length: withTable:
- compareStr:
- compareStr: caseSensitive:
- compareStr: caseSensitive: length:
- compareStr: caseSensitive: length: withTable:

- endCompare:
- endCompare: caseSensitive:
- endCompare: caseSensitive: length:
- endCompare: caseSensitive: length: withTable:
- endCompareStr:
- endCompareStr: caseSensitive:
- endCompareStr: caseSensitive: length:
- endCompareStr: caseSensitive: length: withTable:

ANSI string library covers	- strlen
(ANSI) Category	- strcpy:
- strncpy: :
- strcat:
- strncat: :
- strcmp:
- strncmp: :
- strchr:
- strrchr:
- strstr:
- strpbrk:
- strspn:
- strcspn:
- sprintf: , ...

Archiving	- read:
- write:

NXTransport protocol	- encodeRemotelyFor: freeAfterEncoding: isByCopy:
- encodeUsing:
- decodeUsing:

Hashing	- hash
- isEqual:

Debugging aids	- buildInstanceImageIn:
(Debugging) Category	- printForDebugger:
- printToStdErr:






Class Methods

initialize
+ initialize

Sets the class version number.





Instance Methods

buildInstanceImageIn:
± buildInstanceImageIn:(char *)buf

Fills buf with a nice printable representation of the MOString's instance variables.  ± printForDebugger: and ±€printToStdErr: use this method to print complete representations of themselves.  The format used prints four lines each one indented by a single tab character.

See also:   ± printForDebugger, ± printToStdErr:




cat:
± cat:aString

Adds the contents of aString to the end of the receiving MOString.  This method will not work for unique strings.

See also:    ± catFromFormat:..., ± catStringValue:, ± preCat:, ± preCatFromFormat:..., ± preCatStringValue:, ± insert:at:, ± insertStringValue:at:, ± strcat:, ± strncat::




catFromFormat: ...
± catFromFormat:(const char *)formatString, ...

Does printf style expansion on formatString and the other arguments and adds the resulting string to the end of the MOString's contents.

See also:   ± cat:, ± catStringValue:, ± preCat:, ± preCatFromFormat:..., ± preCatStringValue:, ± insert:at:, ±€insertStringValue:at:, ± strcat:, ± strncat::




catStringValue:
± catStringValue:(const char *)s

Adds the c-string of s to the end of the receiving MOString.  This method will not work for unique strings.  This method is identical to ± strcat: and is provided merely for consistency with the other cat methods.

See also:    ± cat:, ± catFromFormat:..., ± preCat:, ± preCatFromFormat:..., ± preCatStringValue:, ± insert:at:, ± insertStringValue:at:, ± strcat:, ± strncat::




charAt:
± (char)charAt:(int)index

Returns the character at position index in the MOString's contents.  If index is out of range, this returns '\0'.  MOString contents are not supposed to contain NULL characters so this error code is valid.

See also:   ± positionOf:nthOccurrence:, ± replaceAllOccurrencesOfChar:with:, ± replaceCharAt:with:, ± substringFrom:to:, ANSI style methods




compare:
± (int)compare:aString

Identical to ± compare:aString caseSensitive:NO length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compare: caseSensitive:
± (int)compare:aString caseSensitive:(BOOL)flag

Identical to ± compare:aString caseSensitive:flag length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compare: caseSensitive: length:
± (int)compare:aString caseSensitive:(BOOL)flag length:(int)length

Identical to ± compare:aString caseSensitive:flag length:length withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compare: caseSensitive: length: withTable:
± (int)compare:aString caseSensitive:(BOOL)flag length:(int)length withTable:(NXStringOrderTable *)table

Uses NXOrderStrings() to compare the receiver with the given MOString object.  Returns -1, 0, or 1 depending on whether the receiver is less than, equal to, or greater than aString.  Returns -2 on error.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compareStr:
± (int)compareStr:(const char *)s

Identical to ± compareStr:s caseSensitive:NO length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compareStr: caseSensitive:
± (int)compareStr:(const char *)s caseSensitive:(BOOL)flag

Identical to ± compareStr:s caseSensitive:flag length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compareStr: caseSensitive: length:
± (int)compareStr:(const char *)s caseSensitive:(BOOL)flag length:(int)length

Identical to ± compareStr:s caseSensitive:flag length:length withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




compareStr: caseSensitive: length: withTable:
± (int)compareStr:(const char *)s caseSensitive:(BOOL)flag length:(int)length withTable:(NXStringOrderTable *)table

Uses NXOrderStrings() to compare the receiver with the given string.  Returns -1, 0, or 1 depending on whether the receiver is less than, equal to, or greater than s.  Returns -2 on error.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




convertToLower
± convertToLower

Converts the contents of the receiver to lower case.  Non-alphabetic characters are not affected, but it correctly deals with fancy extended ascii characters.  This method will not work for unique strings.

See also:   ± convertToUpper




convertToUpper
± convertToUpper

Converts the contents of the receiver to upper case.  Non-alphabetic characters are not affected, but it correctly deals with fancy extended ascii characters.  This method will not work for unique strings.

See also:   ± convertToUpper




copyFromZone:
± copyFromZone:(NXZone *)zone

Returns a new MOString object that is a duplicate of the receiver.  The contents is also copied if the original MOString's shouldFree flag is YES.  If the original MOString should not free then no copy of the contents is made.  This behavior is what I consider the desired behavior in most circumstances.  If you want to make sure that the MOString's contents are copied, use the ± deepCopy or ± deepCopyFromZone: methods.  If you want to make sure that the MOString's contents are NOT copied use the ± shallowCopy or ± shallowCopyFromZone: methods.

See also:   ± init..., ± free, ± shouldFree, ± setShouldFree:, ± deepCopy, ± deepCopyFromZone:, ± shallowCopy, ± shallowCopyFromZone:




count	(List/Storage conceptual continuity)
± (unsigned)count

Returns the number of characters in the MOString's contents excluding the trailing '\0'.  Returns the length as an unsigned instead of a size_t which is unsigned long.  The method is provided mainly because the appkit has a lot of ±€count methods.  The ± length method is the preferred way of obtaining this information and the ± strlen method is provided also for similar reasons.

See also:   ± length, ± strlen




countOccurrencesOf:
± (int)countOccurrencesOf:(char)aChar

Returns the number of times aChar appears in the string.

See also:   ± charAt:, ± positionOf:nthOccurrence:, ± replaceAllOccurrencesOfChar:with:, ± replaceCharAt:with:, ± substringFrom:to:, ANSI style methods




decodeUsing:	(NXTransport conformance)
± decodeUsing:(id <NXDecoding>)portal

This method is part of the NXTransport protocol.  Decodes an instance of MOString from the portal onto which it was previously encoded using ± encodeUsing:.  The portal supports the NXDecoding protocol, and it's a good thing because without it decoding the object might be difficult.

See also:   ± encodeUsing:, ± encodeRemotelyFor:freeAfterEncoding:isByCopy:




deepCopy
± deepCopy

Returns a new MOString object that is a duplicate of the receiver.  The contents of the origianl MOString is always copied.  The shouldFree flag of the new object is always YES.  The new string is never unique.  The ± copy and ±€copyFromZone: methods try to do the right thing as far as deciding whether to make a deep or shallow copy.  You should usually use those methods instead.

See also:   ± init..., ± free, ± shouldFree, ± setShouldFree:, ± copyFromZone:, ± deepCopyFromZone:, ±€shallowCopy, ± shallowCopyFromZone:




deepCopyFromZone:
± deepCopyFromZone:(NXZone *)zone

Returns a new MOString object that is a duplicate of the receiver allocated from zone.  The contents of the origianl MOString is always copied.  The shouldFree flag of the new object is always YES.  The new string is never unique.  The ± copy and ± copyFromZone: methods try to do the right thing as far as deciding whether to make a deep or shallow copy.  You should usually use those methods instead.

See also:   ± init..., ± free, ± shouldFree, ± setShouldFree:, ± copyFromZone:, ± deepCopy, ± shallowCopy, ±€shallowCopyFromZone:




doubleValue	(Cell conceptual continuity)
± (double)doubleValue

Returns the MOString's contents converted to a double-precision floating point number via the ANSI conversion function atof().  The string should probably resemble a floating point number for this to be useful.

See also:   ± intValue, ± floatValue, ± setIntValue, ± setFloatValue, ± setDoubleValue




encodeRemotelyFor: freeAfterEncoding: isByCopy:	(NXTransport conformance)
± encodeRemotelyFor:(NXConnection *)connection freeAfterEncoding:(BOOL *)flag isByCopy:(BOOL)isByCopy

This method is part of the NXTransport protocol.  It is supposed to return the object (which must conform to the NXTransport protocol) to encode over the connection.  Since the MOString class supports this protocol, it can return self if the isByCopy argument is YES.  This means that the MOString can send itself over a distributed object connection as a real MOString instead of a proxy object and become local to the other end.  This happens if a MOString argument to a distributed object message is designated bycopy.

See also:   ± encodeUsing:, ± decodeUsing:




encodeUsing:	(NXTransport conformance)
± encodeUsing:(id <NXEncoding>)portal

This method is part of the NXTransport protocol.  Encodes an instance of MOString onto the portal from which it is presumed that it will be decoded on the other side of the portal.  The portal supports the NXEncoding protocol, and it's a good thing because without it encoding the object might be difficult.

See also:   ± decodeUsing:, ± encodeRemotelyFor:freeAfterEncoding:isByCopy:




endCompare:
± (int)endCompare:aString

Identical to ± endCompare:aString caseSensitive:NO length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompare: caseSensitive:
± (int)endCompare:aString caseSensitive:(BOOL)flag

Identical to ± endCompare:aString caseSensitive:flag length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompare: caseSensitive: length:
± (int)endCompare:aString caseSensitive:(BOOL)flag length:(int)length

Identical to ± endCompare:aString caseSensitive:flag length:length withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompare: caseSensitive: length: withTable:
± (int)endCompare:aString caseSensitive:(BOOL)flag length:(int)length withTable:(NXStringOrderTable *)table

Uses NXOrderStrings() to compare the receiver with the given MOString object.  Both MOStrings' contents must be non-null and non-empty.  The last length characters of aString are compared to the last length characters of the receiving string's contents (str).  If length is -1, then aString must be no longer than str and the strlen of aString is used for the length.  Returns -1, 0, or 1 depending on whether the receiver is less than, equal to, or greater than aString.  Returns -2 on error.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompareStr:
± (int)endCompareStr:(const char *)s

Identical to ± endCompareStr:s caseSensitive:NO length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompareStr: caseSensitive:
± (int)endCompareStr:(const char *)s caseSensitive:(BOOL)flag

Identical to ± endCompareStr:s caseSensitive:flag length:-1 withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompareStr: caseSensitive: length:
± (int)endCompareStr:(const char *)s caseSensitive:(BOOL)flag length:(int)length

Identical to ± endCompareStr:s caseSensitive:flag length:length withTable:NULL.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




endCompareStr: caseSensitive: length: withTable:
± (int)endCompareStr:(const char *)s caseSensitive:(BOOL)flag length:(int)length withTable:(NXStringOrderTable *)table

Uses NXOrderStrings() to compare the receiver with the given string s.  Both s and the MOString's contents must be non-null and non-empty.  The last length characters of s are compared to the last length characters of the receiving string's contents (str).  If length is -1, then s must be no longer than str and the strlen of s is used for the length.  Returns -1, 0, or 1 depending on whether the receiver is less than, equal to, or greater than s.  Returns -2 on error.

See also:   ± compare..., ± compareStr..., ± endCompare..., ± endCompareStr..., ± strcmp:, ± strncmp:




floatValue	(Cell conceptual continuity)
± (float)floatValue

Returns the MOString's contents converted to a floating point number via the ANSI conversion function atof().  The string should probably resemble a floating point number for this to be useful.

See also:   ± intValue, ± doubleValue, ± setIntValue, ± setFloatValue, ± setDoubleValue




free
± free

Frees the string including the memory used to hold its contents if ± shouldFree is YES.

See also:   ± shouldFree, ± setShouldFree:, ± init...




getCopyInto:
± (char *)getCopyInto:(char *)buf

Copies the MOString's contents into buf.  If  buf is NULL, memory is allocated.  Returns the supplied buf or a pointer to the newly allocated memory as the case may be.

See also:   ± stringVlaue




hash
± (unsigned int)hash

Returns a hash of the MOString's contents.  Uses the NXStrHash() function to do the hash.

See also:   ± isEqual:




init
± init

Overrides Objects init method to initialize the string to the NULL string.

See also:   ± init..., ± free




initFromFormat: , ...
± initFromFormat:(const char *)formatStr, ...

Treats the formatStr and following arguments as printf() style arguments to initialize the string.  Memory is allocated for the contents and the MOString assumes responsibility for the memory.

See also:   ± init..., ± free




initStringValue:
± initStringValue:(const char *)s

Initializes the string to a copy of s.  The MOString will free this copy when it no longer needs it.

See also:   ± init..., ± free




initStringValueNoCopy:
± initStringValueNoCopy:(char *)s

Initializes the string to s.  No copy is made and the MOString does not assume responsibility for the memory.

See also:   ± init..., ± free




initStringValueNoCopy: shouldFree:
± initStringValueNoCopy:(char *)s shouldFree:(BOOL)flag

This is the designated initializer for the class.  Initializes our string to s.  No copy is made.  If flag is YES then the MOString assumes responsibility for the memory and will free it when it is no longer needed.  If flag is NO then the MOString does NOT assume responsibility for the memory.

See also:   ± init..., ± free




initStringValueUnique:
± initStringValueUnique:(const char *)s

Initializes the string to s.  The given string is first passed to NXUniqueString().  Then it is stored as a unique string.  MOString will not allow unique strings to be modified.  MOString never frees unique strings.

See also:   ± init..., ± free




insert:at:
± insert:aString at:(int)position

Inserts the contents of aString into the receiving MOString so the first character of aString is at position.  This method will not work for unique strings.

See also:    ± cat:, ± catFromFormat:..., ± catStringValue:, ± preCat:, ± preCatFromFormat:..., ±€preCatStringValue:, ± insertStringValue:at:, ± strcat:, ± strncat::




insertStringValue:at:
± insertStringValue:(const char *)s at:(int)position

Inserts the c-string of s into the receiving MOString so the first character of s is at position.  This method will not work for unique strings.

See also:    ± cat:, ± catFromFormat:..., ± catStringValue:, ± preCat:, ± preCatFromFormat:..., ±€preCatStringValue:, ± insert:at:, ± strcat:, ± strncat::




intValue	(Cell conceptual continuity)
± (int)intValue

Returns the MOString's contents converted to an integral number via the ANSI conversion function atoi().  The string should probably resemble an integer for this to be useful.

See also:   ± doubleValue, ± floatValue, ± setIntValue, ± setFloatValue, ± setDoubleValue




isEmpty
± (BOOL)isEmpty

Returns YES if the MOString is empty (len == 0).

See also:   ± isNull, ± setNull




isEqual:
±(BOOL)isEqual:anObject

Returns YES if anObject is identical to the receiver or if their contents are equal by the NXStrIsEqual() function.  The NXStrIsEqual() function is used because I assume NXStrHash() returns the same hash for any two strings that cause NXStrIsEqual() to return YES.  I only assume this because they are described in the same breath in the appkit docs. 

See also:   ± hash




isNull
± (BOOL)isNull

Returns YES if the MOString is null.  Note that this will return NO if the MOString's contents is the empty string.  Use ±€isEmpty for this type of test.

See also:   ± setNull, ± isEmpty




isUnique
± (BOOL)isUnique

Returns YES if the MOString's constents have been run through NXUniqueString() by the MOString object through the ±€makeUnique, ± setStringValueUnique:, or ± initStringValueUnique: methods.  This still might return NO if the contents are unique but the MOString does not know it.  A unique MOString may not be modified unless it is reset to completely new contents and it will never try to free its content's memory.

See also:   ± makeUnique, ± setStringValueUnique:, ± initStringValueUnique:




length
± (size_t)length

Returns the length in characters of the MOString's contents excluding the trailing '\0'.  This is the preferred method of getting the length of a MOString.  The other two methods which behave identically are for conceptual continuity with the universe outside (or is that the universe next door?).

See also:   ± count, ± strlen




makeUnique
± makeUnique

Makes the MOString's contents unique by running it through NXUniqueString().  The original contents are then freed if they should be and the MOString is marked as unique and told not to free the new unique'd contents.

See also:   ± isUnique, ± setStringValueUnique:, ± initStringValueUnique:




positionOf: nthOccurrence:
± (int)positionOf:(char)aChar nthOccurrence:(int)n

Returns the index of the nth occurrence of aChar in the MOString's contents.  Returns -1 if there is no nth occurrence.  If n is negative it finds the nth occurrence of aChar starting from the end of the string and working back.

See also:   ± charAt:, ± countOccurrencesOf:, ± replaceAllOccurrencesOfChar:with:, ± replaceCharAt:with:, ± substringFrom:to:, ANSI style methods




preCat:
± preCat:aString

Adds the contents of aString to the front of the receiving MOString.  This method will not work for unique strings.

See also:    ± cat:, ± catFromFormat:..., ± catStringValue:, ± preCatFromFormat:..., ± preCatStringValue:, ±€insert:at:, ± insertStringValue:at:, ± strcat:, ± strncat::




preCatFromFormat: ...
± preCatFromFormat:(const char *)formatString, ...

Does printf style expansion on formatString and the other arguments and adds the resulting string to the front of the MOString's contents.

See also:   ± cat:, ± catFromFormat:..., ± catStringValue:, ± preCat:, ± preCatStringValue:, ± insert:at:, ±€insertStringValue:at:, ± strcat:, ± strncat::




preCatStringValue:
± preCatStringValue:(const char *)s

Adds the c-string of s to the front of the receiving MOString.  This method will not work for unique strings.

See also:    ± cat:, ± catFromFormat:..., ± catStringValue:, ± preCat:, ± preCatFromFormat:..., ± insert:at:, ±€insertStringValue:at:, ± strcat:, ± strncat::




printForDebugger:
± printForDebugger:(NXStream *)stream

Writes an attractive representation of the MOString to the stream.  This uses the ± buildInstanceImageIn: method to write all the instance variables along with whatever the Object implementation writes.

See also:   ± buildInstanceImageIn:, ± printToStdErr:




printToStdErr:
± printToStdErr:(const char *)label

Writes an attractive representation of the MOString to the stderr file descriptor.  This uses the ±€buildInstanceImageIn: method to write all the instance variables along with a leading line that looks like this: 
		"label <MOString:addressOfInstance>"

See also:   ± buildInstanceImageIn:, ± printForDebugger:




read:
± read:(NXTypedStream *)strm

Reads the string from the stream.

See also:   ± write:




recalcLength
± (size_t)recalcLength

Recalculates the MOString's content's length by using the strlen() library function.  This method is used by several other methods of MOString to keep the length instance variable in synch with reality.  You shouldn't have to use this method unless you're going behind MOString's back and modifying its contents (naughty, naughty).




replaceAllOccurrencesOfChar: with:

± (int)replaceAllOccurrencesOfChar:(char)oldChar with:(char)newChar


Replaces all occurrences of oldChar with newChar.  Returns the number of occurrences replaced.  '\0' is not acceptable for either oldChar or newChar.  Returns -1 if the MOString is unique or either argument is '\0'.  This method doesn't work with unique strings.

See also:   ± charAt:, ± positionOf:nthOccurrence:, ± replaceCharAt:with:, ± substringFrom:to:, ANSI style methods




replaceCharAt: with:
± (char)replaceCharAt:(int)index with:(char)newChar

Replaces the character at index in the MOString's contents with newChar.  The old character that was there is returned.  This method doesn't work with unique strings.

See also:   ± charAt:, ± positionOf:nthOccurrence:, ± replaceAllOccurrencesOfChar:with:, ± substringFrom:to:, ANSI style methods




setDoubleValue:	(Cell conceptual continuity)
± setDoubleValue:(double)aDouble

Sets the MOString's contents to be a string representation of the given double-precision floating point number.  Frees the old contents if it should, and marks the memory it allocates for the new string as shouldFree.  This method is the same as ± setFromFormat:"%f", aDouble.

See also:   ± intValue, ± floatValue, ± doubleValue, ± setIntValue, ± setFloatValue




setFloatValue:	(Cell conceptual continuity)
± setFloatValue:(float)aFloat

Sets the MOString's contents to be a string representation of the given floating point number.  Frees the old contents if it should, and marks the memory it allocates for the new string as shouldFree.  This method is the same as ±€setFromFormat:"%f", aFloat.

See also:   ± intValue, ± floatValue, ± doubleValue, ± setIntValue, ± setDoubleValue




setFromFormat: , ...
± setFromFormat:(const char *)formatStr , ...

Treats the formatStr and following arguments as printf() style arguments to set the string.  Memory is allocated for the contents and the MOString assumes responsibility for the memory.  Frees any prior string first if it should.

See also:   ± setStringValue..., ± stringValue




setIntValue:	(Cell conceptual continuity)
± setIntValue:(int)anInt

Sets the MOString's contents to be a string representation of the given integer.  Frees the old contents if it should, and marks the memory it allocates for the new string as shouldFree.  This method is the same as ±€setFromFormat:"%d",€anInt.

See also:   ± intValue, ± floatValue, ± doubleValue, ± setFloatValue, ± setDoubleValue




setNull
± setNull

Sets the string to a NULL pointer.  Frees any prior string first if it should.  Note that this is different from setting the MOString's contents to the empty string.

See also:   ± isNull, ± isEmpty




setShouldFree:
± setShouldFree:(BOOL)flag

If flag is YES then the MOString will free its content's memory when it no longer needs it.  If flag is no then the MOString will not free its content's memory.  This method will not work for unique strings.  Unique strings always return YES for ± shouldFree.

See also:   ± shouldFree, ± free




setStringValue:	(Cell conceptual continuity)
± setStringValue:(const char *)s

Sets the string to a copy of s.  The MOString will assume responsibility for the memory.  Frees any prior string first if it should.

See also:   ± setStringValue..., ± stringValue, ± setFromFormat: , ...




setStringValueNoCopy:	(Cell conceptual continuity)
± setStringValueNoCopy:(char *)s

Sets the string to s. The MOString does not assume responsibility for the memory pointed to.  Frees any prior string first if it should.

See also:   ± setStringValue..., ± stringValue, ± setFromFormat: , ...




setStringValueNoCopy: shouldFree:	(Cell conceptual continuity)
± setStringValueNoCopy:(char *)s shouldFree:(BOOL)flag

Sets the string to s. If flag is YES the MOString assumes responsibility for the memory pointed to. If flag is NO the MOString does not assume responsibility for the memory pointed to.  Frees any prior string first if it should.

See also:   ± setStringValue..., ± stringValue, ± setFromFormat: , ...




setStringValueUnique:
± setStringUnique:(const char *)s

Sets the string to s.  The given string is first passed to NXUniqueString().  Then it is stored as a unique string.  MOString will not allow unique strings to be modified.  MOString never frees unique strings.  Frees any prior string first if it should.

See also:   ± setStringValue..., ± stringValue, ± setFromFormat: , ...




shallowCopy
± shallowCopy

Returns a new MOString object that is a duplicate of the receiver.  The contents of the origianl MOString is never copied.  The shouldFree flag of the new object is always NO.  The new string is unique if the original was.  The ± copy and ± copyFromZone: methods try to do the right thing as far as deciding whether to make a deep or shallow copy.  You should usually use those methods instead.

See also:   ± init..., ± free, ± shouldFree, ± setShouldFree:, ± copyFromZone:, ± deepCopy, ±€deepCopyFromZone:, ± shallowCopyFromZone:




shallowCopyFromZone:
± shallowCopyFromZone:(NXZone *)zone

Returns a new MOString object that is a duplicate of the receiver allocated from zone.  The contents of the origianl MOString is never copied.  The shouldFree flag of the new object is always NO.  The new string is unique if the original was.  The ± copy and ± copyFromZone: methods try to do the right thing as far as deciding whether to make a deep or shallow copy.  You should usually use those methods instead.

See also:   ± init..., ± free, ± shouldFree, ± setShouldFree:, ± copyFromZone:, ± deepCopy, ±€deepCopyFromZone:, ± shallowCopy




shouldFree
±(BOOL) shouldFree

Returns YES if the MOString will free its content memory when it is done with it.  Unique strings always return YES.

See also:   ± setShouldFree:, ± free




sprintf: , ...	(ANSI conceptual continuity)
± sprintf:(const char *)formatStr , ...

Identical to ± setFromFormat:,... which is the preferred call.  It is provided for conceptual continuity.

See also:   ± setFromFormat:, ± initFromFormat:, ANSI style methods




strcat:	(ANSI conceptual continuity)
± (const char *)strcat:(const char *)s

Appends s to the end of the MOString's contents.  This won't work for unique strings.  The new contents will be freeable since the MOString allocates the memory.

See also:   ± cat:, ± catFromFormat:..., ANSI style methods




strchr:	(ANSI conceptual continuity)
± (const char *)strchr:(char)aChar

Returns a pointer to the first occurrence of aChar in the MOString's contents or NULL if there isn't one.  This is a pointer to the actual memory that contents uses so don't mess with it.

See also:   ± positionOf:nthOccurrence:, ANSI style methods




strcmp:	(ANSI conceptual continuity)
± (int)strcmp:(const char *)s

Returns the standard strcmp() return values using the receiver's contents as the first string and the string s as the second string.  Returns -2 if there is a problem.  «Query:  can strcmp() return -2.  If it can then my error code ain't so hot.  Suggestions?»  It is suggested that you use the ± compareStr... methods instead.

See also:   ± compare..., ± compareStr..., ± isEqual..., ANSI style methods




strcpy:	(ANSI conceptual continuity)
± (const char *)strcpy:(const char *)s

Just like ± setStringValue: except that it returns a pointer to the contents when done.

See also:   ± setStringValue..., ANSI style methods




strcspn:	(ANSI conceptual continuity)
± (size_t)strcspn:(const char *)breakChars

Returns the number of characters in the MOString's contents starting from the beginning of the string and counting until there is a character that is also in breakChars.

See also:   ± substringFrom:to:, ANSI style methods




stringValue	(Cell conceptual continuity)
± (const char *)stringValue

Returns the current string.  DO NOT MODIFY THIS STRING.

See also:   ± setStringValue..., ± setFromFormat: , ...




strlen	(ANSI conceptual continuity)
± (size_t)strlen

Returns the length in characters of the MOString's contents excluding the trailing '\0'.  This is provided for ANSI friendliness.  ± length is the preferred way of getting this info.

See also:   ± count, ± length




strncat: :	(ANSI conceptual continuity)
± (const char *)strncat:(const char *)s :(int)n

Appends up to the first n characters of s to the end of the MOString's contents.  This won't work for unique strings.  The new contents will be freeable since the MOString allocates the memory.

See also:   ± cat:, ± catFromFormat:..., ANSI style methods




strncmp: :	(ANSI conceptual continuity)
± (int)strncmp:(const char *)s :(int)n

Returns the standard strncmp() return values using the receiver's contents as the first string and the string s as the second string.  Returns -2 if there is a problem.  «Query:  can strncmp() return -2.  If it can then my error code ain't so hot.  Suggestions?»  It is suggested that you use the ± compareStr... methods instead.

See also:   ± compare..., ± compareStr..., ± isEqual..., ANSI style methods




strncpy: :	(ANSI conceptual continuity)
± (const char *)strncpy:(const char *)s :(int)n

Just like ± setStringValue: except that it uses only up to the first n characters and it returns a pointer to the contents when done.

See also:   ± setStringValue..., ANSI style methods




strpbrk:	(ANSI conceptual continuity)
± (const char *)strpbrk:(const char *)breakChars

Returns the number of characters in the MOString's contents starting from the beginning of the string and counting until there is a character that is not in acceptableChars.

See also:   ± substringFrom:to:, ± tokenize:into:, ANSI style methods




strrchr:	(ANSI conceptual continuity)
± (const char *)strrchr:(char)aChar

Returns a pointer to the last occurrence of aChar in the MOString's contents or NULL if there isn't one.  This is a pointer to the actual memory that contents uses so don't mess with it.

See also:   ± positionOf:nthOccurrence:, ANSI style methods




strspn:	(ANSI conceptual continuity)
± (size_t)strspn:(const char *)acceptableChars

Returns the number of characters in the MOString's contents starting from the beginning of the string and counting until there is a character that is not in acceptableChars.

See also:   ± substringFrom:to:, ANSI style methods




strstr:	(ANSI conceptual continuity)
± (const char *)strstr:(const char *)searchStr

Returns a pointer to the first occurrence of searchStr in the MOString's contents or NULL if there isn't one.  This is a pointer to the actual memory that contents uses so don't mess with it.

See also:   ± positionOf:nthOccurrence:, ANSI style methods




substringFrom: to:
± substringFrom:(int)start to:(int)end

Returns a new MOString containing the substring of the receiver from character position start to position end.  The new string has its own memory which it will free when it is itself freed.

See also:   ± charAt:, ± replaceAllOccurrencesOfChar:with:, ± replaceCharAt:with:, ± positionOf:nthOccurrence:, ANSI style methods




takeDoubleValueFrom:	(Cell conceptual continuity)
± takeDoubleValueFrom:sender

Sets the contents of the MOString to the floating point value obtained by sending sender a doubleValue message.

See also:   ± takeStringValueFrom:, ± takeIntValueFrom:, ± takeFloatValueFrom:




takeFloatValueFrom:	(Cell conceptual continuity)
± takeFloatValueFrom:sender

Sets the contents of the MOString to the floating point value obtained by sending sender a floatValue message.

See also:   ± takeStringValueFrom:, ± takeIntValueFrom:, ± takeDoubleValueFrom:




takeIntValueFrom:	(Cell conceptual continuity)
± takeIntValueFrom:sender

Sets the contents of the MOString to the integer obtained by sending sender a intValue message.

See also:   ± takeStringValueFrom:, ± takeFloatValueFrom:, ± takeDoubleValueFrom:




takeStringValueFrom:	(Cell conceptual continuity)
± takeStringValueFrom:sender

Sets the contents of the MOString to the string obtained by sending sender a stringValue message.

See also:   ± takeIntValueFrom:, ± takeFloatValueFrom:, ± takeDoubleValueFrom:




tokenize: into:
± (List *)strstr:(const char *)breakChars into:aList

Fills aList with MOString objects that are the substrings of the MOString's contents broken at any character that appears in breakChars.  You can use this method to break a string into words by making breakChars the string " \t\n".  If a aList is nil then a List is allocated.  Returns the List that was passed in or allocated.  This method makes a copy of the MOString's contents and runs strtok() on it.  It frees the copy that was made when it is done.

Warning:  tokenize uses the ANSI function strtok() to parse the string.  strtok() keeps internal state and therefore strtok() calls cannot be nested, as it were.  If you don't use strtok() anywhere else within your app, then this method will work fine.  If you do, make sure that you don't call this method while you are in the middle of parsing another string with strtok().  Also notice that this method does not give the full flexibility of strtok().  It lacks the ability to change the parse tokens in the middle of parsing a string.

See also:   ± positionOf:nthOccurrence:, ANSI style methods




write:
± write:(NXTypedStream *)strm

Writes the string to the stream.

See also:   ± read:





These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.