Strings
Chapter Updated 06/19/25
| Method | Description | Parms |
|---|---|---|
| xbString(xbUInt32 size) xbString(char cIn) xbString(const char *sIn, xbUInt32 ulMaxLen) xbString(const xbString &sIn) xbString(const char *sIn = "") xbString( xbDouble dIn ) | Various constructors. |
cIn - Input character sIn - Pointer to char string ulMaxLen - Max length of input string to use dIn - Double value to convert to a string |
| xbString &operator= (const xbString &sIn) xbString &operator= (const char *sIn) | Assignment operator. | sIn - Input pointer to char string |
| operator const char *() const | * operator returns pointer to string data. | |
| char &operator[](xbUInt32 n) const char &operator[](xbInt32 n) const | [] operator. Returns a character at position n. First position in string is 1 (not 0). | n - Offset ino the string for the byte to retrieve |
| xbString &operator+=(const xbString &s) xbString &operator+=(const char *s) xbString &operator+=(char c) | Append operator. | |
| xbString &operator-=(const xbString &s) xbString &operator-=(const char *s) xbString &operator-=(char c) | Append operator, right trimming both strings. | |
| xbBool operator == ( const xbString& ) const xbBool operator == ( const char * ) const | Equals comparison operator. | |
| xbBool operator != ( const xbString& ) const xbBool operator != ( const char * ) const | Not equals comparison operator. | |
| xbBool operator < ( const xbString& ) const | Less than operator. | |
| xbBool operator > ( const xbString& ) const | Greater than operator. | |
| xbBool operator <= ( const xbString& ) const/td> | Less than or equals operator. | |
| xbBool operator >= ( const xbString& ) const/td> | Greater than or equals operator. | |
| xbString operator-( const xbString &s ) | Concatonate operator. Concatonate left string with right string returning reference to new string. Both strings are trimmed. | |
| xbString operator+( const char *s ) xbString operator+( const xbString &s ) xbString operator+( const char c ) |
Concatonate operator. Concatonates left string with right string returning reference to new string. | |
| xbString &AddBackSlash( char c ) | Add a prefixing back slash to specified characters in the string. | c - Charater to precede with a backslash. |
| xbString &Append(const xbString &s) xbString &Append(const char *s) xbString &Append(const char *s, xbUInt32 ulByteCount ) xbString &Append(char c) | Append data to the string. |
s - Data to append to string. ulByteCnt - Max number of bytes to append to string. c - Char value to append to string. |
| xbString &Assign(const char *srcStr, xbUInt32 ulStartPos, xbUInt32 ulCopyLen ) xbString &Assign(const char *srcStr, xbUInt32 ulStartPos ) xbString &Assign(const xbString &srcStr, xbUInt32 ulStartPos, xbUInt32 ulCopyLen ) xbString &Assign(const xbString &srcStr, xbUInt32 ulStartPos ) | Assign portion of a string. |
srcStr - Source string. ulStartPos - Starting position. The first position is 1. ulCopyLen - Max copy length. |
| xbString Copy() const | Copy a string | |
| xbUInt32 CountChar( char c ) const xbUInt32 CountChar( char c, xbInt16 iOpt ) const |
Count the number of characters in a string. |
c - Character to count. iOpt - Option |
| xbInt16 CvtHexChar( char &cOut ) | Convert a four byte string in the format of 0x00 to a one byte char value. The first four bytes of the string must be in the format 0x00. Anything past the first four bytes is disregarded. | cOut - Output character. |
| xbInt16 CvtHexString( xbString &sOut ) | This routine converts a string of one or more four byte sequences 0x00 to a string of one byte chars. | sOut - Output string. |
| xbInt16 CvtULongLong( xbUInt64 &ullOut ) | Convert string to xbUInt64 number. | ullOut - Output unsigned 64 bit interger. |
| xbInt16 CvtLongLong( xbInt64 &llOut ) | Convert string to xbInt64 number | llOut - Output signed 64 bit interger. |
| void Dump( const char *sTitle ) const void Dump( const char *sTitle, xbInt16 iOption ) const void DumpHex( const char *sTitle ) const void Dump( const xbString &sTitle ) const void Dump( const xbString &sTitle, xbInt16 iOption ) const void DumpHex( const xbString &sTitle ) const |
Dump string contents to stdout. Only available if compile option XB_DEBUG_SUPPORT is on. |
iOption Output option.Mbr>
|
| xbString &ExtractElement(xbString &sIn, char delim, xbUInt32 iCnt, xbInt16 iOpt = 0 ) xbString &ExtractElement(const char *sIn, char delim, xbUInt32 iCnt, xbInt16 iOpt = 0 ) |
Extract an element from a delimited string. | sIn - Input string to extract element from delim - One byte delimiter iCnt - Number of delimiters to skip iOpt - Quote handling option |
| char GetCharacter( xbUInt32 ulPos ) const | Extract character from position ulPos. First position is 1. | ulPos - Position within string of character to extract. |
| xbUInt32 GetLastPos(char c) const xbUInt32 GetLastPos(const char *s) const |
Get last position of element within string. | c - character to retrieve the last position in string for. s - string to retrieve the last position in string for. |
| char GetPathSeparator() const | Returns the path separator. Returns \ for Windows environment. Returns / for *nix environment. | |
| xbUInt32 GetSize() const | ||
| xbBool HasAlphaChars() const | Determine if the string has any alpha characters.
| |
| xbBool IsEmpty() const | Determine if string is empty.
| |
| xbBool IsNull() const | Determine if string is null.
| |
| xbString &Left( xbUInt32 ulLen ) | Retain left part of string, Truncare rightmost excess. | ulLen - New string length. |
| xbUInt32 Len() const |
| |
| xbString &Ltrim() | Left trim whitespace from string. | |
| xbString &Ltrunc( xbUInt32 ulCnt ) | Left truncate string. | ulCnt - Number of bytes to remove from the left. |
| xbString &Mid(xbUInt32 ulPos, xbUInt32 lLen ) | Extract portion of data from string. |
ulStartPos - Starting position. ulTargLen - Length. |
| xbString &PadLeft( char c, xbUInt32 ulLen ) | Left pad string. |
c - Padding character. ulNewLen - New string length. |
| xbString &PadRight( char c, xbUInt32 ulLen ) | Right pad string. |
c - Padding character. ulNewLen - New string length. |
| xbUInt32 Pos(char c, xbUInt32 ulStartPos ) const xbUInt32 Pos(char c) const xbUInt32 Pos(const char *s) const |
Determine position of a given character or string. |
c - Seek character. s - Seek string. ulStartPos - Starting position for search, first position is 1. |
| xbString &PutAt(xbUInt32 ulPos, char c) | Insert character into string. |
ulPos - Insertion position. c - Character to insert. |
| xbString &Remove( xbUInt32 ulPos, xbUInt32 ulN ) | Remove portion of string. |
ulStartPos - Starting position for removal operation. ulDelSize - Size of deletion. |
| xbString &Replace( const char *sReplace, const char *sReplaceWith, xbInt16 iOpt = 0 ) xbString &Replace( const xbString &sReplace, const xbString &sReplaceWith, xbInt16 iOpt = 0 ) xbString &Replace( constxbString &sReplace, const char *sReplaceWith, xbInt16 iOpt = 0 ) xbString &Replace( const char *sReplace, const xbString &sReplaceWith, xbInt16 iOpt = 0 ) |
Replace a value within a string with another value. |
sReplace - Character string to replace. sReplaceWith - Character string to replace with. iOption - Processing option. |
| xbString &Resize( xbUInt32 lSize ) | Resize a string. | ulSize - New string size, including null termination byte. |
| xbString &Rtrim() | Right trim whitespace from string. | |
| xbString &Set( const char *s ) xbString &Set( const xbString &s ) xbString &Set( const char *s, xbUInt32 ulSize ) |
Set the value of the string. |
s - Value to set the string. ulSize - Maximum size of resultant string. |
| xbString &SetNum( xbInt32 lNum ) | Set the string to long integer numeric value. | lNum - Value to set the string. |
| xbString &Sprintf(const char *format, ...) | Example: MyString.Sprintf( "Num: %d Text %s", 100, "test data" )
sFormat - A format specifier. | ... - variables or data values to insert into formatted string. |
| const char *Str() const | Return string data. Returns char * to string data or NULL if string is empty | |
| char *strncpy( char * cDest, xbUInt32 n ) const |
cDest - pointer to destination buffer. n Number of bytes to copy. | |
| xbString &SwapChars( char from, char to ) | Swap characters. |
cFrom - Character to replace. cTo - Character to replace with. |
| xbString &ToLowerCase() | Replace all upper case charaters with lower case characters. | |
| xbString &ToUpperCase() | Replace all lower case charaters with upper case characters. | |
| xbString &Trim() | Right and left trim whitespace from string. | |
| xbBool ValidLogicalValue() const | ||
| xbBool ValidNumericValue() const | This function returns true if the string contains valid numeric data, else returns false. | |
| xbString &ZapChar( char c ) | Remove every instance of specified character from a string. | c - Character to remove from string. |
| xbString &ZapLeadingChar( char c ) | Remove leading character from a string. | c - Character to remove from beginning of string. |
| xbString &ZapTrailingChar( char c ) | Remove trailing character from a string. | c - Character to remove from ending of string. |
| std::ostream& operator<< ( std::ostream& os, const xbString& s ) | Stream insertion operator << |
os - Output stream. s - String to send to output stream |
