|
public
operator
operator[]
char *m_pszChar
operator char * ) { return m_pszChar
operator const char * ) { return m_pszChar
operator const double )
operator const int )
operator const long )
operator double )
operator int )
operator long )
size_t m_Length
Caster
GetBuffer
ReleaseBuffer
Comperasion
IsEmpty
StrCmp
operator !=
operator <
operator <=
operator ==
operator >
operator >=
Constructor/Destructor
XString
~XString
Enhanced
Find
FindRev
Replace
Strip
Get
At
GetLength
Left
Mid
Right
Set
DelSubString
operator +=
operator =
|
Derrived | : public XCollectable
|
Author: Jens von Pilgrim
Last change: 08.07.1996
|
|
|
Definition | char* operator ( ) ( )
char* operator ( ) ( size_t inCount ) |
Returns | char* |
|
Definition | char operator[] ( size_t inZeroIndex ) |
Returns | char |
|
|
|
|
|
|
|
|
|
|
|
|
This is the most dangerous function, because it allows you access to the heart of XString, the
char-buffer! Don't use this function for dircet manipulations of the buffer! This function has
another job to do!
The job of this method is to work as a caster, when some awefull and dirty C-functions needs a
char-pointer, like sprintf. Size is the size you initialize the string, take care that the size
is great enough!
Don't forget to call the ReleaseBuffer()-Function after GetBuffer()! ReleaseBuffer correct the length
of the string.
The Size is exactly the size of chars in the buffer, the byte for the zero-byte is automatically added!
See the example!
|
Definition | char* GetBuffer ( size_t Size )
char* GetBuffer ( size_t Size=0 )
|
Returns | char*
|
Examples | XString a;
double pi=3.14;
sprintf(a.GetBuffer(100), "Pi = %2.3f", pi); a.ReleaseBuffer();
|
|
After getting the buffer with GetBuffer, and after setting the size of the string to Size, this function
correct the size of the buffer, so that the size of the buffer is equal to the length of the string.
Don't use any other function after GetBuffer, before not calling ReleaseBuffer!!!!!!!!!!
|
Definition | int ReleaseBuffer ( size_t Length )
int ReleaseBuffer ( size_t Length=0 )
|
Returns | int
|
|
|
If the string is not allocated (f.e. a Stringpointer before calling new) is NOT empyt! If
you call any String-Function before calling the Constructor, most functions fail and the program
will exit by a failed assert!
|
Definition | int IsEmpty ( )
|
Returns | int
True, if the String is empty
False, else
|
|
Returns exactly the result from strcmp, usefull if other function needs this result.
The Result is
== 0: this string == inThen
< 0: this string < inThen
> 0: this string > inThen
|
Definition | int StrCmp ( const XString& inThen )
virtual int StrCmp ( const XString& inThen )
|
Returns | int
|
|
Compares one string with another, returns TRUE if both strings are not equal, else FALSE
|
Definition | virtual int operator != ( const XString& inThen )
|
Returns | int
|
|
Compares one string with another, returns TRUE if the first string is less then the second string, else FALSE
|
Definition | virtual int operator < ( const XString& inThen )
|
Returns | int
|
|
Compares one string with another, returns TRUE if the first string is less/equal, else FALSE
|
Definition | virtual int operator <= ( const XString& inThen )
|
Returns | int
|
|
Overload for Charpointer, because this case is often used!
Compares one string with another, returns TRUE if both strings are equal, else FALSE
|
Definition | virtual int operator == ( const XString& inThen )
virtual int operator == ( const char* inCharPtr )
|
Returns | int
|
|
Compares one string with another, returns TRUE if the first string is greater then the second string, else FALSE
|
Definition | virtual int operator > ( const XString& inThen )
|
Returns | int
|
|
Compares one string with another, returns TRUE if the first string is greater/equal, else FALSE
|
Definition | virtual int operator >= ( const XString& inThen )
|
Returns | int
|
|
|
Constructs a string and casts an int, usefull as caster
Constructs a string with first char == aChar
Constructs a string as a copy of pszChar, usefull as caster
Constructs a string as a copy of 'aString'
Constructs an empty string
|
Definition | XString ( long aNumber, int Radix )
XString ( int aNumber, int Radix )
XString ( char aChar )
XString ( char* pszChar, int DUPLICATE )
XString ( char* pszChar )
XString ( const XString& aString )
XString ( )
XString ( long aNumber, int Radix = 10 )
XString ( int aNumber, int Radix = 10 )
|
Returns | -
|
|
(Virtual) Destructor, removes string from memory
|
Definition | ~XString ( )
virtual ~XString ( )
|
Returns | -
|
|
|
Because some parameters have standard values, you can call this method also with Find(pos, "...").
|
Definition | BOOL Find ( size_t& outPos, const XString& SubString, size_t From, size_t inTo )
BOOL Find ( size_t& outPos, const XString& SubString, size_t From = 0, size_t inTo = 0 )
|
Returns | BOOL
TRUE, if substring is in string, outPos is the (zero-indexed) position of the substring in string (the first). FALSE, if the substring was not found
|
|
Because some parameters have standard values, you can call this method also with Find(pos, "...").
|
Definition | BOOL FindRev ( size_t& outPos, const XString& SubString, size_t From, size_t inTo )
BOOL FindRev ( size_t& outPos, const XString& SubString, size_t From = 0, size_t inTo = 0 )
|
Returns | BOOL
TRUE, if substring is in string, outPos is the (zero-indexed) position of the substring in string (the first). FALSE, if the substring was not found
|
|
This is one of the most powerful methods of XString. It works as the Search-Replace-Function of you editor.
Of course, the search- and the replace-substring must NOT have the same length! The methods is working very fast,
because it first searches the substring, allocs new memory by calculing the new size, and then a new string is build.
When the new string is build, there is no more search necessary (only if the replacement-string is greater then the
searchstring and the length of the searchstring is smaller then the size of a size_t-type!).
In this moment I'm working at another Replace-method: Replace(BadEnglish, CorrectEnglish, everywhere in this docu...) ;-)
|
Definition | int Replace ( XString inSearch, XString inReplace, int inTimes, size_t inFrom, size_t inTo )
int Replace ( XString inSearch, XString inReplace, int inTimes=XALL, size_t inFrom=0, size_t inTo=0 )
|
Parameters | inSearch is the substring to search, inReplace is the string wich replaces the searchstring, the substring
is max. inTimes replaced and inFrom and inTo mark the scope.
|
Returns | int
Number of replacements
|
|
Strip removes all inChars at the beginning (inWhere=XLEFT), at the end (inWhere=XRIGHT), at both ends
(inWhere=XBOTH) or removes all inChars (inWhere=XALL) from the string!
If you have to remove substring, use Replace() instead!
|
Definition | int Strip ( int inWhere, char inChar )
int Strip ( int inWhere = XBOTH, char inChar = ' ' )
|
Returns | int
Number of removed chars
|
|
|
The same as operator []. The first char has index 0!
|
Definition | char At ( size_t inZeroIndex )
|
Returns | char
Returns the char at position inZeroIndex.
|
|
Returns the length of the string!
|
Definition | size_t GetLength ( )
virtual size_t GetLength ( )
|
Returns | size_t
|
|
If Count>GetLength(), a copy of the string is returned, if Count is 0, an empty string is returned.
|
Definition | XString Left ( size_t Count )
virtual XString Left ( size_t Count )
|
Returns | XString
Returns the first Count chars as a XString from string. Thus, it's equal to Mid(0, nCount).
|
|
If From>GetLength(), an empty string is returned; if From+Count>GetLength(),
a string with a length of (GetLength()-From) is returned.
|
Definition | XString Mid ( size_t From, size_t Count )
virtual XString Mid ( size_t From, size_t Count )
|
Returns | XString
Returns substring with Count-length from position From in string.
|
|
What do you think this methods is for? See Left() for details, rigth up!
|
Definition | XString Right ( size_t Count )
virtual XString Right ( size_t Count )
|
Returns | XString
|
|
|
Deletes inCount-chars from inFrom (Zero-Index!).
Deletes the first place occurrence of inSubString
|
Definition | int DelSubString ( size_t inFrom, size_t inCount=1 )
int DelSubString ( XString inSubString )
|
Returns | int
|
|
Adds a string
|
Definition | XString operator += ( const char* Str )
XString operator += ( const XString& Str )
|
Returns | XString
Returns thisString+Str
REMARS Concats string with another string Str and saves the result in string.
Like this:
XString a,b,c;
...
a=(b+=c);
Result: (a==b) = TRUE
|
|
The Sourcestring aString is copied (duplicated) to this-string
|
Definition | XString operator = ( const XString& aString )
|
Returns | XString
Returns copy of aString
|