Public Member Functions
BString Class Reference

String class supporting common string operations. More...

List of all members.

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.

BStringoperator= (const BString &string)
 Re-initialize the object to a copy of the data of a BString.
BStringoperator= (const char *string)
 Re-initialize the object to a copy of the data of a string.
BStringoperator= (char c)
 Re-initialize the object to a character.
BStringSetTo (const char *string)
 Re-initialize the object to a copy of the data of a string.
BStringSetTo (const char *string, int32 maxLength)
 Re-initialize the object to a copy of the data of a string.
BStringSetTo (const BString &string)
 Re-initialize the object to a copy of the data of a BString.
BStringAdopt (BString &from)
 Adopt the data of the given BString object.
BStringSetTo (const BString &string, int32 maxLength)
 Re-initialize the string to a copy of the given BString object.
BStringAdopt (BString &from, int32 maxLength)
 Adopt the data of the given BString object up to maxLength characters.
BStringSetTo (char c, int32 count)
 Set the timezone to another code.
BStringSetToChars (const char *string, int32 charCount)
 Undocumented.
BStringSetToChars (const BString &string, int32 charCount)
 Undocumented.
BStringAdoptChars (BString &from, int32 charCount)
 Undocumented.
BStringSetToFormat (const char *format,...)
 Undocumented.
Substring Copying
BStringCopyInto (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.
BStringCopyCharsInto (BString &into, int32 fromCharOffset, int32 charCount) const
 Undocumented.
bool CopyCharsInto (char *into, int32 *intoLength, int32 fromCharOffset, int32 charCount) const
 Undocumented.
Appending Methods
BStringoperator+= (const BString &string)
 Append the given string to the object.
BStringoperator+= (const char *string)
 Append the given string to the object.
BStringoperator+= (char c)
 Append the given character to the object.
BStringAppend (const BString &string)
 Append the given string to the object.
BStringAppend (const char *string)
 Append the given string to the object.
BStringAppend (const BString &string, int32 length)
 Append a part of the given BString to the object.
BStringAppend (const char *string, int32 length)
 Append a part of the given string to the object.
BStringAppend (char c, int32 count)
 Append the given character repeatedly to the object.
BStringAppendChars (const BString &string, int32 charCount)
 undocumented
BStringAppendChars (const char *string, int32 charCount)
 undocumented
Prepending Methods
BStringPrepend (const char *string)
 Prepend the given string to the object.
BStringPrepend (const BString &string)
 Prepend the given BString to the object.
BStringPrepend (const char *string, int32 length)
 Prepend the given string to the object.
BStringPrepend (const BString &string, int32 length)
 Prepend the given BString to the object.
BStringPrepend (char c, int32 count)
 Prepend the given character repeatedly to the object.
BStringPrependChars (const char *string, int32 charCount)
 undocumented
BStringPrependChars (const BString &string, int32 charCount)
 undocumented
Inserting Methods
BStringInsert (const char *string, int32 position)
 Insert the given string at the given position into the object's data.
BStringInsert (const char *string, int32 length, int32 position)
 Inserts the given string at the given position into the object's data.
BStringInsert (const char *string, int32 fromOffset, int32 length, int32 position)
 Insert the given string at the given position into the object's data.
BStringInsert (const BString &string, int32 position)
 Insert the given BString at the given position into the object's data.
BStringInsert (const BString &string, int32 length, int32 position)
 Insert the given BString at the given position into the object's data.
BStringInsert (const BString &string, int32 fromOffset, int32 length, int32 position)
 Insert the given string at the given position into the object's data.
BStringInsert (char c, int32 count, int32 position)
 Insert the given character repeatedly at the given position into the object's data.
BStringInsertChars (const char *string, int32 charPosition)
 Undocumented.
BStringInsertChars (const char *string, int32 charCount, int32 charPosition)
 Undocumented.
BStringInsertChars (const char *string, int32 fromCharOffset, int32 charCount, int32 charPosition)
 Undocumented.
BStringInsertChars (const BString &string, int32 charPosition)
 Undocumented.
BStringInsertChars (const BString &string, int32 charCount, int32 charPosition)
 Undocumented.
BStringInsertChars (const BString &string, int32 fromCharOffset, int32 charCount, int32 charPosition)
 Undocumented.
Removing Methods
BStringTruncate (int32 newLength, bool lazy=true)
 Truncate the string to the new length.
BStringTruncateChars (int32 newCharCount, bool lazy=true)
 Undocumented.
BStringRemove (int32 from, int32 length)
 Remove some bytes, starting at the given offset.
BStringRemoveChars (int32 fromCharOffset, int32 charCount)
 Undocumented.
BStringRemoveFirst (const BString &string)
 Remove the first occurrence of the given BString.
BStringRemoveLast (const BString &string)
 Remove the last occurrence of the given BString.
BStringRemoveAll (const BString &string)
 Remove all occurrences of the given BString.
BStringRemoveFirst (const char *string)
 Remove the first occurrence of the given string.
BStringRemoveLast (const char *string)
 Remove the last occurrence of the given string.
BStringRemoveAll (const char *string)
 Remove all occurrences of the given string.
BStringRemoveSet (const char *setOfBytesToRemove)
 Remove all the characters specified.
BStringRemoveCharsSet (const char *setOfCharsToRemove)
 Undocumented.
BStringMoveInto (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.
BStringMoveCharsInto (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
BStringReplaceFirst (char replaceThis, char withThis)
 Replace the first occurrence of a character with another character.
BStringReplaceLast (char replaceThis, char withThis)
 Replace the last occurrence of a character with another character.
BStringReplaceAll (char replaceThis, char withThis, int32 fromOffset=0)
 Replace all occurrences of a character with another character.
BStringReplace (char replaceThis, char withThis, int32 maxReplaceCount, int32 fromOffset=0)
 Replace a number of occurrences of a character with another character.
BStringReplaceFirst (const char *replaceThis, const char *withThis)
 Replace the first occurrence of a string with another string.
BStringReplaceLast (const char *replaceThis, const char *withThis)
 Replace the last occurrence of a string with another string.
BStringReplaceAll (const char *replaceThis, const char *withThis, int32 fromOffset=0)
 Replace all occurrences of a string with another string.
BStringReplace (const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromOffset=0)
 Replace a number of occurrences of a string with another string.
BStringReplaceAllChars (const char *replaceThis, const char *withThis, int32 fromCharOffset)
 Undocumented.
BStringReplaceChars (const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromCharOffset)
 Undocumented.
BStringIReplaceFirst (char replaceThis, char withThis)
 Replace the first occurrence of a character with another character. Case insensitive.
BStringIReplaceLast (char replaceThis, char withThis)
 Replace the last occurrence of a character with another character. Case-insensitive.
BStringIReplaceAll (char replaceThis, char withThis, int32 fromOffset=0)
 Replace all occurrences of a character with another character. Case-insensitive.
BStringIReplace (char replaceThis, char withThis, int32 maxReplaceCount, int32 fromOffset=0)
 Replace a number of occurrences of a character with another character. Case-insensive.
BStringIReplaceFirst (const char *replaceThis, const char *withThis)
 Replace the first occurrence of a string with another string. Case-insensitive.
BStringIReplaceLast (const char *replaceThis, const char *withThis)
 Replace the last occurrence of a string with another string. Case-insensitive.
BStringIReplaceAll (const char *replaceThis, const char *withThis, int32 fromOffset=0)
 Replace all occurrences of a string with another string. Case-insensitive.
BStringIReplace (const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromOffset=0)
 Replace a number of occurrences of a string with another string. Case-insensitive.
BStringReplaceSet (const char *setOfBytes, char with)
 Replaces characters that are in a certain set with a chosen character.
BStringReplaceSet (const char *setOfBytes, const char *with)
 Replaces characters that are in a certain set with a chosen string.
BStringReplaceCharsSet (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.
BStringUnlockBuffer (int32 length=-1)
 Unlocks the buffer after you are done with lowlevel manipulation.
Case Manipulation
BStringToLower ()
 Convert the BString to lowercase.
BStringToUpper ()
 Convert the BString to uppercase.
BStringCapitalize ()
 Convert the first character to uppercase, rest to lowercase.
BStringCapitalizeEachWord ()
 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.

BStringCharacterEscape (const char *original, const char *setOfCharsToEscape, char escapeWith)
 Escape selected characters on a given string.
BStringCharacterEscape (const char *setOfCharsToEscape, char escapeWith)
 Escape selected characters of this string.
BStringCharacterDeescape (const char *original, char escapeChar)
 Remove the character to escape with from a given string.
BStringCharacterDeescape (char escapeChar)
 Remove the character to escape with from this string.
Trimming methods
BStringTrim ()
 Undocumented.
Simple sprintf Replacement Methods

These methods may be slower than sprintf(), but they are overflow safe.

BStringoperator<< (const char *string)
 Append the string string.
BStringoperator<< (const BString &string)
 Append the BString string.
BStringoperator<< (char c)
 Append the char c.
BStringoperator<< (bool value)
 Append the boolean value to the string.
BStringoperator<< (int value)
 Convert the int value to a string and append it.
BStringoperator<< (unsigned int value)
 Convert the unsigned int value to a string and append it.
BStringoperator<< (unsigned long value)
 Convert the unsigned long value to a string and append it.
BStringoperator<< (long value)
 Convert the long value to a string and append it.
BStringoperator<< (unsigned long long value)
 Convert the unsigned long long value to a string and append it.
BStringoperator<< (long long value)
 Convert the long long value to a string and append it.
BStringoperator<< (float value)
 Convert the float value to a string and append it.
BStringoperator<< (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.

Detailed Description

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.


Constructor & Destructor Documentation

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.

Warning:
In BeOS R5 passing in a negative maxLength argument will copy the entire string.
BString::~BString ( )

Free all resources associated with the object.

The destructor also frees the internal buffer associated with the string.


Member Function Documentation

BString & BString::Adopt ( BString from)

Adopt the data of the given BString object.

This method adopts the data from a BString.

Note:
The object that is adopted from is not deleted, only its private data is initialized to a NULL string. So if the from object was created on the heap, you need to clean it up yourself.
Parameters:
fromThe string object to adopt.
Returns:
The function always returns *this.
See also:
operator=(const BString &string)
BString & BString::Adopt ( BString from,
int32  maxLength 
)

Adopt the data of the given BString object up to maxLength characters.

Parameters:
fromThe string object to adopt.
maxLengthNumber of characters to adopt from the original BString.
Returns:
The function always returns *this.
See also:
SetTo(const BString &string, int32 maxLength)
BString & BString::Append ( const BString string) [inline]

Append the given string to the object.

Parameters:
stringThe string to append
Returns:
This method always returns *this.
See also:
Append(const BString &string, int32 length)

References Length(), and String().

BString & BString::Append ( const char *  str) [inline]

Append the given string to the object.

This method calls operator+=(const char *str).

See also:
Append(const char *str, int32 length)

References operator+=().

BString & BString::Append ( const BString string,
int32  length 
)

Append a part of the given BString to the object.

Parameters:
stringThe BString to append.
lengthThe maximum number ofbytes to get from the original object.
Returns:
This method always returns *this.
See also:
operator+=(const BString &string)
BString & BString::Append ( const char *  str,
int32  length 
)

Append a part of the given string to the object.

Parameters:
strA pointer to the string to append.
lengthThe maximum bytes to get from the original string.
Returns:
This method always returns *this.
See also:
operator+=(const char *str)
BString & BString::Append ( char  c,
int32  count 
)

Append the given character repeatedly to the object.

Parameters:
cThe character to append.
countThe number of times this character should be appended.
Returns:
This method always returns *this.
See also:
operator+=(char c)
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.

Parameters:
indexThe index (zero-based) of the byte to get.
Returns:
Returns a reference to the specified byte. If you are out of bounds, it will return 0.

References Length().

BString & BString::Capitalize ( )

Convert the first character to uppercase, rest to lowercase.

Returns:
This method always returns *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.

Returns:
This method always returns *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.

Parameters:
originalThe string to be escaped.
escapeCharThe character that was used to escape with.
Returns:
This method always returns *this.
See also:
CharacterEscape(const char *original, const char *setOfCharsToEscape, char escapeWith)
BString & BString::CharacterDeescape ( char  escapeChar)

Remove the character to escape with from this string.

Parameters:
escapeCharThe character that was used to escape with.
Returns:
This method always returns *this.
See also:
CharacterEscape(const char *setOfCharsToEscape, char escapeWith)
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.

Parameters:
originalThe string to be escaped.
setOfCharsToEscapeThe set of characters that need to be escaped.
escapeWithThe character to escape with.
Returns:
This method always returns *this.
See also:
CharacterDeescape(char escapeChar)
CharacterDeescape(const char *original, char escapeChar)
BString & BString::CharacterEscape ( const char *  setOfCharsToEscape,
char  escapeWith 
)

Escape selected characters of this string.

Parameters:
setOfCharsToEscapeThe set of characters that need to be escaped.
escapeWithThe character to escape with.
Returns:
This method always returns *this.
See also:
CharacterDeescape(char escapeChar)
int BString::Compare ( const BString string) const

Lexicographically compare this string to another.

Parameters:
stringThe string to compare to.
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
int BString::Compare ( const char *  string) const

Lexicographically compare this string to another.

Parameters:
stringThe string to compare to.
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
See also:
Compare(const BString &string) const
int BString::Compare ( const BString string,
int32  length 
) const

Lexicographically compare a number of characters of a string to another.

Parameters:
stringThe string to compare to.
lengthThe number of characters to compare
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The 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.

Parameters:
stringThe string to compare to.
lengthThe number of characters to compare.
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
See also:
Compare(const BString &string, int32 n) const
BString & BString::CopyInto ( BString into,
int32  fromOffset,
int32  length 
) const

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.

Parameters:
intoThe BString to where to copy the object.
fromOffsetThe (zero-based) offset where to begin the copy.
lengthThe amount of bytes to copy.
Returns:
This method always returns a pointer to the string passed as the 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.

Parameters:
intoThe buffer where to copy the object.
fromOffsetThe (zero-based) offset where to begin the copy.
lengthThe 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.

Warning:
This method does not check whether the input is outside of the boundaries, so make sure that you check your input values.
Parameters:
fromCharOffsetThe index of the character (not the byte!) from which to start the count
charCountThe number of characters to count
Returns:
An integer with the number of bytes.
int32 BString::CountChars ( ) const

Returns the length of the object measured in characters.

BString is aware of UTF8 characters, so this method will count the actual number of characters in the string.

Returns:
An integer which is the number of characters in the string.
See also:
Length()
int32 BString::FindFirst ( const BString string) const

Find the first occurrence of the given BString.

Parameters:
stringThe BString to search for.
Returns:
The offset (zero-based) into the data where the given BString has been found.
Return values:
B_ERRORCould not find string.
See also:
IFindFirst(const BString &string) const
int32 BString::FindFirst ( const char *  string) const

Find the first occurrence of the given string.

Parameters:
stringThe string to search for.
Returns:
The offset (zero-based) into the data where the given string has been found.
Return values:
B_BAD_VALUEThe string pointer is invalid.
B_ERRORCould not find string.
See also:
IFindFirst(const char *string) const
int32 BString::FindFirst ( const BString string,
int32  fromOffset 
) const

Find the first occurrence of the given BString, starting from the given offset.

Parameters:
stringThe BString to search for.
fromOffsetThe offset where to start the search.
Returns:
An integer which is the offset (zero-based) into the data where the given BString has been found.
Return values:
B_ERRORCould not find string.
See also:
IFindFirst(const BString &string, int32 fromOffset) const
int32 BString::FindFirst ( const char *  string,
int32  fromOffset 
) const

Find the first occurrence of the given string, starting from the given offset.

Parameters:
stringThe string to search for.
fromOffsetThe offset where to start the search.
Returns:
The offset (zero-based) into the data where the given string has been found.
Return values:
B_BAD_VALUEThe string pointer is invalid.
B_ERRORCould not find string.
See also:
IFindFirst(const char *string, int32 fromOffset) const
int32 BString::FindFirst ( char  c) const

Find the first occurrence of the given character.

Parameters:
cThe character to search for.
Returns:
The offset (zero-based) into the data where the given character has been found.
Return values:
B_ERRORCould not find c.
int32 BString::FindFirst ( char  c,
int32  fromOffset 
) const

Find the first occurrence of the given character, starting from the given offset.

Parameters:
cThe character to search for.
fromOffsetThe offset where to start the search.
Returns:
The offset (zero-based) into the data where the given character has been found.
Return values:
B_ERRORCould not find c.
int32 BString::FindLast ( const BString string) const

Find the last occurrence of the given BString.

Parameters:
stringThe BString to search for.
Returns:
The offset (zero-based) into the data where the given BString has been found.
Return values:
B_ERRORCould not find string.
See also:
IFindLast(const BString &string) const
int32 BString::FindLast ( const char *  string) const

Find the last occurrence of the given string.

Parameters:
stringThe string to search for.
Returns:
The offset (zero-based) into the data where the given string has been found.
Return values:
B_BAD_VALUEThe string pointer is invalid.
B_ERRORCould not find string.
See also:
IFindLast(const char *string) const /*!

/*!

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.

Parameters:
stringThe BString to search for.
beforeOffsetThe offset where to start the search.
Returns:
An integer which is the offset (zero-based) into the data where the given BString has been found.
Return values:
B_ERRORCould not find string.
See also:
IFindLast(const BString &string, int32 beforeOffset) const
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.

Parameters:
stringThe string to search for.
beforeOffsetThe offset where to start the search.
Returns:
The offset (zero-based) into the data where the given string has been found.
Return values:
B_BAD_VALUEThe string pointer is invalid.
B_ERRORCould not find string.
See also:
IFindLast(const char *string, int32 beforeOffset) const
int32 BString::FindLast ( char  c) const

Find the last occurrence of the given character.

Parameters:
cThe character to search for.
Returns:
The offset (zero-based) into the data where the given character has been found.
Return values:
B_ERRORCould 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.

Parameters:
cThe character to search for.
beforeOffsetThe offset where to start the search.
Returns:
The offset (zero-based) into the data where the given character has been found.
Return values:
B_ERRORCould not find c.
uint32 BString::HashValue ( ) const [inline]

Return a hash value for the current string.

See also:
HashValue(const char *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.

Parameters:
stringThe string that you want to have hashed.
See also:
HashValue()
int BString::ICompare ( const BString string) const

Lexicographically compare a string to another in a case-insensitive way.

Parameters:
stringThe string to compare to.
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
See also:
Compare(const BString &string) const
int BString::ICompare ( const char *  string) const

Lexicographically compare this string to another in a case-insensitive way.

Parameters:
stringThe string to compare to.
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
See also:
Compare(const BString &string) const
int BString::ICompare ( const BString string,
int32  length 
) const

Lexicographically compare a number of characters of this string to another.

Parameters:
stringThe string to compare to.
lengthThe number of characters to compare
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
See also:
Compare(const BString &string, int32 length) const
int BString::ICompare ( const char *  string,
int32  length 
) const

Lexicographically compare a number of characters of this string to another.

Parameters:
stringThe string to compare to.
lengthThe number of characters to compare
Return values:
>0The object sorts lexicographically after string.
=0The object is equal to string.
<0The object sorts lexicographically before string.
See also:
Compare(const BString &string, int32 length) const
int32 BString::IFindFirst ( const BString string) const

Find the first occurrence of the given BString case-insensitively.

See also:
FindFirst(const BString &string) const
int32 BString::IFindFirst ( const char *  string) const

Find the first occurrence of the given BString case-insensitively.

See also:
FindFirst(const char *string) const
int32 BString::IFindFirst ( const BString string,
int32  fromOffset 
) const

Find the first occurrence of the given BString case-insensitively, starting from the given offset.

See also:
FindFirst(const BString &string, int32 fromOffset) const
int32 BString::IFindFirst ( const char *  string,
int32  fromOffset 
) const

Find the first occurrence of the given string case-insensitively, starting from the given offset.

See also:
FindFirst(const char *string, int32 fromOffset) const
int32 BString::IFindLast ( const BString string) const

Find the last occurrence of the given BString case-insensitively.

See also:
FindLast(const BString &string) const
int32 BString::IFindLast ( const char *  string) const

Find the last occurrence of the given string case-insensitively.

See also:
FindLast(const char *string) const
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.

See also:
FindLast(const BString &string, int32 beforeOffset) const
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.

See also:
FindLast(const char *string, int32 beforeOffset) const
BString & BString::Insert ( const char *  string,
int32  position 
)

Insert the given string at the given position into the object's data.

Parameters:
stringA pointer to the string to insert.
positionThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *this.
See also:
Insert(const char *string, int32 length, int32 position)
Insert(const char *string, int32 fromOffset, int32 length, int32 position)
BString & BString::Insert ( const char *  string,
int32  length,
int32  position 
)

Inserts the given string at the given position into the object's data.

Parameters:
stringA pointer to the string to insert.
lengthThe amount of bytes to insert.
positionThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *this.
See also:
Insert(const char *string, int32 position)
Insert(const char *string, int32 fromOffset, int32 length, int32 position)
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.

Parameters:
stringA pointer to the string to insert.
fromOffsetThe offset in the string that is to be inserted
lengthThe amount of bytes to insert.
positionThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *this.
See also:
Insert(const char *string, int32 position)
Insert(const char *string, int32 length, int32 position)
BString & BString::Insert ( const BString string,
int32  position 
)

Insert the given BString at the given position into the object's data.

Parameters:
stringThe BString object to insert.
positionThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *this.
See also:
Insert(const BString &string, int32 length, int32 position)
Insert(const BString &string, int32 fromOffset, int32 length, int32 position)
BString & BString::Insert ( const BString string,
int32  length,
int32  position 
)

Insert the given BString at the given position into the object's data.

Parameters:
stringThe BString object to insert.
lengthThe amount of bytes to insert.
positionThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *this.
See also:
Insert(const BString &string, int32 position)
Insert(const BString &string, int32 fromOffset, int32 length, int32 position)
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.

Parameters:
stringThe BString object to insert.
fromOffsetThe offset in the string that is to be inserted
lengthThe amount of bytes to insert.
positionThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *this.
See also:
Insert(const BString &string, int32 position)
Insert(const BString &string, int32 length, int32 position)
BString & BString::Insert ( char  c,
int32  count,
int32  pos 
)

Insert the given character repeatedly at the given position into the object's data.

Parameters:
cThe character to insert.
countThe number of times to insert the character.
posThe offset in bytes into the BString's data where to insert the string.
Returns:
This method always returns *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.

Parameters:
replaceThisThe char to replace.
withThisThe char to put in that place
maxReplaceCountThe maximum number of occurences that should be replaced.
fromOffsetThe offset where to start looking for the string
See also:
Replace(char replaceThis, char withThis, int32 maxReplaceCount, int32 fromOffset)
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.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
maxReplaceCountThe maximum number of occurences that should be replaced.
fromOffsetThe offset where to start looking for the string
See also:
Replace(const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromOffset)
BString & BString::IReplaceAll ( char  replaceThis,
char  withThis,
int32  fromOffset = 0 
)

Replace all occurrences of a character with another character. Case-insensitive.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
fromOffsetThe offset where to start looking for the string
See also:
ReplaceAll(char replaceThis, char withThis, int32 fromOffset)
BString & BString::IReplaceAll ( const char *  replaceThis,
const char *  withThis,
int32  fromOffset = 0 
)

Replace all occurrences of a string with another string. Case-insensitive.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
fromOffsetThe offset where to start looking for the string
See also:
ReplaceAll(const char *replaceThis, const char *withThis, int32 fromOffset)
BString & BString::IReplaceFirst ( char  replaceThis,
char  withThis 
)

Replace the first occurrence of a character with another character. Case insensitive.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
See also:
ReplaceFirst(char replaceThis, char withThis)
BString & BString::IReplaceFirst ( const char *  replaceThis,
const char *  withThis 
)

Replace the first occurrence of a string with another string. Case-insensitive.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
See also:
ReplaceFirst(const char *replaceThis, const char *withThis)
BString & BString::IReplaceLast ( char  replaceThis,
char  withThis 
)

Replace the last occurrence of a character with another character. Case-insensitive.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
See also:
ReplaceLast(char replaceThis, char withThis)
BString & BString::IReplaceLast ( const char *  replaceThis,
const char *  withThis 
)

Replace the last occurrence of a string with another string. Case-insensitive.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
See also:
ReplaceLast(const char *replaceThis, const char *withThis)
bool BString::IsEmpty ( ) const [inline]

Check whether the string is empty.

Returns:
Returns true if the string is empty.

References Length().

int32 BString::Length ( ) const [inline]

Get the length of the string in bytes.

Returns:
An integer with the length of the string, measured in bytes.
See also:
CountChars()

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.

Parameters:
maxLengthThe 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.
Returns:
A pointer to the buffer you may manipulate.
See also:
UnlockBuffer()
BString & BString::MoveInto ( BString into,
int32  from,
int32  length 
)

Move the BString data (or part of it) into another BString.

Parameters:
intoThe BString where to move the object.
fromThe offset (zero-based) where to begin the move.
lengthThe amount of bytes to move.
Returns:
This method always returns into .
void BString::MoveInto ( char *  into,
int32  from,
int32  length 
)

Move the BString data (or part of it) into the given buffer.

Parameters:
intoThe buffer where to move the object.
fromThe offset (zero-based) where to begin the move.
lengthThe 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.

Parameters:
stringThe 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.

Parameters:
stringThe string to compare with.

References operator==().

BString & BString::operator+= ( const BString string) [inline]

Append the given string to the object.

Parameters:
stringThe string to append
Returns:
This method always returns *this.
See also:
Append(const BString &string, int32 length)

References Length(), and String().

Referenced by Append().

BString & BString::operator+= ( const char *  str)

Append the given string to the object.

Parameters:
strA pointer to the NULL-terminated string to append.
Returns:
This method always returns *this.
See also:
Append(const char *str, int32 length)
BString & BString::operator+= ( char  c)

Append the given character to the object.

Parameters:
cThe character to append.
Returns:
This method always returns *this.
See also:
Append(char c, int32 count)
bool BString::operator< ( const BString string) const [inline]

Lexicographically compare if this string is less than a given string.

Parameters:
stringThe string to compare with.

References String().

bool BString::operator< ( const char *  string) const

Lexicographically compare if this string is less than a given string.

Parameters:
stringThe 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.

Parameters:
stringThe 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.

Parameters:
stringThe string to compare with.
BString & BString::operator= ( const BString string)

Re-initialize the object to a copy of the data of a BString.

Parameters:
stringThe string object to copy.
Returns:
The function always returns *this.
See also:
Adopt(BString &from)
SetTo(const BString &string, int32 length)

Referenced by SetTo().

BString & BString::operator= ( const char *  str)

Re-initialize the object to a copy of the data of a string.

See also:
SetTo(const char *str, int32 maxLength)
BString & BString::operator= ( char  c)

Re-initialize the object to a character.

Parameters:
cThe 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.

Parameters:
stringThe 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.

Parameters:
stringThe string to compare with.
bool BString::operator> ( const BString string) const [inline]

Lexicographically compare if this string is more than a given string.

Parameters:
stringThe string to compare with.

References String().

bool BString::operator> ( const char *  string) const

Lexicographically compare if this string is more than a given string.

Parameters:
stringThe 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.

Parameters:
stringThe 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.

Parameters:
stringThe 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.

Parameters:
indexThe index (zero-based) of the byte to get.
Returns:
Returns a reference to the specified byte.
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.

Parameters:
indexThe index (zero-based) of the byte to get.
Returns:
Returns a reference to the specified byte.
See also:
ByteAt(int32 index) for a safer version.
BString & BString::Prepend ( const char *  str)

Prepend the given string to the object.

Parameters:
strA pointer to the string to prepend.
Returns:
This method always returns *this.
See also:
Prepend(const char *str, int32 length)
BString & BString::Prepend ( const BString string)

Prepend the given BString to the object.

Parameters:
stringThe BString object to prepend.
Returns:
This method always returns *this.
See also:
Prepend(const BString &string, int32 len)
BString & BString::Prepend ( const char *  str,
int32  length 
)

Prepend the given string to the object.

Parameters:
strA pointer to the string to prepend.
lengthThe maximum amount of bytes to get from the string.
Returns:
This method always returns *this.
See also:
Prepend(const char *str)
BString & BString::Prepend ( const BString string,
int32  length 
)

Prepend the given BString to the object.

Parameters:
stringThe BString object to prepend.
lengthThe maximum amount of bytes to get from the BString.
Returns:
This method always returns *this.
See also:
Prepend(const BString &string)
BString & BString::Prepend ( char  c,
int32  count 
)

Prepend the given character repeatedly to the object.

Parameters:
cThe character to prepend.
countThe number of times this character should be prepended.
Returns:
This method always returns *this.
BString & BString::Remove ( int32  from,
int32  length 
)

Remove some bytes, starting at the given offset.

Parameters:
fromThe offset from which you want to start removing
lengthThe number of bytes to remove
Returns:
This function always returns *this.
BString & BString::RemoveAll ( const BString string)

Remove all occurrences of the given BString.

Parameters:
stringThe BString to remove.
Returns:
This function always returns *this.
BString & BString::RemoveAll ( const char *  str)

Remove all occurrences of the given string.

Parameters:
strA pointer to the string to remove.
Returns:
This function always returns *this.
BString & BString::RemoveFirst ( const BString string)

Remove the first occurrence of the given BString.

Parameters:
stringThe BString to remove.
Returns:
This function always returns *this.
BString & BString::RemoveFirst ( const char *  string)

Remove the first occurrence of the given string.

Parameters:
stringA pointer to the string to remove.
Returns:
This function always returns *this.
BString & BString::RemoveLast ( const BString string)

Remove the last occurrence of the given BString.

Parameters:
stringThe BString to remove.
Returns:
This function always returns *this.
BString & BString::RemoveLast ( const char *  string)

Remove the last occurrence of the given string.

Parameters:
stringA pointer to the string to remove.
Returns:
This function always returns *this.
BString & BString::RemoveSet ( const char *  setOfCharsToRemove)

Remove all the characters specified.

Parameters:
setOfCharsToRemoveThe set of characters to remove.
Returns:
This function always returns *this.
BString & BString::Replace ( char  replaceThis,
char  withThis,
int32  maxReplaceCount,
int32  fromOffset = 0 
)

Replace a number of occurrences of a character with another character.

Parameters:
replaceThisThe character to replace.
withThisThe character to put in that place
maxReplaceCountThe maximum number of characters that should be replaced.
fromOffsetThe offset where to start looking for the character
Returns:
This method always returns *this.
See also:
IReplace(char replaceThis, char withThis, int32 maxReplaceCount, int32 fromOffset)
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.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
maxReplaceCountThe maximum number of occurences that should be replaced.
fromOffsetThe offset where to start looking for the string
Returns:
This method always returns *this.
See also:
IReplace(const char *replaceThis, const char *withThis, int32 maxReplaceCount, int32 fromOffset)
BString & BString::ReplaceAll ( char  replaceThis,
char  withThis,
int32  fromOffset = 0 
)

Replace all occurrences of a character with another character.

Parameters:
replaceThisThe character to replace.
withThisThe character to put in that place
fromOffsetThe offset where to start looking for the character.
Returns:
This method always returns *this.
See also:
IReplaceAll(char replaceThis, char withThis, int32 fromOffset)
BString & BString::ReplaceAll ( const char *  replaceThis,
const char *  withThis,
int32  fromOffset = 0 
)

Replace all occurrences of a string with another string.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
fromOffsetThe offset where to start looking for the string.
Returns:
This method always returns *this.
See also:
IReplaceAll(const char *replaceThis, const char *withThis, int32 fromOffset)
BString & BString::ReplaceFirst ( char  replaceThis,
char  withThis 
)

Replace the first occurrence of a character with another character.

Parameters:
replaceThisThe character to replace.
withThisThe character to put in that place
Returns:
This method always returns *this.
See also:
IReplaceFirst(char replaceThis, char withThis)
BString & BString::ReplaceFirst ( const char *  replaceThis,
const char *  withThis 
)

Replace the first occurrence of a string with another string.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
Returns:
This method always returns *this.
See also:
IReplaceFirst(const char *replaceThis, const char *withThis)
BString & BString::ReplaceLast ( char  replaceThis,
char  withThis 
)

Replace the last occurrence of a character with another character.

Parameters:
replaceThisThe character to replace.
withThisThe character to put in that place
Returns:
This method always returns *this.
See also:
ReplaceLast(char replaceThis, char withThis)
BString & BString::ReplaceLast ( const char *  replaceThis,
const char *  withThis 
)

Replace the last occurrence of a string with another string.

Parameters:
replaceThisThe string to replace.
withThisThe string to put in that place
Returns:
This method always returns *this.
See also:
IReplaceLast(const char *replaceThis, const char *withThis)
BString & BString::ReplaceSet ( const char *  setOfBytes,
char  with 
)

Replaces characters that are in a certain set with a chosen character.

Parameters:
setOfBytesThe set of characters that need to be replaced.
withThe character to replace the occurences with.
Returns:
This method always returns *this.
BString & BString::ReplaceSet ( const char *  setOfBytes,
const char *  with 
)

Replaces characters that are in a certain set with a chosen string.

Parameters:
setOfBytesThe set of characters that need to be replaced.
withThe string to replace the occurences with.
Returns:
This method always returns *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).

See also:
SetTo(const char *str, int32 maxLength)

References operator=().

BString & BString::SetTo ( const char *  str,
int32  maxLength 
)

Re-initialize the object to a copy of the data of a string.

Parameters:
strThe string to copy.
maxLengthAmount of characters to copy from the string.
See also:
operator=(const char *str)
BString & BString::SetTo ( const BString from)

Re-initialize the object to a copy of the data of a BString.

Parameters:
fromThe string object to copy.
Returns:
The function always returns *this.
See also:
SetTo(const BString &string, int32 length)
Adopt(BString &from)
BString & BString::SetTo ( const BString string,
int32  maxLength 
)

Re-initialize the string to a copy of the given BString object.

Parameters:
stringThe BString object to copy.
maxLengthAmount of characters to copy from the original BString.
Returns:
The function always returns *this.
See also:
operator=(const BString &string)
Adopt(BString &from, int32 maxLength)
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.

Returns:
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.

Parameters:
cThe character you want to initialize the BString.
countThe length of the string.
Returns:
The function always returns *this.
See also:
operator=(char c)
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().

Returns:
A pointer to the object string.

Referenced by Append(), HashValue(), operator const char *(), operator!=(), operator+=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

BString & BString::ToLower ( )

Convert the BString to lowercase.

Returns:
This method always returns *this.
BString & BString::ToUpper ( )

Convert the BString to uppercase.

Returns:
This method always returns *this.
BString & BString::Truncate ( int32  newLength,
bool  lazy = true 
)

Truncate the string to the new length.

Parameters:
newLengthThe new length of the string.
lazyIf true, the memory-optimization is postponed to later
Returns:
This method always returns *this.
BString & BString::UnlockBuffer ( int32  length = -1)

Unlocks the buffer after you are done with lowlevel manipulation.

Parameters:
lengthThe 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.
Returns:
This method always returns *this.

The Haiku Book pre-R1 - BString Class Reference
Generated on Sat May 18 2013 by Doxygen 1.7.5.1