LString is a PowerPlant class that is used for manipulating text strings.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
This class implements string functionality for Pascal-style strings. It serves as a base class for LStr255 and TString.
Source files:
Purpose:
This is a constructor to create a string from a max length and a string pointer. Subclasses must call this "protected" constructor to specify the maximum string size (including the length byte) and a pointer to the storage for the string
Access:
Prototype:
LString();Parameters:
Purpose:
These overloaded methods append characters to the end of this String.
Access:
Prototype:
LString& Append( const void* inPtr, UInt8 inLength );
LString& Append( SInt32 inNumber );
LString& Append( char inChar );
LString& Append( UInt8 inChar );
LString& Append( ConstStringPtr inStringPtr );
LString& Append( const LString& inString );Parameters:
The parameters for these methods are:
Return:
A reference to an LString that has the appended string.
Purpose:
Append a Pascal string to this String.
Access:
Prototype:
static StringPtr AppendPStr( Str255 ioBaseString,Parameters:
ConstStringPtr inAppendString,
SInt16 inDestSize );
The parameters for these methods are:
Return:
A pointer to the finished String.
Purpose:
Access:
Prototype:
LString& Assign(FourCharCode inCode);
LString& Assign(double_t inNumber,
SInt8 inStyle,SInt16 inDigits);
LString& Assign( SInt32 inNumber);
LString& Assign(ResIDT inResID,SInt16 inIndex);
LString& Assign( Handle inHandle);
LString& Assign(const void* inPtr,UInt8 inLength);
LString& Assign( const char* inCString);
LString& Assign( char inChar);
LString& Assign( UInt8 inChar);
LString& Assign( ConstStringPtr inStringPtr);
LString& Assign(const LString& inString,Parameters:
UInt8 inStartPos,UInt8 inCount);
The parameters for this method are:
Return:
A reference to the finished LString.
Purpose:
Indicate whether this String begins with a specified String.
Access:
Prototype:
Boolean BeginsWith( const void* inPtr,
UInt8 inLength ) const;
Boolean BeginsWith( UInt8 inChar) const;
Boolean BeginsWith(
ConstStringPtr inStringPtr) const;
Boolean BeginsWith( const LString& inString) const;Parameters:
The parameters for this method are:
Return:
A Boolean value of true if the String starts with the passed String, else false.
Purpose:
Return the length of a C string, but with an upper limit of 255.
Access:
Prototype:
static UInt8 CStringLength(const char* inCString);Parameters:
The parameters for this method are:
Return:
The length of the string (number of characters in it).
Purpose:
Simple byte-by-byte value comparison of two strings.
Access:
Prototype:
static SInt16 CompareBytes(Parameters:
const void* inLeft,
const void* inRight,
UInt8 inLeftLength,
UInt8 inRightLength );
The parameters for this method are:
Return:
Return 1 of the Left String is greater, else return -1 if the Right String is greater. Equality will cause a return value of 0.
Purpose:
Case-insensitve string comparison.
Access:
Prototype:
static SInt16 CompareIgnoringCase(Parameters:
const void* inLeft,
const void* inRight,
UInt8 inLeftLength,
UInt8 inRightLength );
The parameters for this method are:
Return:
Return 1 of the Left String is greater, else return -1 if the Right String is greater. Equality will cause a return value of 0.
Purpose:
Compare two strings using a compare function set in mCompareFunc.
Access:
Prototype:
SInt16 CompareTo (const void* inPtr, UInt8 inLength)
const;
SInt16 CompareTo( UInt8 inChar) const;
SInt16 CompareTo(ConstStringPtr inStringPtr) const;
SInt16 CompareTo( const LString& inString) const;Parameters:
The parameters for this method are:
Return:
The return values are specified by the compare function you supply.
Purpose:
Copy a Pascal String into the String.
Access:
Prototype:
static StringPtr CopyPStr(Parameters:
ConstStringPtr inSourceString,
StringPtr outDestString,
SInt16 inDestSize );
The parameters for this method are:
Return:
A pointer to the String is returned.
Purpose:
Return whether this String ends with a specified String.
Access:
Prototype:
Boolean EndsWith( const void* inPtr,
UInt8 inLength) const;
Boolean EndsWith( UInt8 inChar) const;
Boolean EndsWith( ConstStringPtr inStringPtr) const;
Boolean EndsWith( const LString& inString) const;Parameters:
The parameters for this method are:
Return:
A Boolean value of true if the String starts with the passed String, else false.
Purpose:
Find a substring within a String.
Access:
Prototype:
UInt8 Find( const void* inPtr,
UInt8 inLength, UInt8 inStartPos ) const;
UInt8 Find( UInt8 inChar,
UInt8 inStartPos = 1 ) const;
UInt8 Find( ConstStringPtr inStringPtr,
UInt8 inStartPos = 1 ) const;
UInt8 Find( const LString& inString, UInt8Parameters:
inStartPos = 1 ) const;
The parameters for this method are:
Return:
Return the index of where the substring starts within this String.
Purpose:
Return the index of where this String starts within another String.
Access:
Prototype:
UInt32 FindWithin( const void* inPtr,
UInt32 inLength, UInt32 inStartPos ) const;
UInt8 FindWithin(UInt8 inChar,
UInt8 inStartPos = 1 ) const;
UInt8 FindWithin( ConstStringPtr inStringPtr, UInt8
inStartPos = 1 ) const;
UInt8 FindWithin( const LString& inString, UInt8Parameters:
inStartPos = 1 ) const;
The parameters for this method are:
Return:
Returns 0 if the substring is not in the String. inStartPos is the index within inPtr at which to begin searching. The default value is 1. Value 0 is not valid.
Remarks:
To find the next occurrence, set inStartPos to one plus the index
returned by the last FindWithin call.
Purpose:
Convert a four character code to a Pascal string and return a pointer to the string.
Access:
Prototype:
static StringPtr FourCharCodeToPStr(Parameters:
FourCharCode inCode,
StringPtr outString );
The parameters for this method are:
Return:
Returns a pointer to the string.
Remarks:
outString must point to a buffer (usually a string) that can hold the resulting
string, including the length byte. Therefore, the buffer must
be at least 5-bytes large. Usually, you will allocate an array
of 5 unsigned char.
Purpose:
Access:
Prototype:
LString& Insert( const void* inPtr,
UInt8 inLength, UInt8 inAtIndex);
LString& Insert( UInt8 inChar, UInt8 inAtIndex);
LString& Insert( ConstStringPtr inStringPtr, UInt8
inAtIndex);
LString& Insert( const LString& inString, UInt8Parameters:
inAtIndex);
The parameters for this method are:
Return:
A reference to the finished string.
Purpose:
Access:
Prototype:
UInt8 Length() const;Parameters:
Return:
Returns the number of characters in the String.
Purpose:
Fill in the String given a pointer and a byte count.
Access:
Prototype:
void LoadFromPtr( const void* inPtr,Parameters:
UInt8 inLength );
The parameters for this method are:
Return:
Purpose:
Fill in the String from a STR resource.
Access:
Prototype:
void LoadFromSTRListResource( ResIDT inResID,
SInt16 inIndex);
void LoadFromSTRResource( ResIDT inResID );Parameters:
The parameters for this method are:
Return:
Purpose:
This method calls LoadFromPtr().
Access:
Prototype:
void LoadFromStringPtr( ConstStringPtrParameters:
inStringPtr);
The parameter for this method is:
Return:
Purpose:
Convert a Pascal string to a four character code.
Access:
Prototype:
static void PStrToFourCharCode(Parameters:
ConstStringPtr inString,
FourCharCode &outCode );
The parameters for this method are:
Return:
Purpose:
Remove a given number of bytes from this String starting at the specified index.
Access:
Prototype:
LString& Remove(Parameters:
UInt8 inStartPos,
UInt8 inCount );
The parameters for this method are:
Return:
Purpose:
Replace a portion of this String with a new value.
Access:
Prototype:
LString& Replace( UInt8 inStartPos, UInt8 inCount,
const void* inPtr, UInt8 inLength );
LString& Replace( UInt8 inStartPos, UInt8 inCount,
UInt8 inChar );
LString& Replace( UInt8 inStartPos, UInt8 inCount,
ConstStringPtr inStringPtr );
LString& Replace( UInt8 inStartPos, UInt8 inCount,Parameters:
const LString& inString );
The parameters for this method are:
Return:
Purpose:
Find where a substring starts within this String, searching from the end of the String towards the beginning of the String.
Access:
Prototype:
UInt8 ReverseFind( const void* inPtr, UInt8
inLength, UInt8 inStartPos ) const;
UInt8 ReverseFind( UInt8 inChar, UInt8 inStartPos
= 255 ) const;
UInt8 ReverseFind( ConstStringPtr inStringPtr,
UInt8 inStartPos = 255 ) const;
UInt8 ReverseFind( const LString& inString, UInt8
inStartPos = 255 ) const;
UInt32 ReverseFindWithin( const void* inPtr,
UInt32 inLength, UInt32 inStartPos ) const;
UInt8 ReverseFindWithin( UInt8 inChar, UInt8
inStartPos = 1 ) const;
UInt8 ReverseFindWithin( ConstStringPtr
inStringPtr, UInt8 inStartPos = 255 ) const;
UInt8 ReverseFindWithin( const LString& inString,Parameters:
UInt8 inStartPos = 255 ) const;
The parameters for this method are:
Return:
The index where the item was found.
Purpose:
Sets the value of mCompareFunc to point to a function used for comparing strings.
Access:
Prototype:
void SetCompareFunc( CompareFunc inCompareFunc );Parameters:
The parameters for this method are:
Return:
Purpose:
This method is a String comparison function that uses the Toolbox CompareText() routine.
Access:
Prototype:
static SInt16 ToolboxCompareText(Parameters:
const void* inLeft,
const void* inRight,
UInt8 inLeftLength,
UInt8 inRightLength );
The parameters for this method are:
Return:
This is the same as the return value for CompareText() in the Mac OS Toolbox.
Purpose:
This is an operator overload for the += operator. It calls the Append (TypeParameters ) method to append a String to another String.
TypeParameter:
long, char, unsigned char, const unsigned char*, const LString&
Access:
Prototype:
LString& operator+=(TypeParameter );Parameters:
The specified TypeParameters may be input to this operator.
Return:
Type Parameter:
unsigned long, long, const char*, char, unsigned char, const unsigned char*, const LString&
Purpose:
This is an operator overload for the = (assignment) operator. It calls the Assign(TypeParameters) method to assign a String to another String.
TypeParameter:
unsigned long, long, const char*, char, unsigned char, const unsigned char*, const LString&
Access:
Prototype:
LString& operator=(TypeParameter );Parameters:
The specified TypeParameters may be input to this operator.
Return:
Purpose:
Return a LStr255 String object containing the specified substring of this String.
Access:
Prototype:
LStr255 operator()(Parameters:
UInt8 inStartPos,
UInt8 inCount ) const;
The parameters for this operator are:
Return:
Purpose:
Return a character at a specified position in the String.
Access:
Prototype:
const UInt8& operator[]( UInt8 inPosition ) const;Parameters:
The parameter for this operator is:
Return:
A reference to the unsigned character.
Purpose:
Access individual characters in a String, in an array-like fashion.
Access:
Prototype:
UInt8& operator[]( UInt8 inPosition );Parameters:
The parameter for this operator is:
Return:
A reference to the unsigned character.
Purpose:
Retrieve the value of mStringPtr.
Access:
Prototype:
operator ConstStringPtr() const;Parameters:
Return:
A pointer to the String held in mStringPtr.
Purpose:
This operator provides a conversion to a floating point number.
Access:
Prototype:
operator double_t() const;Parameters:
Return:
A double_t that represents the String.
Purpose:
This operator provides a conversion to a long integer.
Access:
Prototype:
operator SInt32() const;Parameters:
Return:
A SInt32 that represents the String.
Purpose:
This operator provides a conversion to a char* pointer.
Access:
Prototype:
operator StringPtr();Parameters:
Return:
A StringPtr that represents the String.
Purpose:
This operator provides a conversion to a four character code.
Access:
Prototype:
operator FourCharCode() const;Parameters:
Return:
A FourCharCode that represents the String.
Purpose:
Access:
Prototype:
StringPtr mStringPtr;
Purpose:
The compare function pointer for the String.
Access:
Prototype:
CompareFunc mCompareFunc;
Purpose:
The maximum number of bytes for the String.
Access:
Prototype:
UInt16 mMaxBytes;