Description |
GetBuffer |
Sometimes an int is available for the length..
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!
EXAMPLE
XString a;
double pi=3.14;
sprintf(a.GetBuffer(100), "Pi = %2.3f", pi); a.ReleaseBuffer();
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!!!!!!!!!!
operatorconstdouble |
String as a constant float (double), sometimes a const is required. REMARS Uses standard C-function atof
operatorconstint |
String as a constant int, sometimes a const is required. Uses standard C-function atoi
operatorconstlong |
String as a constant long int, sometimes a const is required. REMARS Uses standard C-function atol
IsEmpty |
TRUE, if the String is empty
BOOL, else
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!
StrCmp |
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
XString |
Constructs a string and casts an int, usefull as caster
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
~XString |
(Virtual) Destructor, removes string from memory
Find |
TRUE, if substring is in string, outPos is the (zero-indexed) position of the substring in string (the first). BOOL, if the substring was not found
Because some parameters have standard values, you can call this method also with Find(pos, "...").
FindRev |
TRUE, if substring is in string, outPos is the (zero-indexed) position of the substring in string (the first). BOOL, if the substring was not found
Because some parameters have standard values, you can call this method also with Find(pos, "...").
Replace |
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.
Number of replacements
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 XSIZE_T-type!).
In this moment I'm working on another Replace-method: Replace(BadEnglish, CorrectEnglish, everywhere in this docu...) ;-)
Strip |
Number of removed chars
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!
StripWhitespaces |
Number of removed chars
Strip whitespaces ( Space, Tab, Linefeed, Carriage return ) like function "Strip"
At |
Returns the char at position inZeroIndex.
The same as operator []. The first char has index 0!
GetLength |
Returns the length of the string!
Left |
Returns the first Count chars as a XString from string. Thus, it's equal to Mid(0, nCount).
If Count>GetLength(), a copy of the string is returned, if Count is 0, an empty string is returned.
Mid |
Returns substring with Count-length from position From in string.
If From>GetLength(), an empty string is returned; if From+Count>GetLength(), a string with a length of (GetLength()-From) is returned.
Right |
What do you think this methods is for? See Left() for details, rigth up!
operator |
Returns a pointer to chars.
Usefull in functions requiering char-pointer like printf (printf("Hallo %s", aString()); ). The method works like Left, so AString(5) returns the first 5 chars.
operator[] |
Returns the char at position inZeroIndex.
The same as function At. The first char has index 0!
DelSubString |
Deletes inCount-chars from inFrom (Zero-Index!).
Deletes the first place occurrence of inSubString
operator+= |
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
Adds a string
operator= |
Returns copy of aString
The Sourcestring aString is copied (duplicated) to this-string