- Inherits from:
- Object
- Conforms to:
- DComparable, DDatable, DParsable, DSizeable, DTextReadable, DTextScannable, DTextWritable, DTextable
- Declared in:
- DText.h
Object
|
+---DText
Class Description
The text string class implements methods for storing and manipulating text strings.
- Last modified:
- 31-Oct-2007 (DText.h)
Instance Variables
- private unsigned long _size
- the allocated size for the string
- private unsigned _extra
- the extra amount for sizing
- private unsigned long _length
- the length of the string
- private unsigned long _pntr
- the pointer for the DTextReadable,-Writable protocols
- private char *_string
- the string data
- private int _error
- the last error (or 0)
- Constructors
- - (DText *) init
- Initialise an empty string
- Returns:
- the string object
- - (DText *) init :(const char *) cstring
- Initialise the object with a c-string
- Parameters:
- cstring - the zero terminated ascii string
- Returns:
- the string object
- Copy related methods
- - shallowCopy
- Do a shallow copy of the string object
- Returns:
- the string object
- Deconstructor
- - free
- Free the object
- Returns:
- nothing
- DSizeable protocol methods
- - (DText *) extra :(unsigned) extra
- Set the amount of extra size increase if the size must be extended
- Parameters:
- extra - the amount (def. 0)
- Returns:
- the object
- - (DText *) size :(unsigned long) size
- Set the size (storage space) for the string
- Parameters:
- size - the request size for the string
- Returns:
- the string object
- Conversion methods
- - (double) toDouble
- Convert the string to a floating point number
- Returns:
- the floating point number
- - (int) toInt
- Convert the string to a integer number
- Returns:
- the integer number
- - (long) toLong
- Convert the string to a long number
- Returns:
- the long number
- String manipulation
- - (DText *) clear
- Clear the text string
- Returns:
- the object
- - (DText *) delete :(long) index
- Delete the character at the given index
- Parameters:
- index - the index in the string
- Returns:
- the string object
- - (DText *) delete :(long) from :(long) to
- Delete a substring from the string
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the string object
- - (DText *) format :(const char *) format,...
- Format the string
- Parameters:
- format - the format string
- Returns:
- the string object
- - (char) get :(long) index
- Get the character at the given index
- Parameters:
- index - the index in the string
- Returns:
- the character in the string or \0
- - (DText *) get :(long) from :(long) to
- Return a substring
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- a new text string object
- - (DText *) insert :(long) from :(long) to :(const char *) cstring
- Insert a cstring in a part of the string.
- Parameters:
- from - the start index
to - the end index (to >= (from-1))
cstring - the c-string
- Returns:
- the string object
- - (DText *) insert :(long) from :(long) to :(char) ch :(long) number
- Insert a number of characters in a part of the string
- Parameters:
- from - the start index
to - the end index (to >= (from-1))
ch - the character to be inserted
number - the number of characters to insert
- Returns:
- the string object
- - (DText *) put :(long) index :(char) ch
- Set a character at the given index (must fit in string)
- Parameters:
- index - the index in the string
ch - the character to be placed in the string
- Returns:
- the string object
- - (DText *) set :(const char *) cstring
- Set a c-string in the string
- Parameters:
- cstring - the c-string
- Returns:
- the string object
- - (DText *) set :(char) ch :(long) number
- Set number of characters in the string
- Parameters:
- ch - the character to be set
number - the number of characters
- Returns:
- the object
- - (DText *) set :(const char *) cstring :(long) from :(long) to
- Set a substring of a c-string in the object
- Parameters:
- cstring - the c-string
from - the start in the c-string
to - the end in the c-string
- Returns:
- the object
- - (DText *) split :(char) separator
- Split the string in two: the part before the separator character is
stored in the returning new string object; the part after the separator
remains in the string object.
- Parameters:
- separator - the character
- Returns:
- a new text object (or nil if character not found)
- String properties methods
- - (const char *) cstring
- Return the pointer to a c-string notation of the string
- Returns:
- the pointer to the c-string
- - (int) error
- Return the last occurred error
- Returns:
- the last error (or 0)
- - (BOOL) isEmpty
- Check if the string is empty
- Returns:
- Is the string empty ?
- - (unsigned long) length
- Return the length of the string
- Returns:
- the length of the string
- DTextable protocol methods
- - (DText *) toText
- Convert to a text string object
- Returns:
- a (new) text string object
- DDatable protocol methods
- - (DData *) toData
- Convert to a data string
- Returns:
- a (new) data string object
- DTextReadable protocol methods
- - (BOOL) isEof
- Check if the end of the string is reached
- Returns:
- is it?
- - (char) readChar
- Read character
- Returns:
- the character read
- - (DText *) readLine
- Read a line of text (till Eof or \n, not including in text string)
- Returns:
- a (new) text string
- - (DText *) readText
- Read text string (all available text)
- Returns:
- a (new) text string
- - (DText *) readText :(long) length
- Read text string
- Parameters:
- length - the length of the text to be read
- Returns:
- a (new) text string
- - (BOOL) seek :(unsigned long) offset :(int) origin
- Move the current position in the text string
- Parameters:
- offset - the offset from the origin (in bytes)
origin - the origin for the offset (0=begin, 1=current, 2=end)
- Returns:
- success
- - (BOOL) skip :(unsigned long) offset
- Skip a number of positions
- Parameters:
- offset - the number of bytes to skip
- Returns:
- success
- - (unsigned long) tell
- Tell the current position in the text string
- Returns:
- the current position
- TextScannable protocol methods
- - (BOOL) cmatch :(const char *) cstring
- Match a string case sensitive; if the string matched, the current position in
the readable is moved to the location after the matched string.
- Parameters:
- cstring - the c-string to be matched
- Returns:
- does the string match ?
- - (BOOL) imatch :(const char *) cstring
- Match a string case insensitive; if the string matched, the current position in
the readable is moved to the location after the matched string.
- Parameters:
- cstring - the c-string to be matched
- Returns:
- does the string match ?
- - (int) scanInt :(int) wrong
- Scan for a (decimal) integer value
- Parameters:
- wrong - the value returned if there is no int to scan
- Returns:
- the integer read (or the wrong value)
- - (DText *) scanText :(char) separator
- Scan for a text string until a separator character. The separator character is
is not part of the returned string and is skipped in the text object.
- Parameters:
- separator - the separator character
- Returns:
- a (new) text string (or nil if the separator is not found)
- - (DText *) scanText :(const char *) separators :(char *) separator
- Scan for a text string until one of the separator characters in the
separator string. The matched separator character is is not part of
the returned string, is skipped in the text object and is returned in
the separator argument.
- Parameters:
- separators - the c-string with the separators
separator - the destination for the actual matched separator character (or NULL)
- Returns:
- a (new) text string (or nil if none of the separators is found)
- - (int) skipChar :(char) ch
- Skip characters
- Parameters:
- ch - the character to be skipped
- Returns:
- the number of characters skipped
- - (int) skipWhiteSpace
- Skip whitespace
- Returns:
- the number of characters skipped
- TextWritable protocol methods
- - (BOOL) writeChar :(char) ch
- Write character
- Parameters:
- ch - the character to be written
- Returns:
- success
- - (BOOL) writeLine :(const char *) text
- Write line (appending a '\n')
- Parameters:
- text - the text to be written as line
- Returns:
- success
- - (BOOL) writeText :(const char *) text
- Write text string
- Parameters:
- text - the text to be written
- Returns:
- success
- DParsable methods
- - (int) fromString :(char **) cstr
- Parse a string for a DText string
- Parameters:
- cstr - the string to be parsed (moved to the first non-parsable char)
- Returns:
- the result (0, ENODATA)
- String manipulation methods
- - (DText *) append :(const char *) cstring
- Append a c-string to the string
- Parameters:
- cstring - the string to be appended
- Returns:
- the string object
- - (DText *) appendFormat :(const char *) format,...
- Append a formatted string
- Parameters:
- format - the format string
- Returns:
- the string object
- - (DText *) capitalize
- Capitalize the first character of the string
- Returns:
- the string object
- - (DText *) capwords
- Capitalize the first character of every word, replaces repeated whitespace
with one space and strips leading and trailing spaces.
- Returns:
- the string object
- - (DText *) center :(unsigned long) width
- Center the string
- Parameters:
- width - the length of the resulting string
- Returns:
- the string object
- - (DText *) column :(int) width
- Insert linefeeds in a string to create a column
- Parameters:
- width - the width of the column
- Returns:
- the object
- - (DText *) expandtabs :(unsigned) tabsize
- Expand all tabs with tabsize spaces
- Parameters:
- tabsize - the size of the tab in spaces
- Returns:
- the string object
- - (DText *) ljust :(unsigned long) width
- Align the string to the left
- Parameters:
- width - the length of the resulting string
- Returns:
- the string object
- - (DText *) lower
- Convert all uppercase characters in the string to lowercase
- Returns:
- the string object
- - (DText *) lstrip
- Strip leading spaces from the string
- Returns:
- the string object
- - (DText *) multiply :(unsigned) times
- Multiply the string a number of times
- Parameters:
- times - the number of times the string must be multiplied
- Returns:
- the string object
- - (char) pop
- Pop the last character from the string
- Returns:
- the character (or \0)
- - (DText *) prepend :(const char *) cstring
- Prepend a c-string in front of the string
- Parameters:
- cstring - the string to be prepended
- Returns:
- the string object
- - (DText *) push :(char) ch
- Push one character at the end of the string
- Parameters:
- ch - the character
- Returns:
- the object
- - (DText *) rjust :(unsigned long) width
- Align the string to the right
- Parameters:
- width - the length of the resulting string
- Returns:
- the string object
- - (DText *) rstrip
- Strip tailing spaces from the string
- Returns:
- the string object
- - (DText *) strip
- Strip both leading and tailing spaces from the string
- Returns:
- the string object
- - (DText *) swapcase
- Convert all lowercase to uppercase and uppercase to lowercase
- Returns:
- the string object
- - (DText *) upper
- Convert all lowercase characters in the string to uppercase
- Returns:
- the string object
- - (DText *) zfill :(unsigned long) width
- Pad a string to the left with zeros
- Parameters:
- width - the length of the resulting string
- Returns:
- the string object
- Comparable protocol methods
- - (int) compare :(DText *) other
- Compare the string with another string
- Parameters:
- other - the string that should be compared
- Returns:
- the compare result (-1, 0, 1)
- Comparison methods
- - (int) ccompare :(const char *) other
- Compare case sensitive the string with a c-string
- Parameters:
- other - the c-string that should be tested
- Returns:
- the test result (-1, 0, 1)
- - (int) ccompare :(const char *) other :(unsigned long) length
- Compare case sensitive the string with the first number of characters
of a c-string
- Parameters:
- other - the c-string that should be tested
length - the length of the string to be tested
- Returns:
- the test result (-1, 0, 1)
- - (int) icompare :(const char *) other
- Compare case insensitive the string with a c-string
- Parameters:
- other - the c-string that should be compared
- Returns:
- the compare result (-1, 0, 1)
- - (int) icompare :(const char *) other :(unsigned long) length
- Compare case insensitive the string with the first number of characters
of a c-string
- Parameters:
- other - the c-string that should be compared
length - the length of the string to be tested
- Returns:
- the compare result (-1, 0, 1)
- Search and replace methods
- - (unsigned long) count :(const char *) search :(long) from :(long) to
- Count the number of occurrences of the c-string in the string
- Parameters:
- search - the c-string that should be counted
from - the start index
to - the end index (to >= from)
- Returns:
- the number of occurrences
- - (long) index :(const char *) search :(long) from :(long) to
- Return the first index where the search c-string is found
- Parameters:
- search - the c-string that should be searched
from - the start index
to - the end index (to >= from)
- Returns:
- the first index or -1 = not found
- - (DText *) replace :(const char *) old :(const char *) new :(long) max
- Replace in the string the occurrences of old with new, max times
- Parameters:
- old - the c-string that is searched
new - the c-string that is inserted
max - the maximum number of replaces (-1 = all)
- Returns:
- the string object
- - (long) rindex :(const char *) search :(long) from :(long) to
- Return the last index where the search c-string is found
- Parameters:
- search - the c-string that should be searched
from - the start index
to - the end index (to >= from)
- Returns:
- the last index or -1 = not found
generated 05-Nov-2007 by ObjcDoc 3.0.0