Main Page   Class Hierarchy   Compound List   Header Files   Compound Members  

BGString Class Reference

Common stringclass with base functionality, like substrings, trimming, etc. More...

#include <bgstring.h>

Class diagram for BGString:

BGOctet BGType BGObject

List of all members.


Public Members

 BGString ( )
Constructs an empty string.

 BGString ( long )
Constructs an empty string with initial size, like specified.

 BGString ( const BGString &s )
Constructs an empty string with initial value. More...

 BGString ( const char *s )
Constructs an empty string with initial value. More...

virtual ~BGString ( )
Destructor of string. More...

virtual BGString toString ( )
Generates string representation of this object. More...

virtual unsigned long hash ( )
Generates a 'unique' hashvalue of this object. More...

virtual int compare ( BGObject &obj )
Compares two objects (derived from bgobject). More...

virtual BGString className ( )
Return the class name for this class. More...

void set ( const char *s )
Set content of string. More...

virtual char* buffer ( ) const
Returns content of string. More...

virtual long length ( ) const
Returns length of string. More...

void clear ( )
Clears current content of string (memory will not be freed, just length is set to 0).

void ensure ( long neededSize )
Ensures capacity of string. More...

long indexOf ( char ch, long fromIndex=0 )
Return position of specified character. More...

long indexOf ( char *s, long fromIndex=0 )
Return position of specified string. More...

long indexOf ( BGString &s, long fromIndex=0 )
Return position of specified string. More...

BGString substring ( long beginIndex, long endIndex )
Returns a new string that is a substring of this string. More...

BGString& replace ( char oldch, char newch, long beginIndex=0, long endIndex=0 )
Replaces oldchar to newchar from index beginIndex to endIndex-1. More...

BGString& add ( const char *s )
Concatenate a string to this one. More...

BGString& add ( char charToAppend )
Appends a character to string content end. More...

BGString& add ( const BGString& s )
Concatenate a string to this one. More...

BGString& trim ( )
Trims spaces on left and right site.

BGString& ltrim ( )
Trims spaces on left site.

BGString& rtrim ( )
Trims spaces on right site.


Protected Members

void realloc ( long plusSize = REALLOCSIZE )
Reallocates string to actual size + plusSize. More...


Detailed Description

Common stringclass with base functionality, like substrings, trimming, etc.

Author(s):
Dietrich Pfeifle
Version:
1.0

Member Function Documentation

BGString::BGString (const BGString & s)

Constructs an empty string with initial value.

Parameters:
s   Initial string value

BGString::BGString (const char * s)

Constructs an empty string with initial value.

Parameters:
s   Initial string value

virtual BGString::~BGString () [virtual]

Destructor of string.

Frees all allocated memory.

virtual BGString BGString::toString () [inline, virtual]

Generates string representation of this object.

This is useful for logging, etc. - This method will replace dump !

Returns:
Stringrepresentation of this object

Reimplemented from BGObject.

virtual unsigned long BGString::hash () [virtual]

Generates a 'unique' hashvalue of this object.

Note: The returned pointer will point to class buffer. Therefore do not delete it, dupe it if you need it outside of instance lifecycle.

Returns:
Hash of this object

Reimplemented from BGObject.

virtual int BGString::compare (BGObject & obj) [virtual]

Compares two objects (derived from bgobject).

This method is pure virtual and must be overwritten in subclasses.

Parameters:
obj   Object reference to compare with us
Returns:
0=Equal <0=objIsLess >0=objIsGreater TODO: Discuss !

Reimplemented from BGType.

virtual BGString BGString::className () [inline, virtual]

Return the class name for this class.

Subclasses should overwrite this method to return their own name.

Reimplemented from BGObject.

void BGString::set (const char * s)

Set content of string.

Characters are copied to internal buffer. Old content (if existant) will be overwritten.

Parameters:
s   New content of string

virtual char * BGString::buffer () const [inline, virtual]

Returns content of string.

Returns:
Content of string

Reimplemented from BGOctet.

virtual long BGString::length () const [inline, virtual]

Returns length of string.

Returns:
Length of string

Reimplemented from BGOctet.

void BGString::ensure (long neededSize) [inline]

Ensures capacity of string.

It is not usual to call this method, because all add's, etc. will call it implicitely.

Parameters:
neededSize   Minimum size needed

long BGString::indexOf (char ch, long fromIndex = 0)

Return position of specified character.

Parameters:
ch   Character to find
Returns:
Position of specified character (or -1 if not found)

long BGString::indexOf (char * s, long fromIndex = 0)

Return position of specified string.

Parameters:
s   String to find
Returns:
Position of specified string (or -1 if not found)

long BGString::indexOf (BGString & s, long fromIndex = 0)

Return position of specified string.

Parameters:
s   String to find
Returns:
Position of specified string (or -1 if not found)

BGString BGString::substring (long beginIndex, long endIndex)

Returns a new string that is a substring of this string.

The substring begins at the specified beginIndex and extends to the character at index endIndex-1.

Parameters:
beginIndex   The beginning index, inclusive
endIndex   The ending index, exclusive
Returns:
The specified substring

BGString & BGString::replace (char oldch, char newch, long beginIndex = 0, long endIndex = 0)

Replaces oldchar to newchar from index beginIndex to endIndex-1.

Parameters:
oldch   Character to replace
oldch   Character to insert instead
beginIndex   The beginning index, inclusive
endIndex   The ending index, exclusive
Returns:
Reference to own instance

BGString & BGString::add (const char * s)

Concatenate a string to this one.

Parameters:
s   String which will be appended
Returns:
Reference to own instance

BGString & BGString::add (char charToAppend)

Appends a character to string content end.

Parameters:
charToAppend   Character to apppend
Returns:
Reference to own instance

BGString & BGString::add (const BGString & s)

Concatenate a string to this one.

Parameters:
s   String which will be appended
Returns:
Reference to own instance

void BGString::realloc (long plusSize = REALLOCSIZE) [protected]

Reallocates string to actual size + plusSize.

Parameters:
plusSize   Additional space needed

The documentation for this class was generated from the following file:
Generated at Fri Feb 18 10:57:07 2000 for bgclass by doxygen 0.49-991205 written by Dimitri van Heesch, © 1997-1999