Description


Include file: xstring.h

Functions

GetBuffer

Remarks

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

Remarks

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

Return-Value

String as a constant float (double), sometimes a const is required. REMARS Uses standard C-function atof

Remarks

operatorconstint

Return-Value

String as a constant int, sometimes a const is required. Uses standard C-function atoi

Remarks

operatorconstlong

Return-Value

String as a constant long int, sometimes a const is required. REMARS Uses standard C-function atol

Remarks

IsEmpty

Return-Value

TRUE, if the String is empty
BOOL, else

Remarks

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

Remarks

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

Remarks

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

Remarks

(Virtual) Destructor, removes string from memory

Find

Return-Value

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

Remarks

Because some parameters have standard values, you can call this method also with Find(pos, "...").

FindRev

Return-Value

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

Remarks

Because some parameters have standard values, you can call this method also with Find(pos, "...").

Replace

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.

Return-Value

Number of replacements

Remarks

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

Return-Value

Number of removed chars

Remarks

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

Return-Value

Number of removed chars

Remarks

Strip whitespaces ( Space, Tab, Linefeed, Carriage return ) like function "Strip"

At

Return-Value

Returns the char at position inZeroIndex.

Remarks

The same as operator []. The first char has index 0!

GetLength

Remarks

Returns the length of the string!

Left

Return-Value

Returns the first Count chars as a XString from string. Thus, it's equal to Mid(0, nCount).

Remarks

If Count>GetLength(), a copy of the string is returned, if Count is 0, an empty string is returned.

Mid

Return-Value

Returns substring with Count-length from position From in string.

Remarks

If From>GetLength(), an empty string is returned; if From+Count>GetLength(), a string with a length of (GetLength()-From) is returned.

Right

Remarks

What do you think this methods is for? See Left() for details, rigth up!

operator

Return-Value

Returns a pointer to chars.

Remarks

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[]

Return-Value

Returns the char at position inZeroIndex.

Remarks

The same as function At. The first char has index 0!

DelSubString

Remarks

Deletes inCount-chars from inFrom (Zero-Index!).
Deletes the first place occurrence of inSubString

operator+=

Return-Value

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

Remarks

Adds a string

operator=

Return-Value

Returns copy of aString

Remarks

The Sourcestring aString is copied (duplicated) to this-string


This document was generated by Jens von Pilgrim's Autodoc