home *** CD-ROM | disk | FTP | other *** search
- /*==============================================================================
- Module Name: istring.hpp
-
- Description:
- Declaration for the "string" class IString.
-
- Copyright: (C) Copyright IBM Corporation 1992
- All Rights Reserved
- Licensed Materials = Property of IBM
-
- Usage:
- This header file is #include-d in other modules requiring
- use of the class IString.
-
- Notes:
-
- History:
- flag yymmdd who description
- ---- ------ --- -----------------------------------------------------------
- 920710 law Revised for ICLUI
- ==============================================================================*/
- #if !defined( _ISTRING_ )
- #define _ISTRING_
-
- #if !defined( _IBASETYP_ )
- #include <ibasetyp.hpp>
- #endif
-
- // Forward declarations for classes referenced herein.
- class IStringTest;
- class IBuffer;
- class ostream;
-
- /*------------------------------------------------------------------------------
- Class Name: IString
-
- Class Hierarchy:
- IString
-
- Description:
- Objects of this class replace conventional C "strings"
- (i.e., char* pointers).
-
- Usage:
- Objects of this class are essentially arrays of characters.
-
- IStrings provide the following function beyond that typically
- granted by standard C char* arrays and the string.h library
- functions:
-
- o No restrictions on string contents (i.e., strings can
- contain null characters)
- o Automatic conversion from/to numeric types
- o Automatic deletion of string buffer when the IString is
- deleted
- o Full support for all comparison operators
- o Full support for all bit-wise operators
- o Full support for concatenation using the more natural "+"
- operator
- o String data testing (for characters, digits, hex digits,
- etc.)
- o Full complement of string manipulation functions (center,
- left/right justify, leading/trailing char stripping,
- substring deletion, insertion of strings, etc.)
- o Full complement of correponding string manipulation functions
- that return a new IString, rather than modifying the receiver
- o Full complement of string searching functions (index of
- string, last index of string, etc.)
- o Word manipulation (index of word, search for word phrase,
- etc.)
-
- Notes:
- 1. DBCS and NLS support is "enabled" but not yet implemented.
-
- Related Topics:
- IStringTest
- IBuffer
- ------------------------------------------------------------------------------*/
- class IString {
- public:
- /*---------------------------- Instance Creation -------------------------------
-
- There are four basic categories of constructors:
-
- 1. Construct a null string.
-
- 2. Construct a string with the Ascii representation of a given
- numeric value (supporting all flavors of int and double).
-
- 3. Construct a string with a copy of the given character data
- (supporting Ascii-Z strings, characters, and IStrings).
-
- 4. Construct a string with contents consisting of copies of up
- to three buffers of arbitrary data (void*). Optionally,
- only the length need be provided, in which case the IString
- contents will be initialize to a given pad character (default
- is a blank).
- ------------------------------------------------------------------------------*/
- IString ( );
- IString ( const IString & );
-
- IString ( int );
- IString ( unsigned );
- IString ( long );
- IString ( unsigned long );
- IString ( short );
- IString ( unsigned short );
-
- IString ( double );
-
- IString ( char );
- IString ( unsigned char );
- #if !defined( __BORLANDC__ )
- IString ( signed char );
- #endif
-
- IString ( const char * );
- IString ( const unsigned char * );
- #if !defined( __BORLANDC__ )
- IString ( const signed char * );
- #endif
-
- IString ( const void *pBuffer1,
- unsigned lenBuffer1,
- char padCharacter = ' ' );
- IString ( const void *pBuffer1,
- unsigned lenBuffer1,
- const void *pBuffer2,
- unsigned lenBuffer2,
- char padCharacter = ' ' );
- IString ( const void *pBuffer1,
- unsigned lenBuffer1,
- const void *pBuffer2,
- unsigned lenBuffer2,
- const void *pBuffer3,
- unsigned lenBuffer3,
- char padCharacter = ' ' );
-
- ~IString ( );
-
- /*-------------------------------- Displaying ----------------------------------
-
- This function can be used to display a IString on an output
- stream, using the traditional left-shift operator (<<).
- ------------------------------------------------------------------------------*/
- friend ostream
- &operator << ( ostream &aStream,
- const IString &aString );
-
- /*--------------------------------- Testing ------------------------------------
-
- These functions test the characters that comprise the string.
-
- isAlnum - true iff all characters are in
- {'A'-'Z','a'-'z','0'-'9'}.
- isAlpha - true iff all characters are in {'A'-'Z','a'-'z'}.
- isAscii - true iff all characters are in {0x00-0x7F}.
- isCntrl - true iff all characters are in {0x00-0x1F,0x7F}.
- isDigits - true iff all characters are in {'0'-'9'}.
- isGraphics - true iff all characters are in {0x21-0x7E}
- isHexDigits - true iff all characters are in
- {'0'-'9','A'-'F','a'-'f'}.
- isBinaryDigits- true iff all characters are either '0' or '1'
- isLowerCase - true iff all characters are in {'a'-'z'}.
- isPrintable - true iff all characters are in {0x20-0x7E}.
- isPunctuation - !( isWhiteSpace || isCntrl || isAlnum ).
- isWhiteSpace - true iff all characters are in {0x09-0x0D,0x20}.
- isUpperCase - true iff all characters are in {'A'-'Z'}.
-
- isLike - true iff the receiver matches the argument "pattern"
- which may contain 'wildcard' characters
-
- isAbbrevFor - true if the receiver is a valid abbreviation of the
- argument string.
-
- includes - true if the receiver contains the argument search
- string
- ------------------------------------------------------------------------------*/
- Boolean
- isAlnum ( ) const,
- isAlpha ( ) const,
- isAscii ( ) const,
- isCntrl ( ) const,
- isDigits ( ) const,
- isGraphics ( ) const,
- isHexDigits ( ) const,
- isBinaryDigits ( ) const,
- isLowerCase ( ) const,
- isPrintable ( ) const,
- isPunctuation ( ) const,
- isUpperCase ( ) const,
- isWhiteSpace ( ) const,
-
- isLike ( const IString &aPattern,
- char zeroOrMore = '*',
- char anyChar = '?' ) const,
- isLike ( const char *pPattern,
- char zeroOrMore = '*',
- char anyChar = '?' ) const,
-
- isAbbrevFor ( const IString &fullString,
- unsigned minAbbrevLength = 0 ) const,
- isAbbrevFor ( const char *pFullString,
- unsigned minAbbrevLength = 0 ) const,
-
- includes ( const IString &aString ) const,
- includes ( const char *pString ) const,
- includes ( char aChar ) const,
- includes ( const IStringTest &aTest ) const;
-
- /*------------------------------- Comparison -----------------------------------
-
- All boolean operators are defined for strings:
-
- == true iff the strings are identical
- != true iff the strings are not identical
- < true iff the first string is less than the second,
- applying the standard collating scheme (memcmp)
- > equivalent to !( string1 <= string2 )
- <= equivalent to ( string1 < string2) || (string1 == string2 )
- >= equivalent to !( string1 < string2)
-
- These functions are overloaded so that IStrings can be compared
- to objects of type char*, as well as to other IStrings.
- ------------------------------------------------------------------------------*/
- friend Boolean
- operator == ( const IString &string1,
- const IString &string2 ),
- operator == ( const IString &string1,
- const char *pString2 ),
- operator == ( const char *pString1,
- const IString &string2 ),
-
- operator != ( const IString &string1,
- const IString &string2 ),
- operator != ( const IString &string1,
- const char *pString2 ),
- operator != ( const char *pString1,
- const IString &string2 ),
-
- operator < ( const IString &string1,
- const IString &string2 ),
- operator < ( const IString &string1,
- const char *pString2 ),
- operator < ( const char *pString1,
- const IString &string2 ),
-
- operator <= ( const IString &string1,
- const IString &string2 ),
- operator <= ( const IString &string1,
- const char *pString2 ),
- operator <= ( const char *pString1,
- const IString &string2 ),
-
- operator > ( const IString &string1,
- const IString &string2 ),
- operator > ( const IString &string1,
- const char *pString2 ),
- operator > ( const char *pString1,
- const IString &string2 ),
-
- operator >= ( const IString &string1,
- const IString &string2 ),
- operator >= ( const IString &string1,
- const char *pString2 ),
- operator >= ( const char *pString1,
- const IString &string2 );
-
- /*------------------------------- Conversion -----------------------------------
-
- These functions permit the conversion of a string to various
- other data types. The types supported are the same set as are
- supported by the IString constructors:
-
- operator char* - returns char* pointer to string contents; note
- that there are also variants for unsigned char*
- and signed char*
- asInt - returns number represented by the string as a
- long integer
- asUnsigned - returns number represented by the string as an
- unsigned long
- asDouble - returns number represented by the string as a
- double
-
- In addition, there are a complete set of functions to convert a
- String from any "format" to another. The "formats" can be any of
- b - a string of binary digits ('0' and '1')
- c - a normal string of characters
- d - a string of decimal digits ('0' thru '9')
- x - a string of hexidecimal digits ('0' thru '9' and 'a/A' thru 'f/F')
-
- The resulting functions are:
-
- The following work if isBinaryDigits() == true; if not, they return a
- null string:
- b2c - changes '01' to '\x01', '00110011' to '3'
- b2d - changes '00011001' to '25', '0001001000110100' to '4660'
- b2x - changes '00011011' to '1b', '10001001000110100' to '11234'
-
- The following will always work:
- c2b - changes 'a' to '01010001', '12' to '11000100110010'
- c2d - changes 'a' to '97', 'ab' to '24930'
- c2x - changes 'a' to '61', 'ab' to '6162'
-
- The following work if isDigits() == true; if not, they return a null
- string:
- d2b - changes '12' to '1100', '123' to '1111011'
- d2c - changes '12' to '\x0c', '56' to '8'
- d2x - changes '12' to 'c', '123' to '7b'
-
- The following work if isHexDigits() == true; if not, they return a
- null string:
- x2b - changes 'a1c' to '101000011100', 'f3' to '11110011'
- x2c - changes '8' to '\x08', '31393932' to '1992'
- x2d - changes 'a1c' to '2588', '10000' to '65536'
-
- There are plain functions by the same name that can be applied to
- a String to return the modified string (without changing the argument
- String). These are used much like the similar Rexx functions. E.g.,
-
- aString.c2b(); // Changes aString.
- String binaryDigits = c2b( aString ); // Leaves aString alone.
- ------------------------------------------------------------------------------*/
- operator char* ( ) const;
- operator unsigned char* ( ) const;
- #if !defined( __BORLANDC__ )
- operator signed char* ( ) const;
- #endif
-
- long
- asInt ( ) const;
-
- unsigned long
- asUnsigned ( ) const;
-
- double
- asDouble ( ) const;
-
- IString
- &b2c ( ),
- &b2d ( ),
- &b2x ( ),
- &c2b ( ),
- &c2d ( ),
- &c2x ( ),
- &d2b ( ),
- &d2c ( ),
- &d2x ( ),
- &x2b ( ),
- &x2c ( ),
- &x2d ( );
-
- /*------------------------- Manipulation Operators -----------------------------
-
- These functions allow the string contents to be manipulated.
- All are overloaded so that standard C "strings" can be used
- efficiently (without constructing an equivalent String
- first).
-
- = - Replaces the contents of the string
- ~ - Returns bitwise negation (one's complement)
- + - Concatenates two strings
- += - Concatenate and replace
- & - Performs bitwise "and"
- &= - Performs bitwise "and" and replaces receiver
- | - Performs bitwise "or"
- |= - Performs bitwise "or" and replaces receiver
- ^ - Performs bitwise "xor"
- ^= - Performs bitwise "xor" and replaces receiver
- ------------------------------------------------------------------------------*/
- IString
- &operator = ( const IString &aString );
-
- IString
- operator + ( const IString &aString ) const,
- operator + ( const char *pString ) const;
-
- friend IString
- operator + ( const char *pString,
- const IString &aString );
-
- IString
- operator ~ ( ) const;
-
- IString
- &operator += ( const IString &aString ),
- &operator += ( const char *pString );
-
- IString
- operator & ( const IString &aString ) const,
- operator & ( const char *pString ) const;
-
- friend IString
- operator & ( const char *pString,
- const IString &aString );
-
- IString
- &operator &= ( const IString &aString ),
- &operator &= ( const char *pString );
-
- IString
- operator | ( const IString &aString ) const,
- operator | ( const char *pString ) const;
-
- friend IString
- operator | ( const char *pString,
- const IString &aString );
-
- IString
- &operator |= ( const IString &aString ),
- &operator |= ( const char *pString );
-
- IString
- operator ^ ( const IString &aString ) const,
- operator ^ ( const char *pString ) const;
-
- friend IString
- operator ^ ( const char *pString,
- const IString &aString );
-
- IString
- &operator ^= ( const IString &aString ),
- &operator ^= ( const char *pString );
-
- /*------------------------------- Accessing ------------------------------------
-
- These functions provide access to general information about
- the string.
-
- size - Returns the length of the string (not counting
- the terminating null character).
- length - Same as "size"
- subString - Returns a given substring of the receiver.
- operator[] - Return a reference to the n-th character of the
- string. NOTE: The non-const version of this
- function will extend the string if invoked with
- and extend beyond the end.
- ------------------------------------------------------------------------------*/
- unsigned
- size ( ) const,
- length ( ) const;
-
- IString
- subString ( unsigned startPos ) const,
- subString ( unsigned startPos,
- unsigned length,
- char padCharacter = ' ' ) const;
-
- char
- &operator [] ( unsigned index );
-
- const char
- &operator [] ( unsigned index ) const;
-
- /*------------------------------- Searching ------------------------------------
-
- These functions permit searching the string in various ways.
-
- indexOfAnyBut - Returns the index of the first character of
- the receiver that is *not* in the argument
- set of characters (0 if none); alternatively,
- returns the index of the first character that
- fails the test proscribed by an argument
- IStringTest object
- indexOfAnyOf - Returns the index of the first character of
- the receiver that *is* a character in the
- argument set of characters (0 if none);
- alternatively, returns the index of the first
- character that passes the test proscribed by
- an argument IStringTest object
- indexOf - Return the index of the first occurrence of
- the argument string within the reciever (0
- if none); the argument can also be a single
- character or a IStringTest
- occurrencesOf - Returns number of occurrences of the argument
- String,char*,char,test (slower than indexOf if you
- just want a boolean test).
-
- One can specify an optional index that indicates where in
- the String the search is to start (default is to start at
- the beginning of the string).
-
- Each of the "indexing" functions also has a "lastIndexOf"
- version that returns the index of the last character in
- the receiver IString that satisfies the search criteria.
- These functions accept an optional argument that specifies
- where the search is to commence (defaults to the end of the
- string).
-
- Notes:
- 1. Use of the search functions requiring a IStringTest
- argument necessitate the #including of istrtest.hpp
-
- Related Topics:
- includes
- ------------------------------------------------------------------------------*/
- unsigned
- indexOf ( const IString &aString,
- unsigned startPos = 1 ) const,
- indexOf ( const char *pString,
- unsigned startPos = 1 ) const,
- indexOf ( char aCharacter,
- unsigned startPos = 1 ) const,
- indexOf ( const IStringTest &aTest,
- unsigned startPos = 1 ) const,
-
- indexOfAnyBut ( const IString &validChars,
- unsigned startPos = 1 ) const,
- indexOfAnyBut ( const char *pValidChars,
- unsigned startPos = 1 ) const,
- indexOfAnyBut ( char validChar,
- unsigned startPos = 1 ) const,
- indexOfAnyBut ( const IStringTest &aTest,
- unsigned startPos = 1 ) const,
-
- indexOfAnyOf ( const IString &searchChars,
- unsigned startPos = 1 ) const,
- indexOfAnyOf ( const char *pSearchChars,
- unsigned startPos = 1 ) const,
- indexOfAnyOf ( char searchChar,
- unsigned startPos = 1 ) const,
- indexOfAnyOf ( const IStringTest &aTest,
- unsigned startPos = 1 ) const,
-
- lastIndexOf ( const IString &aString,
- unsigned endPos = 0 ) const,
- lastIndexOf ( const char *pString,
- unsigned endPos = 0 ) const,
- lastIndexOf ( char aCharacter,
- unsigned endPos = 0 ) const,
- lastIndexOf ( const IStringTest &aTest,
- unsigned startPos = 1 ) const,
-
- lastIndexOfAnyBut ( const IString &validChars,
- unsigned endPos = 0 ) const,
- lastIndexOfAnyBut ( const char *pValidChars,
- unsigned endPos = 0 ) const,
- lastIndexOfAnyBut ( char validChar,
- unsigned startPos = 1 ) const,
- lastIndexOfAnyBut ( const IStringTest &aTest,
- unsigned endPos = 0 ) const,
-
- lastIndexOfAnyOf ( const IString &searchChars,
- unsigned endPos = 0 ) const,
- lastIndexOfAnyOf ( const char *pSearchChars,
- unsigned endPos = 0 ) const,
- lastIndexOfAnyOf ( char searchChar,
- unsigned startPos = 1 ) const,
- lastIndexOfAnyOf ( const IStringTest &aTest,
- unsigned endPos = 0 ) const,
-
- occurrencesOf ( const IString &aString,
- unsigned startPos = 1 ) const,
- occurrencesOf ( const char *pString,
- unsigned startPos = 1 ) const,
- occurrencesOf ( char aCharacter,
- unsigned startPos = 1 ) const,
- occurrencesOf ( const IStringTest &aTest,
- unsigned startPos = 1 ) const;
-
- /*-------------------------------- Editing -------------------------------------
-
- These functions are used to edit the string. All return
- a reference to the (modified) receiver. Many that are
- 'length related' (e.g., center, leftJustify) accept a pad
- character which defaults to a blank. In all cases, argument
- strings can be specified as either objects of class String
- or via char*.
-
- center - centers the receiver within a string of the
- specified length
- change - changes occurrences of an argument pattern to
- an argument replacement string, the number
- of changes to perform can be specified (defaults
- to all occurrences of the pattern), as can the
- position in the receiver at which to begin
- copy - replaces the receiver's contents with a given
- number of replications of itself
- remove - Deletes the specified substring from the receiver
- insert - Inserts an argument string at a given location
- leftJustify - Left justifies the receiver in a string of the
- specified length
- lowerCase - Translates all upper case letters in the receiver
- to lower case
- overlayWith - Replaces a given portion of the receiver's contents
- with an argument string
- reverse - Reverse the receiver contents
- rightJustify - Right justifies the receiver in a string of the
- specified length.
- strip - Strips both leading and trailing character or
- characters; the character(s) can be specified
- either as a single char, a String (or char*
- array), or via a IStringTest (the latter defined
- in StrTest.hpp); the default is "whitespace"
- stripLeading - Strip leading char/chars
- stripTrailing - Strip trailing char/chars
- translate - Converts all receiver characters that are in one
- argument string to the corresponding character in
- a second argument string
- upperCase - Translates all lower case letters in the receiver
- to upper case.
-
- There are plain functions by the same name that can be applied to
- a String to obtain the modified String without affecting the
- argument. For example:
-
- aString.change('\t', ' '); // Changes all tabs in
- // aString to 3 blanks.
- String s = change( aString, '\t', ' ' ); // Leaves aString as is
- // but obtains modified version.
- ------------------------------------------------------------------------------*/
- IString
- ¢er ( unsigned length,
- char padCharacter = ' ' ),
-
- &change ( const IString &inputString,
- const IString &outputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
- &change ( const IString &inputString,
- const char *pOutputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
- &change ( const char *pInputString,
- const IString &outputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
- &change ( const char *pInputString,
- const char *pOutputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
-
- © ( unsigned numCopies ),
-
- &insert ( const IString &aString,
- unsigned index = 0,
- char padCharacter = ' ' ),
- &insert ( const char *pString,
- unsigned index = 0,
- char padCharacter = ' ' ),
-
- &leftJustify ( unsigned length,
- char padCharacter = ' ' ),
-
- &lowerCase ( ),
-
- &overlayWith ( const IString &aString,
- unsigned index = 1,
- char padCharacter = ' ' ),
- &overlayWith ( const char *pString,
- unsigned index = 1,
- char padCharacter = ' ' ),
-
- &remove ( unsigned startPos ),
- &remove ( unsigned startPos,
- unsigned numChars ),
-
- &reverse ( ),
-
- &rightJustify ( unsigned length,
- char padCharacter = ' ' ),
-
- &strip ( ),
- &strip ( char aCharacter ),
- &strip ( const IString &aString ),
- &strip ( const char *pString ),
- &strip ( const IStringTest &aTest ),
-
- &stripLeading ( ),
- &stripLeading ( char aCharacter ),
- &stripLeading ( const IString &aString ),
- &stripLeading ( const char *pString ),
- &stripLeading ( const IStringTest &aTest ),
-
- &stripTrailing ( ),
- &stripTrailing ( char aCharacter ),
- &stripTrailing ( const IString &aString ),
- &stripTrailing ( const char *pString ),
- &stripTrailing ( const IStringTest &aTest ),
-
- &translate ( const IString &inputChars,
- const IString &outputChars,
- char padCharacter = ' ' ),
- &translate ( const IString &inputChars,
- const char *pOutputChars,
- char padCharacter = ' ' ),
- &translate ( const char *pInputChars,
- const IString &outputChars,
- char padCharacter = ' ' ),
- &translate ( const char *pInputChars,
- const char *pOutputChars,
- char padCharacter = ' ' ),
-
- &upperCase ( );
-
- /*----------------------------- Word Functions ---------------------------------
-
- These functions operate on the string as a collection of
- words separated by whitespace characters.
-
- indexOfPhrase - Returns the position of the first occurrence
- of the argument phrase in the receiver
- indexOfWord - Returns the index of the n-th whitespace
- delimited word in the receiver
- lengthOfWord - Returns the length of the n-th whitespace
- delimited word in the receiver
- numWords - Returns the number of whitespace delimited words
- in the receiver
- removeWords - Deletes the specified words from the receiver
- contents; the words are specified via a starting
- word number and the number of words (the latter
- defaulting to the rest of the string) (See note)
- space - Modifies the receiver so that all words are
- separated by the specified number of blanks
- (defaults to 1); all whitespace is converted
- to simple blanks (See note)
- word - Returns a copy of the n-th whitespace delimited
- word in the receiver
- wordIndexOfPhrase - Returns the word number of the first word in
- receiver matching the argument phrase
- words - Returns a substring of the receiver that starts
- at a given word and comprised of a given number
- of words; the word separators are copied to
- the result intact
-
- There are plain functions "space" and "removeWords" that obtain
- the same result but do not affect the String to which they are
- applied.
- ------------------------------------------------------------------------------*/
- IString
- &removeWords ( unsigned firstWord ),
- &removeWords ( unsigned firstWord,
- unsigned numWords );
- unsigned
- indexOfPhrase ( const IString &wordString,
- unsigned startWord = 1 ) const,
-
- indexOfWord ( unsigned wordNumber ) const,
-
- lengthOfWord ( unsigned wordNumber ) const,
-
- numWords ( ) const,
-
- wordIndexOfPhrase ( const IString &aPhrase,
- unsigned startWord = 1 ) const;
-
- IString
- &space ( unsigned numSpaces = 1,
- char spaceChar = ' ' );
-
- IString
- word ( unsigned wordNumber ) const,
-
- words ( unsigned firstWord ) const,
- words ( unsigned firstWord,
- unsigned numWords ) const;
-
- // Modes for strip functions:
- typedef enum
- {
- leading,
- trailing,
- both
- } StripMode;
-
- protected:
-
- // Pointer to string contents:
- // IBuffer *pBuffer; deleted KMT
- char* pBuffer; // new - KMT
-
- // Static "constants":
- static const IString
- null,
- zero,
- maxLong;
-
- // Function to obtain contents:
- char
- *data ( ) const;
-
- // Function to set associatedIBuffer:
- void
- setBuffer( IBuffer *ibuff );
-
- // Function to obtain associated IBuffer:
- IBuffer
- *buffer ( ) const;
-
- // Static function to return string length (handles NULL):
- static unsigned
- lengthOf( const char *p );
-
- #if defined( __ZTC__ )
- public:
- #endif
-
- // Static function to return default (null) buffer pointer:
- static char
- *defaultBuffer ( );
-
- // Special constructor to take over ownership of buffer:
- IString ( IBuffer *pBuffer );
-
- #if defined( __ZTC__ )
- protected:
- #endif
-
- // Buffer inititialization:
- void
- initBuffer ( const void *p1,
- unsigned len1,
- const void *p2 = 0,
- unsigned len2 = 0,
- const void *p3 = 0,
- unsigned len3 = 0,
- char padChar = 0 ),
- initBuffer ( long n ),
- initBuffer ( unsigned long n ),
- initBuffer ( double d );
-
- // Common "occurrencesOf" implementation function:
- unsigned
- occurrencesOf ( const char *pSearchString,
- unsigned searchLen,
- unsigned startPos ) const;
-
- // Perform common isLike function:
- Boolean
- isLike ( const char *pPattern,
- unsigned patternLen,
- char zeroOrMore,
- char anyChar ) const;
-
- // Implement isAbbrevFor:
- Boolean
- isAbbrevFor ( const char *pFullString,
- unsigned fullLen,
- unsigned minLen ) const;
-
- // Apply bitwise operators:
- typedef enum
- {
- and,
- or,
- exclusiveOr
- } BitOperator;
-
- IString
- &applyBitOp ( const char *pArg,
- unsigned argLen,
- BitOperator op );
-
- // Common edit function implementation:
- IString
- &change ( const char *pPattern,
- unsigned patternLen,
- const char *pReplacement,
- unsigned replacementLen,
- unsigned startPos,
- unsigned numChanges ),
- &insert ( const char *pInsert,
- unsigned insertLen,
- unsigned startPos,
- char padCharacter ),
- &overlayWith ( const char *pOverlay,
- unsigned overlayLen,
- unsigned index,
- char padCharacter ),
- &strip ( const char *p,
- unsigned len,
- StripMode mode ),
- &strip ( const IStringTest &aTest,
- StripMode mode ),
- &translate ( const char *pInputChars,
- unsigned inputLen,
- const char *pOutputChars,
- unsigned outputLen,
- char padCharacter );
-
- // Enumeration of options to findPhrase:
- typedef enum
- {
- charIndex,
- wordIndex
- } IndexType;
-
- // Function to find word/phrase:
- unsigned
- findPhrase ( const IString &aPhrase,
- unsigned startWord,
- IndexType charOrWord ) const;
-
- // IndexOfWord utility function:
- unsigned
- indexOfWord ( unsigned wordNumber,
- unsigned startPos,
- unsigned numWords ) const;
-
- // character/decimal conversion utilities:
- void
- binaryMath ( unsigned char newDigit ),
- decimalMath ( unsigned char newDigit );
-
- // Make sure receiver holds only reference to its buffer:
- IString
- &prepareToChange();
-
- }; // class IString
-
- /*------------------------------Related Functions-------------------------------
-
- These are non-member functions that manipulate Strings. All (except
- the ones that declare binary operators with char* as first argument)
- are versions of the editing and conversion functions of the same name
- as member functions. These functions leave the IString argument
- unmodified (and return a modified IString only).
- ------------------------------------------------------------------------------*/
- IString
- center ( const IString &aString,
- unsigned length,
- char padCharacter = ' ' ),
-
- change ( const IString &aString,
- const IString &inputString,
- const IString &outputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
- change ( const IString &aString,
- const IString &inputString,
- const char *pOutputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
- change ( const IString &aString,
- const char *pInputString,
- const IString &outputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
- change ( const IString &aString,
- const char *pInputString,
- const char *pOutputString,
- unsigned startPos = 1,
- unsigned numChanges = 0 ),
-
- copy ( const IString &aString,
- unsigned numCopies ),
-
- insert ( const IString &aString,
- const IString &anInsert,
- unsigned index = 0,
- char padCharacter = ' ' ),
- insert ( const IString &aString,
- const char *pInsert,
- unsigned index = 0,
- char padCharacter = ' ' ),
-
- leftJustify ( const IString &aString,
- unsigned length,
- char padCharacter = ' ' ),
-
- lowerCase ( const IString &aString ),
-
- overlayWith ( const IString &aString,
- const IString &anOverlay,
- unsigned index = 1,
- char padCharacter = ' ' ),
- overlayWith ( const IString &aString,
- const char *pOverlay,
- unsigned index = 1,
- char padCharacter = ' ' ),
-
- remove ( const IString &aString,
- unsigned startPos ),
- remove ( const IString &aString,
- unsigned startPos,
- unsigned numChars ),
-
- removeWords ( const IString &aString,
- unsigned startWord ),
- removeWords ( const IString &aString,
- unsigned startWord,
- unsigned numWords ),
-
- reverse ( const IString &aString ),
-
- rightJustify ( const IString &aString,
- unsigned length,
- char padCharacter = ' ' ),
-
- space ( const IString &aString,
- unsigned numSpaces = 1,
- char spaceChar = ' ' ),
-
- strip ( const IString &aString ),
- strip ( const IString &aString,
- char aChar ),
- strip ( const IString &aString,
- const IString &aStringOfChars ),
- strip ( const IString &aString,
- const char *pStringOfChars ),
- strip ( const IString &aString,
- const IStringTest &aTest ),
-
- stripLeading ( const IString &aString ),
- stripLeading ( const IString &aString,
- char aChar ),
- stripLeading ( const IString &aString,
- const IString &aStringOfChars ),
- stripLeading ( const IString &aString,
- const char *pStringOfChars ),
- stripLeading ( const IString &aString,
- const IStringTest &aTest ),
-
- stripTrailing ( const IString &aString ),
- stripTrailing ( const IString &aString,
- char aChar ),
- stripTrailing ( const IString &aString,
- const IString &aStringOfChars ),
- stripTrailing ( const IString &aString,
- const char *pStringOfChars ),
- stripTrailing ( const IString &aString,
- const IStringTest &aTest ),
-
- translate ( const IString &aString,
- const IString &inputChars,
- const IString &outputChars,
- char padCharacter = ' ' ),
- translate ( const IString &aString,
- const IString &inputChars,
- const char *pOutputChars,
- char padCharacter = ' ' ),
- translate ( const IString &aString,
- const char *pInputChars,
- const IString &outputChars,
- char padCharacter = ' ' ),
- translate ( const IString &aString,
- const char *pInputChars,
- const char *pOutputChars,
- char padCharacter = ' ' ),
-
- upperCase ( const IString &aString ),
-
- b2c ( const IString &aString ),
- b2d ( const IString &aString ),
- b2x ( const IString &aString ),
- c2b ( const IString &aString ),
- c2d ( const IString &aString ),
- c2x ( const IString &aString ),
- d2b ( const IString &aString ),
- d2c ( const IString &aString ),
- d2x ( const IString &aString ),
- x2b ( const IString &aString ),
- x2c ( const IString &aString ),
- x2d ( const IString &aString );
-
- #endif