String class supporting common string operations. More...
Public Member Functions | |
| BString () | |
| Creates an empty BString. | |
| BString (const char *string) | |
| Creates and initializes a BString from a string. | |
| BString (const BString &string) | |
| Creates and initializes a BString from another BString. | |
| BString (const char *string, int32 maxLength) | |
| Creates and initializes a BString from a string up to maxLength characters. | |
| ~BString () | |
| Free all resources associated with the object. | |
Assignment Methods | |
To assign a string to the object, thus overriding the previous string that was stored, there are different methods to use. Use one of the overloaded Adopt() methods to take over data from another object. Use one of the assignment operators to copy data from another object, or use one of the SetTo() methods for more advanced copying. | |
| BString & | operator= (const BString &string) |
| Re-initialize the object to a copy of the data of a BString. | |
| BString & | operator= (const char *string) |
| Re-initialize the object to a copy of the data of a string. | |
| BString & | operator= (char c) |
| Re-initialize the object to a character. | |
| BString & | SetTo (const char *string) |
| Re-initialize the object to a copy of the data of a string. | |
| BString & | SetTo (const char *string, int32 maxLength) |
| Re-initialize the object to a copy of the data of a string. | |
| BString & | SetTo (const BString &string) |
| Re-initialize the object to a copy of the data of a BString. | |
| BString & | Adopt (BString &from) |
| Adopt the data of the given BString object. | |
| BString & | SetTo (const BString &string, int32 maxLength) |
| Re-initialize the string to a copy of the given BString object. | |
| BString & | Adopt (BString &from, int32 maxLength) |
| Adopt the data of the given BString object up to maxLength characters. | |
| BString & | SetTo (char c, int32 count) |
| Set the timezone to another code. | |
| BString & | SetToChars (const char *string, int32 charCount) |
| Undocumented. | |
| BString & | SetToChars (const BString &string, int32 charCount) |
| Undocumented. | |
| BString & | AdoptChars (BString &from, int32 charCount) |
| Undocumented. | |
| BString & | SetToFormat (const char *format,...) |
| Undocumented. | |
Substring Copying | |
| BString & | CopyInto (BString &into, int32 fromOffset, int32 length) const |
| Copy the object's data (or part of it) into another BString. | |
| void | CopyInto (char *into, int32 fromOffset, int32 length) const |
| Copy the BString data (or part of it) into the supplied buffer. | |
| BString & | CopyCharsInto (BString &into, int32 fromCharOffset, int32 charCount) const |
| Undocumented. | |
| bool | CopyCharsInto (char *into, int32 *intoLength, int32 fromCharOffset, int32 charCount) const |
| Undocumented. | |
Appending Methods | |
| BString & | operator+= (const BString &string) |
| Append the given string to the object. | |
| BString & | operator+= (const char *string) |
| Append the given string to the object. | |
| BString & | operator+= (char c) |
| Append the given character to the object. | |
| BString & | Append (const BString &string) |
| Append the given string to the object. | |
| BString & | Append (const char *string) |
| Append the given string to the object. | |
| BString & | Append (const BString &string, int32 length) |
| Append a part of the given BString to the object. | |
| BString & | Append (const char *string, int32 length) |
| Append a part of the given string to the object. | |
| BString & | Append (char c, int32 count) |
| Append the given character repeatedly to the object. | |
| BString & | AppendChars (const BString &string, int32 charCount) |
| undocumented | |
| BString & | AppendChars (const char *string, int32 charCount) |
| undocumented | |
Prepending Methods | |
| BString & | Prepend (const char *string) |
| Prepend the given string to the object. | |
| BString & | Prepend (const BString &string) |
| Prepend the given BString to the object. | |
| BString & | Prepend (const char *string, int32 length) |
| Prepend the given string to the object. | |
| BString & | Prepend (const BString &string, int32 length) |
| Prepend the given BString to the object. | |
| BString & | Prepend (char c, int32 count) |
| Prepend the given character repeatedly to the object. | |
| BString & | PrependChars (const char *string, int32 charCount) |
| undocumented | |
| BString & | PrependChars (const BString &string, int32 charCount) |
| undocumented | |
Inserting Methods | |
| BString & | Insert (const char *string, int32 position) |
| Insert the given string at the given position into the object's data. | |
| BString & | Insert (const char *string, int32 length, int32 position) |
| Inserts the given string at the given position into the object's data. | |
| BString & | Insert (const char *string, int32 fromOffset, int32 length, int32 position) |
| Insert the given string at the given position into the object's data. | |
| BString & | Insert (const BString &string, int32 position) |
| Insert the given BString at the given position into the object's data. | |
| BString & | Insert (const BString &string, int32 length, int32 position) |
| Insert the given BString at the given position into the object's data. | |
| BString & | Insert (const BString &string, int32 fromOffset, int32 length, int32 position) |
| Insert the given string at the given position into the object's data. | |
| BString & | Insert (char c, int32 count, int32 position) |
| Insert the given character repeatedly at the given position into the object's data. | |
| BString & | InsertChars (const char *string, int32 charPosition) |
| Undocumented. | |
| BString & | InsertChars (const char *string, int32 charCount, int32 charPosition) |
| Undocumented. | |
| BString & | InsertChars (const char *string, int32 fromCharOffset, int32 charCount, int32 charPosition) |
| Undocumented. | |
| BString & | InsertChars (const BString &string, int32 charPosition) |
| Undocumented. | |
| BString & | InsertChars (const BString &string, int32 charCount, int32 charPosition) |
| Undocumented. | |
| BString & | InsertChars (const BString &string, int32 fromCharOffset, int32 charCount, int32 charPosition) |
| Undocumented. | |
Removing Methods | |
| BString & | Truncate (int32 newLength, bool lazy=true) |
| Truncate the string to the new length. | |
| BString & | TruncateChars (int32 newCharCount, bool lazy=true) |
| Undocumented. | |
| BString & | Remove (int32 from, int32 length) |
| Remove some bytes, starting at the given offset. | |
| BString & | RemoveChars (int32 fromCharOffset, int32 charCount) |
| Undocumented. | |
| BString & | RemoveFirst (const BString &string) |
| Remove the first occurrence of the given BString. | |
| BString & | RemoveLast (const BString &string) |
| Remove the last occurrence of the given BString. | |
| BString & | RemoveAll (const BString &string) |
| Remove all occurrences of the given BString. | |
| BString & | RemoveFirst (const char *string) |
| Remove the first occurrence of the given string. | |
| BString & | RemoveLast (const char *string) |
| Remove the last occurrence of the given string. | |
| BString & | RemoveAll (const char *string) |
| Remove all occurrences of the given string. | |
| BString & | RemoveSet (const char *setOfBytesToRemove) |
| Remove all the characters specified. | |
| BString & | RemoveCharsSet (const char *setOfCharsToRemove) |
| Undocumented. | |
| BString & | MoveInto (BString &into, int32 from, int32 length) |
| Move the BString data (or part of it) into another BString. | |
| void | MoveInto (char *into, int32 from, int32 length) |
| Move the BString data (or part of it) into the given buffer. | |
| BString & | MoveCharsInto (BString &into, int32 fromCharOffset, int32 charCount) |
| Undocumented. | |
| bool | MoveCharsInto (char *into, int32 *intoLength, int32 fromCharOffset, int32 charCount) |
| Undocumented. | |
Comparison Methods | |
There are two different comparison methods. First of all there is the whole range of operators that return a boolean value, secondly there are methods that return an integer value, both case sensitive and case insensitive. There are also global comparison operators and global compare functions. You might need these in case you have a sort routine that takes a generic comparison function, such as BList::SortItems(). See the String.h documentation file to see the specifics, though basically there are the same as implemented in this class. | |
| bool | operator< (const BString &string) const |
| Lexicographically compare if this string is less than a given string. | |
| bool | operator<= (const BString &string) const |
| Lexicographically compare if this string is less than or equal to a given string. | |
| bool | operator== (const BString &string) const |
| Lexicographically compare if this string is equal to a given string. | |
| bool | operator>= (const BString &string) const |
| Lexicographically compare if this string is more than or equal to a given string. | |
| bool | operator> (const BString &string) const |
| Lexicographically compare if this string is more than a given string. | |
| bool | operator!= (const BString &string) const |
| Lexicographically compare if this string is not equal to a given string. | |
| bool | operator< (const char *string) const |
| Lexicographically compare if this string is less than a given string. | |
| bool | operator<= (const char *string) const |
| Lexicographically compare if this string is less than or equal to a given string. | |
| bool | operator== (const char *string) const |
| Lexicographically compare if this string is equal to a given string. | |
| bool | operator>= (const char *string) const |
| Lexicographically compare if this string is more than or equal to a given string. | |
| bool | operator> (const char *string) const |
| Lexicographically compare if this string is more than a given string. | |
| bool | operator!= (const char *string) const |
| Lexicographically compare if this string is not equal to a given string. | |
| operator const char * () const | |
| Undocumented. | |
| int | Compare (const BString &string) const |
| Lexicographically compare this string to another. | |
| int | Compare (const char *string) const |
| Lexicographically compare this string to another. | |
| int | Compare (const BString &string, int32 length) const |
| Lexicographically compare a number of characters of a string to another. | |
| int | Compare (const char *string, int32 length) const |
| Lexicographically compare a number of characters of a string to another. | |
| int | CompareChars (const BString &string, int32 charCount) const |
| Undocumented. | |
| int | CompareChars (const char *string, int32 charCount) const |
| Undocumented. | |
| int | ICompare (const BString &string) const |
| Lexicographically compare a string to another in a case-insensitive way. | |
| int | ICompare (const char *string) const |
| Lexicographically compare this string to another in a case-insensitive way. | |
| int | ICompare (const BString &string, int32 length) const |
| Lexicographically compare a number of characters of this string to another. | |
| int | ICompare (const char *string, int32 length) const |
| Lexicographically compare a number of characters of this string to another. | |
Searching Methods | |
| int32 | FindFirst (const BString &string) const |
| Find the first occurrence of the given BString. | |
| int32 | FindFirst (const char *string) const |
| Find the first occurrence of the given string. | |
| int32 | FindFirst (const BString &string, int32 fromOffset) const |
| Find the first occurrence of the given BString, starting from the given offset. | |
| int32 | FindFirst (const char *string, int32 fromOffset) const |
| Find the first occurrence of the given string, starting from the given offset. | |
| int32 | FindFirst (char c) const |
| Find the first occurrence of the given character. | |
| int32 | FindFirst (char c, int32 fromOffset) const |
| Find the first occurrence of the given character, starting from the given offset. | |
| int32 | FindFirstChars (const BString &string, int32 fromCharOffset) const |
| Undocumented. | |
| int32 | FindFirstChars (const char *string, int32 fromCharOffset) const |
| Undocumented. | |
| int32 | FindLast (const BString &string) const |
| Find the last occurrence of the given BString. | |
| int32 | FindLast (const char *string) const |
| Find the last occurrence of the given string. | |
| int32 | FindLast (const BString &string, int32 beforeOffset) const |
| Find the last occurrence of the given BString, starting from the given offset, and going backwards. | |
| int32 | FindLast (const char *string, int32 beforeOffset) const |
| Find the last occurrence of the given string, starting from the given offset, and going backwards. | |
| int32 | FindLast (char c) const |
| Find the last occurrence of the given character. | |
| int32 | FindLast (char c, int32 beforeOffset) const |
| Find the last occurrence of the given character, starting from the given offset and going backwards. | |
| int32 | FindLastChars (const BString &string, int32 beforeCharOffset) const |
| Undocumented. | |
| int32 | FindLastChars (const char *string, int32 beforeCharOffset) const |
| Undocumented. | |
| int32 | IFindFirst (const BString &string) const |
| Find the first occurrence of the given BString case-insensitively. | |
| int32 | IFindFirst (const char *string) const |
| Find the first occurrence of the given BString case-insensitively. | |
| int32 | IFindFirst (const BString &string, int32 fromOffset) const |
| Find the first occurrence of the given BString case-insensitively, starting from the given offset. | |
| int32 | IFindFirst (const char *string, int32 fromOffset) const |
| Find the first occurrence of the given string case-insensitively, starting from the given offset. | |
| int32 | IFindLast (const BString &string) const |
| Find the last occurrence of the given BString case-insensitively. | |
| int32 | IFindLast (const char *string) const |
| Find the last occurrence of the given string case-insensitively. | |
| int32 | IFindLast (const BString &string, int32 beforeOffset) const |
| Find the last occurrence of the given BString case-insensitively, starting from the given offset, and going backwards. | |
| int32 | IFindLast (const char *string, int32 beforeOffset) const |
| Find the last occurrence of the given string case-insensitively, starting from the given offset, and going backwards. | |
Replacing Methods | |
| BString & | ReplaceFirst (char replaceThis, char withThis) |
| Replace the first occurrence of a character with another character. | |
| BString & | ReplaceLast (char replaceThis, char withThis) |
| Replace the last occurrence of a character with another character. | |
| BString & | ReplaceAll (char replaceThis, char withThis, int32 fromOffset=0) |
| Replace all occurrences of a character with another character. | |
| BString & | Replace (char replaceThis, char withThis, int32 maxReplaceCount, int32 fromOffset=0) |
| Replace a number of occurrences of a character with another character. | |
| BString & | ReplaceFirst (const char *replaceThis, const char *withThis) |
| Replace the first occurrence of a string with another string. | |
| BString & | ReplaceLast (const char *replaceThis, const char *withThis) |
| Replace the last occurrence of a string with another string. | |
| BString & | ReplaceAll (const char *replaceThis, const char *withThis, int32 fromOffset=0) |
| Replace all occurrences of a string with another string. | |
| BString & | Replace (const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromOffset=0) |
| Replace a number of occurrences of a string with another string. | |
| BString & | ReplaceAllChars (const char *replaceThis, const char *withThis, int32 fromCharOffset) |
| Undocumented. | |
| BString & | ReplaceChars (const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromCharOffset) |
| Undocumented. | |
| BString & | IReplaceFirst (char replaceThis, char withThis) |
| Replace the first occurrence of a character with another character. Case insensitive. | |
| BString & | IReplaceLast (char replaceThis, char withThis) |
| Replace the last occurrence of a character with another character. Case-insensitive. | |
| BString & | IReplaceAll (char replaceThis, char withThis, int32 fromOffset=0) |
| Replace all occurrences of a character with another character. Case-insensitive. | |
| BString & | IReplace (char replaceThis, char withThis, int32 maxReplaceCount, int32 fromOffset=0) |
| Replace a number of occurrences of a character with another character. Case-insensive. | |
| BString & | IReplaceFirst (const char *replaceThis, const char *withThis) |
| Replace the first occurrence of a string with another string. Case-insensitive. | |
| BString & | IReplaceLast (const char *replaceThis, const char *withThis) |
| Replace the last occurrence of a string with another string. Case-insensitive. | |
| BString & | IReplaceAll (const char *replaceThis, const char *withThis, int32 fromOffset=0) |
| Replace all occurrences of a string with another string. Case-insensitive. | |
| BString & | IReplace (const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromOffset=0) |
| Replace a number of occurrences of a string with another string. Case-insensitive. | |
| BString & | ReplaceSet (const char *setOfBytes, char with) |
| Replaces characters that are in a certain set with a chosen character. | |
| BString & | ReplaceSet (const char *setOfBytes, const char *with) |
| Replaces characters that are in a certain set with a chosen string. | |
| BString & | ReplaceCharsSet (const char *setOfChars, const char *with) |
| Undocumented. | |
Character Access | |
| char | operator[] (int32 index) const |
| Returns the character in the string at the given offset. | |
| char & | operator[] (int32 index) |
| Return a reference to the data at the given offset. | |
| char | ByteAt (int32 index) const |
| Returns the character in the string at the given offset. | |
| const char * | CharAt (int32 charIndex, int32 *bytes=NULL) const |
| Undocumented. | |
| bool | CharAt (int32 charIndex, char *buffer, int32 *bytes) const |
| Undocumented. | |
Low-Level Manipulation | |
| char * | LockBuffer (int32 maxLength) |
| Locks the buffer and return the internal string for manipulation. | |
| BString & | UnlockBuffer (int32 length=-1) |
| Unlocks the buffer after you are done with lowlevel manipulation. | |
Case Manipulation | |
| BString & | ToLower () |
| Convert the BString to lowercase. | |
| BString & | ToUpper () |
| Convert the BString to uppercase. | |
| BString & | Capitalize () |
| Convert the first character to uppercase, rest to lowercase. | |
| BString & | CapitalizeEachWord () |
| Convert the first character of every word to uppercase, rest to lowercase. | |
Escaping and De-escaping Methods | |
This class contains some methods to help you with escaping and de-escaping certain characters. Note that this is the C-style of escaping, where you place a character before the character that is to be escaped, and not HTML style escaping, where certain characters are replaced by something else. | |
| BString & | CharacterEscape (const char *original, const char *setOfCharsToEscape, char escapeWith) |
| Escape selected characters on a given string. | |
| BString & | CharacterEscape (const char *setOfCharsToEscape, char escapeWith) |
| Escape selected characters of this string. | |
| BString & | CharacterDeescape (const char *original, char escapeChar) |
| Remove the character to escape with from a given string. | |
| BString & | CharacterDeescape (char escapeChar) |
| Remove the character to escape with from this string. | |
Trimming methods | |
| BString & | Trim () |
| Undocumented. | |
Simple sprintf Replacement Methods | |
These methods may be slower than sprintf(), but they are overflow safe. | |
| BString & | operator<< (const char *string) |
| Append the string string. | |
| BString & | operator<< (const BString &string) |
| Append the BString string. | |
| BString & | operator<< (char c) |
Append the char c. | |
| BString & | operator<< (bool value) |
Append the boolean value to the string. | |
| BString & | operator<< (int value) |
Convert the int value to a string and append it. | |
| BString & | operator<< (unsigned int value) |
Convert the unsigned int value to a string and append it. | |
| BString & | operator<< (unsigned long value) |
Convert the unsigned long value to a string and append it. | |
| BString & | operator<< (long value) |
Convert the long value to a string and append it. | |
| BString & | operator<< (unsigned long long value) |
Convert the unsigned long long value to a string and append it. | |
| BString & | operator<< (long long value) |
Convert the long long value to a string and append it. | |
| BString & | operator<< (float value) |
Convert the float value to a string and append it. | |
| BString & | operator<< (double value) |
Convert the double value to a string and append it. | |
Access Methods | |
| const char * | String () const |
Return a pointer to the object string, NUL terminated. | |
| int32 | Length () const |
| Get the length of the string in bytes. | |
| int32 | CountChars () const |
| Returns the length of the object measured in characters. | |
| int32 | CountBytes (int32 fromCharOffset, int32 charCount) const |
| Count the number of bytes starting from a specified character. | |
| bool | IsEmpty () const |
| Check whether the string is empty. | |
| uint32 | HashValue () const |
| Return a hash value for the current string. | |
| static uint32 | HashValue (const char *string) |
Return the hash value of a specified string. | |
String class supporting common string operations.
BString is a string allocation and manipulation class. The object takes care to allocate and free memory for you, so it will always be "big enough" to store your strings.
While BString is in essence a wrapper around a byte-array, which can always be accessed with the BString::String() method, it does have some understanding of UTF-8 and it can be used for the manipulation of UTF-8 strings. For all operations that perform on bytes, there is an equivalent that operates on UTF-8 strings. See for example the BString::CopyInto() and BString::CopyCharsInto() methods. The main difference is that if there are any position argumens, the regular method counts the bytes and the Chars methods counts characters.
| BString::BString | ( | const char * | string, |
| int32 | maxLength | ||
| ) |
Creates and initializes a BString from a string up to maxLength characters.
If maxLength is greater than the length of the source string then the entire source string is copied. If maxLength is less than or equal to 0 then the result is an empty BString.
| BString::~BString | ( | ) |
Free all resources associated with the object.
The destructor also frees the internal buffer associated with the string.
Adopt the data of the given BString object.
This method adopts the data from a BString.
NULL string. So if the from object was created on the heap, you need to clean it up yourself.| from | The string object to adopt. |
*this.Append the given string to the object.
| string | The string to append |
*this.| BString & BString::Append | ( | const char * | str | ) | [inline] |
Append the given string to the object.
This method calls operator+=(const char *str).
References operator+=().
Append a part of the given BString to the object.
| string | The BString to append. |
| length | The maximum number ofbytes to get from the original object. |
*this.| BString & BString::Append | ( | const char * | str, |
| int32 | length | ||
| ) |
Append a part of the given string to the object.
| str | A pointer to the string to append. |
| length | The maximum bytes to get from the original string. |
*this.| BString & BString::Append | ( | char | c, |
| int32 | count | ||
| ) |
Append the given character repeatedly to the object.
| c | The character to append. |
| count | The number of times this character should be appended. |
*this.| char BString::ByteAt | ( | int32 | index | ) | const [inline] |
Returns the character in the string at the given offset.
This function can be used to read a single byte.
| index | The index (zero-based) of the byte to get. |
References Length().
| BString & BString::Capitalize | ( | ) |
Convert the first character to uppercase, rest to lowercase.
*this. | BString & BString::CapitalizeEachWord | ( | ) |
Convert the first character of every word to uppercase, rest to lowercase.
Converts the first character of every "word" (series of alphabetical characters separated by non alphabetical characters) to uppercase, and the rest to lowercase.
*this. | BString & BString::CharacterDeescape | ( | const char * | original, |
| char | escapeChar | ||
| ) |
Remove the character to escape with from a given string.
This version sets itself to the string supplied in the original parameter, and then removes the escape characters.
| original | The string to be escaped. |
| escapeChar | The character that was used to escape with. |
*this.| BString & BString::CharacterDeescape | ( | char | escapeChar | ) |
Remove the character to escape with from this string.
| escapeChar | The character that was used to escape with. |
*this.| BString & BString::CharacterEscape | ( | const char * | original, |
| const char * | setOfCharsToEscape, | ||
| char | escapeWith | ||
| ) |
Escape selected characters on a given string.
This version sets itself to the string supplied in the original paramater, and then escapes the selected characters with a supplied character.
| original | The string to be escaped. |
| setOfCharsToEscape | The set of characters that need to be escaped. |
| escapeWith | The character to escape with. |
*this.| BString & BString::CharacterEscape | ( | const char * | setOfCharsToEscape, |
| char | escapeWith | ||
| ) |
Escape selected characters of this string.
| setOfCharsToEscape | The set of characters that need to be escaped. |
| escapeWith | The character to escape with. |
*this.| int BString::Compare | ( | const BString & | string | ) | const |
Lexicographically compare this string to another.
| string | The string to compare to. |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int BString::Compare | ( | const char * | string | ) | const |
Lexicographically compare this string to another.
| string | The string to compare to. |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int BString::Compare | ( | const BString & | string, |
| int32 | length | ||
| ) | const |
Lexicographically compare a number of characters of a string to another.
| string | The string to compare to. |
| length | The number of characters to compare |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int BString::Compare | ( | const char * | string, |
| int32 | length | ||
| ) | const |
Lexicographically compare a number of characters of a string to another.
| string | The string to compare to. |
| length | The number of characters to compare. |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
Copy the object's data (or part of it) into another BString.
This methods makes sure you don't copy more bytes than are available in the string. If the length exceeds the length of the string, it only copies the number of characters that are actually available.
| into | The BString to where to copy the object. |
| fromOffset | The (zero-based) offset where to begin the copy. |
| length | The amount of bytes to copy. |
into parameter. | void BString::CopyInto | ( | char * | into, |
| int32 | fromOffset, | ||
| int32 | length | ||
| ) | const |
Copy the BString data (or part of it) into the supplied buffer.
This methods makes sure you don't copy more bytes than are available in the string. If the length exceeds the length of the string, it only copies the number of characters that are actually available.
It's up to you to make sure your buffer is large enough.
| into | The buffer where to copy the object. |
| fromOffset | The (zero-based) offset where to begin the copy. |
| length | The amount of bytes to copy. |
| int32 BString::CountBytes | ( | int32 | fromCharOffset, |
| int32 | charCount | ||
| ) | const |
Count the number of bytes starting from a specified character.
BString is somewhat aware of UTF8 characters, which can take up more than one byte. With this method you can count the number of bytes a subset of the string contains.
| fromCharOffset | The index of the character (not the byte!) from which to start the count |
| charCount | The number of characters to count |
| int32 BString::CountChars | ( | ) | const |
| int32 BString::FindFirst | ( | const BString & | string | ) | const |
| int32 BString::FindFirst | ( | const char * | string | ) | const |
Find the first occurrence of the given string.
| string | The string to search for. |
| B_BAD_VALUE | The string pointer is invalid. |
| B_ERROR | Could not find string. |
| int32 BString::FindFirst | ( | const BString & | string, |
| int32 | fromOffset | ||
| ) | const |
Find the first occurrence of the given BString, starting from the given offset.
| string | The BString to search for. |
| fromOffset | The offset where to start the search. |
| B_ERROR | Could not find string. |
| int32 BString::FindFirst | ( | const char * | string, |
| int32 | fromOffset | ||
| ) | const |
Find the first occurrence of the given string, starting from the given offset.
| string | The string to search for. |
| fromOffset | The offset where to start the search. |
| B_BAD_VALUE | The string pointer is invalid. |
| B_ERROR | Could not find string. |
| int32 BString::FindFirst | ( | char | c | ) | const |
Find the first occurrence of the given character.
| c | The character to search for. |
| B_ERROR | Could not find c. |
| int32 BString::FindFirst | ( | char | c, |
| int32 | fromOffset | ||
| ) | const |
Find the first occurrence of the given character, starting from the given offset.
| c | The character to search for. |
| fromOffset | The offset where to start the search. |
| B_ERROR | Could not find c. |
| int32 BString::FindLast | ( | const BString & | string | ) | const |
| int32 BString::FindLast | ( | const char * | string | ) | const |
Find the last occurrence of the given string.
| string | The string to search for. |
| B_BAD_VALUE | The string pointer is invalid. |
| B_ERROR | Could not find string. |
/*!
| int32 BString::FindLast | ( | const BString & | string, |
| int32 | beforeOffset | ||
| ) | const |
Find the last occurrence of the given BString, starting from the given offset, and going backwards.
| string | The BString to search for. |
| beforeOffset | The offset where to start the search. |
| B_ERROR | Could not find string. |
| int32 BString::FindLast | ( | const char * | string, |
| int32 | beforeOffset | ||
| ) | const |
Find the last occurrence of the given string, starting from the given offset, and going backwards.
| string | The string to search for. |
| beforeOffset | The offset where to start the search. |
| B_BAD_VALUE | The string pointer is invalid. |
| B_ERROR | Could not find string. |
| int32 BString::FindLast | ( | char | c | ) | const |
Find the last occurrence of the given character.
| c | The character to search for. |
| B_ERROR | Could not find c. |
| int32 BString::FindLast | ( | char | c, |
| int32 | beforeOffset | ||
| ) | const |
Find the last occurrence of the given character, starting from the given offset and going backwards.
| c | The character to search for. |
| beforeOffset | The offset where to start the search. |
| B_ERROR | Could not find c. |
| uint32 BString::HashValue | ( | ) | const [inline] |
Return a hash value for the current string.
References String().
| static uint32 BString::HashValue | ( | const char * | string | ) | [static] |
Return the hash value of a specified string.
This allows you to use the BString::HashValue() method on any arbitrary string.
| string | The string that you want to have hashed. |
| int BString::ICompare | ( | const BString & | string | ) | const |
Lexicographically compare a string to another in a case-insensitive way.
| string | The string to compare to. |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int BString::ICompare | ( | const char * | string | ) | const |
Lexicographically compare this string to another in a case-insensitive way.
| string | The string to compare to. |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int BString::ICompare | ( | const BString & | string, |
| int32 | length | ||
| ) | const |
Lexicographically compare a number of characters of this string to another.
| string | The string to compare to. |
| length | The number of characters to compare |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int BString::ICompare | ( | const char * | string, |
| int32 | length | ||
| ) | const |
Lexicographically compare a number of characters of this string to another.
| string | The string to compare to. |
| length | The number of characters to compare |
| >0 | The object sorts lexicographically after string. |
| =0 | The object is equal to string. |
| <0 | The object sorts lexicographically before string. |
| int32 BString::IFindFirst | ( | const BString & | string | ) | const |
Find the first occurrence of the given BString case-insensitively.
| int32 BString::IFindFirst | ( | const char * | string | ) | const |
Find the first occurrence of the given BString case-insensitively.
| int32 BString::IFindFirst | ( | const BString & | string, |
| int32 | fromOffset | ||
| ) | const |
Find the first occurrence of the given BString case-insensitively, starting from the given offset.
| int32 BString::IFindFirst | ( | const char * | string, |
| int32 | fromOffset | ||
| ) | const |
Find the first occurrence of the given string case-insensitively, starting from the given offset.
| int32 BString::IFindLast | ( | const BString & | string | ) | const |
Find the last occurrence of the given BString case-insensitively.
| int32 BString::IFindLast | ( | const char * | string | ) | const |
Find the last occurrence of the given string case-insensitively.
| int32 BString::IFindLast | ( | const BString & | string, |
| int32 | beforeOffset | ||
| ) | const |
Find the last occurrence of the given BString case-insensitively, starting from the given offset, and going backwards.
| int32 BString::IFindLast | ( | const char * | string, |
| int32 | beforeOffset | ||
| ) | const |
Find the last occurrence of the given string case-insensitively, starting from the given offset, and going backwards.
| BString & BString::Insert | ( | const char * | string, |
| int32 | position | ||
| ) |
Insert the given string at the given position into the object's data.
| string | A pointer to the string to insert. |
| position | The offset in bytes into the BString's data where to insert the string. |
*this.| BString & BString::Insert | ( | const char * | string, |
| int32 | length, | ||
| int32 | position | ||
| ) |
Inserts the given string at the given position into the object's data.
| string | A pointer to the string to insert. |
| length | The amount of bytes to insert. |
| position | The offset in bytes into the BString's data where to insert the string. |
*this.| BString & BString::Insert | ( | const char * | string, |
| int32 | fromOffset, | ||
| int32 | length, | ||
| int32 | position | ||
| ) |
Insert the given string at the given position into the object's data.
| string | A pointer to the string to insert. |
| fromOffset | The offset in the string that is to be inserted |
| length | The amount of bytes to insert. |
| position | The offset in bytes into the BString's data where to insert the string. |
*this.| BString & BString::Insert | ( | const BString & | string, |
| int32 | fromOffset, | ||
| int32 | length, | ||
| int32 | position | ||
| ) |
Insert the given string at the given position into the object's data.
| string | The BString object to insert. |
| fromOffset | The offset in the string that is to be inserted |
| length | The amount of bytes to insert. |
| position | The offset in bytes into the BString's data where to insert the string. |
*this.| BString & BString::Insert | ( | char | c, |
| int32 | count, | ||
| int32 | pos | ||
| ) |
Insert the given character repeatedly at the given position into the object's data.
| c | The character to insert. |
| count | The number of times to insert the character. |
| pos | The offset in bytes into the BString's data where to insert the string. |
*this. | BString & BString::IReplace | ( | char | replaceThis, |
| char | withThis, | ||
| int32 | maxReplaceCount, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace a number of occurrences of a character with another character. Case-insensive.
| replaceThis | The char to replace. |
| withThis | The char to put in that place |
| maxReplaceCount | The maximum number of occurences that should be replaced. |
| fromOffset | The offset where to start looking for the string |
| BString & BString::IReplace | ( | const char * | replaceThis, |
| const char * | withThis, | ||
| int32 | maxReplaceCount, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace a number of occurrences of a string with another string. Case-insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| maxReplaceCount | The maximum number of occurences that should be replaced. |
| fromOffset | The offset where to start looking for the string |
| BString & BString::IReplaceAll | ( | char | replaceThis, |
| char | withThis, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace all occurrences of a character with another character. Case-insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| fromOffset | The offset where to start looking for the string |
| BString & BString::IReplaceAll | ( | const char * | replaceThis, |
| const char * | withThis, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace all occurrences of a string with another string. Case-insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| fromOffset | The offset where to start looking for the string |
| BString & BString::IReplaceFirst | ( | char | replaceThis, |
| char | withThis | ||
| ) |
Replace the first occurrence of a character with another character. Case insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| BString & BString::IReplaceFirst | ( | const char * | replaceThis, |
| const char * | withThis | ||
| ) |
Replace the first occurrence of a string with another string. Case-insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| BString & BString::IReplaceLast | ( | char | replaceThis, |
| char | withThis | ||
| ) |
Replace the last occurrence of a character with another character. Case-insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| BString & BString::IReplaceLast | ( | const char * | replaceThis, |
| const char * | withThis | ||
| ) |
Replace the last occurrence of a string with another string. Case-insensitive.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| bool BString::IsEmpty | ( | ) | const [inline] |
Check whether the string is empty.
true if the string is empty. References Length().
| int32 BString::Length | ( | ) | const [inline] |
Get the length of the string in bytes.
Referenced by Append(), ByteAt(), IsEmpty(), and operator+=().
| char * BString::LockBuffer | ( | int32 | maxLength | ) |
Locks the buffer and return the internal string for manipulation.
If you want to do any lowlevel string manipulation on the internal buffer, you should call this method. This method includes the possibility to grow the buffer so that you don't have to worry about that yourself.
Make sure you call UnlockBuffer() when you're done with the manipulation.
| maxLength | The size of the buffer. If you don't want a biggerx buffer, passing anything under the length of the string will simply return it as is. |
| void BString::MoveInto | ( | char * | into, |
| int32 | from, | ||
| int32 | length | ||
| ) |
Move the BString data (or part of it) into the given buffer.
| into | The buffer where to move the object. |
| from | The offset (zero-based) where to begin the move. |
| length | The amount of bytes to move. |
| bool BString::operator!= | ( | const BString & | string | ) | const [inline] |
Lexicographically compare if this string is not equal to a given string.
| string | The string to compare with. |
References String().
| bool BString::operator!= | ( | const char * | string | ) | const [inline] |
Lexicographically compare if this string is not equal to a given string.
| string | The string to compare with. |
References operator==().
| BString & BString::operator+= | ( | const char * | str | ) |
Append the given string to the object.
| str | A pointer to the NULL-terminated string to append. |
*this.| BString & BString::operator+= | ( | char | c | ) |
Append the given character to the object.
| c | The character to append. |
*this.| bool BString::operator< | ( | const BString & | string | ) | const [inline] |
Lexicographically compare if this string is less than a given string.
| string | The string to compare with. |
References String().
| bool BString::operator< | ( | const char * | string | ) | const |
Lexicographically compare if this string is less than a given string.
| string | The string to compare with. |
| BString & BString::operator<< | ( | bool | value | ) |
Append the boolean value to the string.
In case the value is true, the string true is appended to the string. Otherwise, the string false is appended.
| BString & BString::operator<< | ( | float | value | ) |
Convert the float value to a string and append it.
Using this operator will append in the %.2f style formatting.
| BString & BString::operator<< | ( | double | value | ) |
Convert the double value to a string and append it.
Using this operator will append in the %.2f style formatting.
| bool BString::operator<= | ( | const BString & | string | ) | const [inline] |
Lexicographically compare if this string is less than or equal to a given string.
| string | The string to compare with. |
References String().
| bool BString::operator<= | ( | const char * | string | ) | const |
Lexicographically compare if this string is less than or equal to a given string.
| string | The string to compare with. |
| BString & BString::operator= | ( | const char * | str | ) |
Re-initialize the object to a copy of the data of a string.
| BString & BString::operator= | ( | char | c | ) |
Re-initialize the object to a character.
| c | The character which you want to initialize the string to. |
| bool BString::operator== | ( | const BString & | string | ) | const [inline] |
Lexicographically compare if this string is equal to a given string.
| string | The string to compare with. |
References String().
Referenced by operator!=().
| bool BString::operator== | ( | const char * | string | ) | const |
Lexicographically compare if this string is equal to a given string.
| string | The string to compare with. |
| bool BString::operator> | ( | const BString & | string | ) | const [inline] |
Lexicographically compare if this string is more than a given string.
| string | The string to compare with. |
References String().
| bool BString::operator> | ( | const char * | string | ) | const |
Lexicographically compare if this string is more than a given string.
| string | The string to compare with. |
| bool BString::operator>= | ( | const BString & | string | ) | const [inline] |
Lexicographically compare if this string is more than or equal to a given string.
| string | The string to compare with. |
References String().
| bool BString::operator>= | ( | const char * | string | ) | const |
Lexicographically compare if this string is more than or equal to a given string.
| string | The string to compare with. |
| char BString::operator[] | ( | int32 | index | ) | const [inline] |
Returns the character in the string at the given offset.
This function can be used to read a byte. There is no bound checking though, use ByteAt() if you don't know if the index parameter is valid.
| index | The index (zero-based) of the byte to get. |
| char & BString::operator[] | ( | int32 | index | ) |
Return a reference to the data at the given offset.
This function can be used to read a byte. There is no bounds checking though, so make sure the index you supply is valid.
| index | The index (zero-based) of the byte to get. |
| BString & BString::Prepend | ( | const char * | str | ) |
Prepend the given string to the object.
| str | A pointer to the string to prepend. |
*this.| BString & BString::Prepend | ( | const char * | str, |
| int32 | length | ||
| ) |
Prepend the given string to the object.
| str | A pointer to the string to prepend. |
| length | The maximum amount of bytes to get from the string. |
*this.Prepend the given BString to the object.
| string | The BString object to prepend. |
| length | The maximum amount of bytes to get from the BString. |
*this.| BString & BString::Prepend | ( | char | c, |
| int32 | count | ||
| ) |
Prepend the given character repeatedly to the object.
| c | The character to prepend. |
| count | The number of times this character should be prepended. |
*this. | BString & BString::Remove | ( | int32 | from, |
| int32 | length | ||
| ) |
Remove some bytes, starting at the given offset.
| from | The offset from which you want to start removing |
| length | The number of bytes to remove |
*this. | BString & BString::RemoveAll | ( | const char * | str | ) |
Remove all occurrences of the given string.
| str | A pointer to the string to remove. |
*this. | BString & BString::RemoveFirst | ( | const char * | string | ) |
Remove the first occurrence of the given string.
| string | A pointer to the string to remove. |
*this. | BString & BString::RemoveLast | ( | const char * | string | ) |
Remove the last occurrence of the given string.
| string | A pointer to the string to remove. |
*this. | BString & BString::RemoveSet | ( | const char * | setOfCharsToRemove | ) |
Remove all the characters specified.
| setOfCharsToRemove | The set of characters to remove. |
*this. | BString & BString::Replace | ( | char | replaceThis, |
| char | withThis, | ||
| int32 | maxReplaceCount, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace a number of occurrences of a character with another character.
| replaceThis | The character to replace. |
| withThis | The character to put in that place |
| maxReplaceCount | The maximum number of characters that should be replaced. |
| fromOffset | The offset where to start looking for the character |
*this.| BString & BString::Replace | ( | const char * | replaceThis, |
| const char * | withThis, | ||
| int32 | maxReplaceCount, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace a number of occurrences of a string with another string.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| maxReplaceCount | The maximum number of occurences that should be replaced. |
| fromOffset | The offset where to start looking for the string |
*this.| BString & BString::ReplaceAll | ( | char | replaceThis, |
| char | withThis, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace all occurrences of a character with another character.
| replaceThis | The character to replace. |
| withThis | The character to put in that place |
| fromOffset | The offset where to start looking for the character. |
*this.| BString & BString::ReplaceAll | ( | const char * | replaceThis, |
| const char * | withThis, | ||
| int32 | fromOffset = 0 |
||
| ) |
Replace all occurrences of a string with another string.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
| fromOffset | The offset where to start looking for the string. |
*this.| BString & BString::ReplaceFirst | ( | char | replaceThis, |
| char | withThis | ||
| ) |
Replace the first occurrence of a character with another character.
| replaceThis | The character to replace. |
| withThis | The character to put in that place |
*this.| BString & BString::ReplaceFirst | ( | const char * | replaceThis, |
| const char * | withThis | ||
| ) |
Replace the first occurrence of a string with another string.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
*this.| BString & BString::ReplaceLast | ( | char | replaceThis, |
| char | withThis | ||
| ) |
Replace the last occurrence of a character with another character.
| replaceThis | The character to replace. |
| withThis | The character to put in that place |
*this.| BString & BString::ReplaceLast | ( | const char * | replaceThis, |
| const char * | withThis | ||
| ) |
Replace the last occurrence of a string with another string.
| replaceThis | The string to replace. |
| withThis | The string to put in that place |
*this.| BString & BString::ReplaceSet | ( | const char * | setOfBytes, |
| char | with | ||
| ) |
Replaces characters that are in a certain set with a chosen character.
| setOfBytes | The set of characters that need to be replaced. |
| with | The character to replace the occurences with. |
*this. | BString & BString::ReplaceSet | ( | const char * | setOfBytes, |
| const char * | with | ||
| ) |
Replaces characters that are in a certain set with a chosen string.
| setOfBytes | The set of characters that need to be replaced. |
| with | The string to replace the occurences with. |
*this. | BString & BString::SetTo | ( | const char * | str | ) | [inline] |
Re-initialize the object to a copy of the data of a string.
This method calls operator=(const char *str).
References operator=().
| BString & BString::SetTo | ( | const char * | str, |
| int32 | maxLength | ||
| ) |
Re-initialize the object to a copy of the data of a string.
| str | The string to copy. |
| maxLength | Amount of characters to copy from the string. |
Re-initialize the object to a copy of the data of a BString.
| from | The string object to copy. |
*this.| BString & BString::SetTo | ( | char | c, |
| int32 | count | ||
| ) |
Set the timezone to another code.
Re-initialize the object to a string composed of a character you specify.
false if there was an error (likely due to an invalid timezone code.)This method lets you specify the length of a string and what character you want the string to contain repeatedly.
| c | The character you want to initialize the BString. |
| count | The length of the string. |
*this.| const char * BString::String | ( | ) | const [inline] |
Return a pointer to the object string, NUL terminated.
The pointer to the object string is guaranteed to be NUL terminated. You can't modify or free the pointer. Once the BString object is deleted, the pointer becomes invalid.
If you want to manipulate the internal string of the object directly, have a look at LockBuffer().
Referenced by Append(), HashValue(), operator const char *(), operator!=(), operator+=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().
| BString & BString::ToLower | ( | ) |
Convert the BString to lowercase.
*this. | BString & BString::ToUpper | ( | ) |
Convert the BString to uppercase.
*this. | BString & BString::Truncate | ( | int32 | newLength, |
| bool | lazy = true |
||
| ) |
Truncate the string to the new length.
| newLength | The new length of the string. |
| lazy | If true, the memory-optimization is postponed to later |
*this. | BString & BString::UnlockBuffer | ( | int32 | length = -1 | ) |
Unlocks the buffer after you are done with lowlevel manipulation.
| length | The length to trim the string to in order to keep the internal buffer sane. If you don't pass a value in it, a strlen call will be used to determine the length. |
*this.