Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBstring Class Reference

Yet another string class. **. More...

#include "CTBstring.hxx"

Collaboration diagram for CTBstring:

Collaboration graph
[legend]
List of all members.

Public Methods

 CTBstring ()
 CTBstring (const CTBstring &rhs)
 CTBstring (CTBstring &rhs, bool b_grab)
 CTBstring (const CTBstring &rhs, CTBint i_length)
 CTBstring (const CTBstring &rhs, CTBint i_offset, CTBint i_length)
 CTBstring (const char *c_rhs)
 CTBstring (const char *c_rhs, CTBint i_length)
 ~CTBstring ()
const char * Data () const
CTBint Length () const
bool IsNull () const
bool IsEmpty () const
void Copy (const CTBstring &rhs)
void Copy (const char *c_rhs)
void Copy (char c_rhs)
void Append (const CTBstring &rhs)
void Append (const char *c_rhs)
void Append (const char *c_rhs, CTBint i_length)
void Append (char c_rhs)
void Clear ()
int Compare (const CTBstring &rhs) const
int Compare (const char *c_rhs) const
int CompareCaseBlind (const CTBstring &rhs) const
int CompareCaseBlind (const char *c_rhs) const
bool IsWhite () const
bool IsUpperCase () const
bool IsLowerCase () const
void TrimWhite ()
void CollapseWhite ()
void ToUpperCase ()
void ToLowerCase ()
bool Get (long &i_val, int i_base=0) const
bool Get (unsigned long &i_val, int i_base=0) const
bool Get (int &i_val, int i_base=0) const
bool Get (unsigned int &i_val, int i_base=0) const
bool Get (double &d_val) const
bool Get (float &f_val) const
CTBint FindCharacter (char c, CTBint i_offset=0) const
CTBint FindCharacter (const char *c_set, CTBint i_offset=0) const
CTBint FindCharacter (const CTBstring &set, CTBint i_offset=0) const
CTBstring Escape () const
CTBstring Unescape () const
bool GetLine (istream &is)
void Grab (CTBstring &rhs)
void Dump (int i_indent=0, ostream &os=cout, const char *p_text=0) const
CTBstring & operator= (const CTBstring &rhs)
CTBstring & operator= (const char *c_rhs)
CTBstring & operator= (char c_rhs)
CTBstring & operator+= (const CTBstring &rhs)
CTBstring & operator+= (const char *c_rhs)
CTBstring & operator+= (char c_rhs)
CTBstring & operator<< (const CTBstring &rhs)
CTBstring & operator<< (const char *c_rhs)
CTBstring & operator<< (char c_rhs)
char operator[] (CTBint i_ind) const
CTBstring operator() (CTBint i_length) const
CTBstring operator() (CTBint i_offset, CTBint i_length) const
 operator const char * () const

Static Public Methods

const CTBstring & NullString ()
const CTBstring & EmptyString ()

Private Methods

void Unshare ()
void EnsureUnsharedCapacity (CTBint i_capacity)
void NewString (const char *c_str, CTBint i_len)
void NewString (const char *c_str1, CTBint i_len1, const char *c_str2, CTBint i_len2)
void AppendData (const char *c_str, CTBint i_len)
void Terminate ()
CTBint FindCharacter (const char *c_set, CTBint i_len, CTBint i_offset) const

Private Attributes

CTBsharedBuffer< char > m_sbuf
CTBint mi_offset
CTBint mi_length

Friends

CTBstring operator+ (const CTBstring &lhs, const CTBstring &rhs)
CTBstring operator+ (const CTBstring &lhs, const char *c_rhs)
CTBstring operator+ (const char *c_lhs, const CTBstring &rhs)
bool operator== (const CTBstring &lhs, const CTBstring &rhs)
bool operator< (const CTBstring &lhs, const CTBstring &rhs)
bool operator== (const CTBstring &lhs, const char *c_rhs)
bool operator< (const CTBstring &lhs, const char *c_rhs)
bool operator== (const char *c_lhs, const CTBstring &rhs)
bool operator< (const char *c_lhs, const CTBstring &rhs)
ostream & operator<< (ostream &os, const CTBstring &rhs)

Detailed Description

Yet another string class. **.

Definition at line 19 of file CTBstring.hxx.


Constructor & Destructor Documentation

CTBstring::CTBstring [inline]
 

Construct empty.

Definition at line 17 of file CTBstring.icc.

Referenced by operator()().

CTBstring::CTBstring const CTBstring & rhs
 

Copy constructor.

Definition at line 62 of file CTBstring.cxx.

CTBstring::CTBstring CTBstring & rhs,
bool b_grab
[inline]
 

Grab constructor.

For a pro's and con's using grabs with CTBstring see Grab() .

Definition at line 28 of file CTBstring.icc.

CTBstring::CTBstring const CTBstring & rhs,
CTBint i_length
 

Construct from substring.

Definition at line 73 of file CTBstring.cxx.

CTBstring::CTBstring const CTBstring & rhs,
CTBint i_offset,
CTBint i_length
 

Construct from substring.

Definition at line 84 of file CTBstring.cxx.

CTBstring::CTBstring const char * c_rhs
 

Construct from char*.

Definition at line 99 of file CTBstring.cxx.

CTBstring::CTBstring const char * c_rhs,
CTBint i_length
 

Construct from char* substring.

Definition at line 111 of file CTBstring.cxx.

CTBstring::~CTBstring [inline]
 

Destructor.

Definition at line 40 of file CTBstring.icc.


Member Function Documentation

const char * CTBstring::Data const [inline]
 

Returns a pointer to char.

Definition at line 46 of file CTBstring.icc.

Referenced by Append(), AppendData(), Compare(), CompareCaseBlind(), Escape(), FindCharacter(), Get(), CTBxmlIStream::GetDataStream(), IsLowerCase(), IsUpperCase(), IsWhite(), CTBxmlOStream::PutEscapedString(), Terminate(), Unescape(), Unshare(), operator const char *(), operator+(), operator<<(), and operator[]().

CTBint CTBstring::Length const [inline]
 

Returns length of string.

Definition at line 54 of file CTBstring.icc.

Referenced by Append(), CTBstring(), CollapseWhite(), Compare(), CompareCaseBlind(), CTBxmlIStream::ConvertEntityRef(), Escape(), FindCharacter(), CTBline::FromStream(), CTBattrList::FromXStream(), CTBxmlIStream::GetDataStream(), CTBxmlOStream::PutEscapedString(), CTBxmlOStream::PutTaggedValue(), Terminate(), ToLowerCase(), ToUpperCase(), Unescape(), Unshare(), operator+(), operator<<(), and operator[]().

bool CTBstring::IsNull const [inline]
 

Returns true if string is in `null' state.

Definition at line 62 of file CTBstring.icc.

bool CTBstring::IsEmpty const [inline]
 

Returns true if string is not in `null' state, but empty.

Definition at line 70 of file CTBstring.icc.

void CTBstring::Copy const CTBstring & rhs
 

Copy string.

Definition at line 123 of file CTBstring.cxx.

Referenced by operator=().

void CTBstring::Copy const char * c_rhs
 

Copy char*.

Definition at line 136 of file CTBstring.cxx.

void CTBstring::Copy char c_rhs
 

Copy char.

Definition at line 146 of file CTBstring.cxx.

void CTBstring::Append const CTBstring & rhs
 

Append string.

Definition at line 159 of file CTBstring.cxx.

Referenced by operator+=(), and operator<<().

void CTBstring::Append const char * c_rhs
 

Append char*.

Definition at line 169 of file CTBstring.cxx.

void CTBstring::Append const char * c_rhs,
CTBint i_length
 

Append char*.

Definition at line 179 of file CTBstring.cxx.

void CTBstring::Append char c_rhs
 

Append char.

Definition at line 189 of file CTBstring.cxx.

void CTBstring::Clear [inline]
 

Reset the string to an empty string.

Definition at line 78 of file CTBstring.icc.

Referenced by CTBxmlLexerToken::Clear(), CTBxmlToken::Clear(), CTBxmlIStream::Close(), CTBxmlIStream::Get(), and CTBxmlIStream::GetDataStream().

int CTBstring::Compare const CTBstring & rhs const
 

Compare to string.

Returns an integer less than, equal to, or greater than zero if this is found, respectively, to be less than, to match, or be greater than rhs. Null strings are equivalent to empty strings in this comparison.

Definition at line 219 of file CTBstring.cxx.

Referenced by operator<(), and operator==().

int CTBstring::Compare const char * c_rhs const
 

Compare to char*.

Returns an integer less than, equal to, or greater than zero if this is found, respectively, to be less than, to match, or be greater than c_rhs. Null strings are equivalent to empty strings in this comparison.

Definition at line 239 of file CTBstring.cxx.

int CTBstring::CompareCaseBlind const CTBstring & rhs const
 

Case blind comparison with a string.

Returns an integer less than, equal to, or greater than zero if this is found, respectively, to be less than, to match, or be greater than rhs. Null strings are equivalent to empty strings in this comparison.

Definition at line 259 of file CTBstring.cxx.

int CTBstring::CompareCaseBlind const char * c_rhs const
 

Case blind comparison with a char*.

Returns an integer less than, equal to, or greater than zero if this is found, respectively, to be less than, to match, or be greater than c_rhs. Null strings are equivalent to empty strings in this comparison.

Definition at line 282 of file CTBstring.cxx.

bool CTBstring::IsWhite const
 

Returns true if all characters of string are white space.

White space characters are (in the "C" locale): space, form-feed('\f'), newline('\n'), carriage return('\r'), horizontal tab('\t'), and vertical tab ('\v'). Note, that true is returned for empty and null strings.

Definition at line 306 of file CTBstring.cxx.

bool CTBstring::IsUpperCase const
 

Returns true if all alphabetic characters of the string are upper case.

Note, that true is returned for empty and null strings.

Definition at line 322 of file CTBstring.cxx.

bool CTBstring::IsLowerCase const
 

Returns true if all alphabetic characters of the string are lower case.

Note, that true is returned for empty and null strings.

Definition at line 341 of file CTBstring.cxx.

void CTBstring::TrimWhite
 

Trims all white space from the head and tail of the string.

For the set of white space characters see IsWhite() .

Definition at line 360 of file CTBstring.cxx.

Referenced by CTBline::SetupString().

void CTBstring::CollapseWhite
 

Replace all sequences of white space by a single blank.

Note, that leading and trailing white space is not removed but also just replaced by a single blank. To remove it use Trim() . For the set of white space characters see IsWhite() .

Definition at line 384 of file CTBstring.cxx.

void CTBstring::ToUpperCase
 

Convert all characters to upper case.

Definition at line 412 of file CTBstring.cxx.

void CTBstring::ToLowerCase
 

Convert all characters to lower case.

Definition at line 427 of file CTBstring.cxx.

Referenced by CTBline::SetupString().

bool CTBstring::Get long & i_val,
int i_base = 0
const
 

Convert string to long integer.

Definition at line 442 of file CTBstring.cxx.

bool CTBstring::Get unsigned long & i_val,
int i_base = 0
const
 

Convert string to unsigned long integer.

Definition at line 453 of file CTBstring.cxx.

bool CTBstring::Get int & i_val,
int i_base = 0
const
 

Convert string to int integer.

Definition at line 464 of file CTBstring.cxx.

bool CTBstring::Get unsigned int & i_val,
int i_base = 0
const
 

Convert string to unsigned int integer.

Definition at line 475 of file CTBstring.cxx.

bool CTBstring::Get double & d_val const
 

Convert string to double floating point value.

Definition at line 486 of file CTBstring.cxx.

bool CTBstring::Get float & f_val const
 

Convert string to float floating point value.

Definition at line 497 of file CTBstring.cxx.

CTBint CTBstring::FindCharacter char c,
CTBint i_offset = 0
const [inline]
 

Find first occurence of character c.

Scans the string starting at offset i_offset for the character c. The method returns the index of the first match. If no match found, the length of this is returned. If i_offset is < 0 it is set to 0 and the full string is processed. If i_offset is >= Length(), a return value of Length() is returned.

Definition at line 96 of file CTBstring.icc.

Referenced by Escape(), FindCharacter(), and Unescape().

CTBint CTBstring::FindCharacter const char * c_set,
CTBint i_offset = 0
const
 

Find first occurence of a character from the set given by c_set.

Scans the string starting at offset i_offset for a character in the set given by c_set. The method returns the index of the first match. If no match found, the length of this is returned. If i_offset is < 0 it is set to 0 and the full string is processed. If i_offset is >= Length(), a return value of Length() is returned.

Definition at line 515 of file CTBstring.cxx.

CTBint CTBstring::FindCharacter const CTBstring & set,
CTBint i_offset = 0
const [inline]
 

Find first occurence of a character in set set.

Scans the string starting at offset i_offset for a character in the set given by set. The method returns the index of the first match. If no match found, the length of this is returned. If i_offset is < 0 it is set to 0 and the full string is processed. If i_offset is >= Length(), a return value of Length() is returned.

Definition at line 111 of file CTBstring.icc.

CTBstring CTBstring::Escape const
 

Returns a string with all non-blank white space characters escaped.

Definition at line 523 of file CTBstring.cxx.

Referenced by CTBxmlLexerToken::ToStream(), and CTBxmlToken::ToStream().

CTBstring CTBstring::Unescape const
 

Returns a string with all 'x' type escape sequences translated.

\

Definition at line 565 of file CTBstring.cxx.

bool CTBstring::GetLine istream & is
 

Get a line from istream is.

Todo:
Proper handling of long lines -- handling of continuation lines

Definition at line 625 of file CTBstring.cxx.

Referenced by CTBline::FromStream().

void CTBstring::Grab CTBstring & rhs [inline]
 

Grab resources.

The resources allocated for rhs will be transfered to this. Note, that a normal copy or an assignment are very cheap operations since CTBstring uses a reference counted shared buffer implementation. Therefore a grab not much faster and should only be used when the context requires that the rhs string is nulled, e.g. in the implementation of grabs of objects that embed a CTBstring.

Definition at line 128 of file CTBstring.icc.

Referenced by CTBxmlToken::Grab().

void CTBstring::Dump int i_indent = 0,
ostream & os = cout,
const char * p_text = 0
const
 

Dump.

Definition at line 645 of file CTBstring.cxx.

Referenced by CTBxmlLexerToken::Dump(), CTBxmlIStream::Dump(), and CTBxmlToken::Dump().

CTBstring & CTBstring::operator= const CTBstring & rhs [inline]
 

Assign string (see Copy(const CTBstring&) ).

Definition at line 145 of file CTBstring.icc.

CTBstring & CTBstring::operator= const char * c_rhs [inline]
 

Assign char* (see Copy(const char*) ).

Definition at line 153 of file CTBstring.icc.

CTBstring & CTBstring::operator= char c_rhs [inline]
 

Assign char (see Copy(char) ).

Definition at line 161 of file CTBstring.icc.

CTBstring & CTBstring::operator+= const CTBstring & rhs [inline]
 

Append string (see Append(const CTBstring&) ).

Definition at line 174 of file CTBstring.icc.

CTBstring & CTBstring::operator+= const char * c_rhs [inline]
 

Append char* (see Append(const char*) ).

Definition at line 182 of file CTBstring.icc.

CTBstring & CTBstring::operator+= char c_rhs [inline]
 

Append char (see Append(char) ).

Definition at line 190 of file CTBstring.icc.

CTBstring & CTBstring::operator<< const CTBstring & rhs [inline]
 

Append string (see Append(const CTBstring&) ).

Definition at line 203 of file CTBstring.icc.

CTBstring & CTBstring::operator<< const char * c_rhs [inline]
 

Append char* (see Append(const char*) ).

Definition at line 211 of file CTBstring.icc.

CTBstring & CTBstring::operator<< char c_rhs [inline]
 

Append char (see Append(char) ).

Definition at line 219 of file CTBstring.icc.

char CTBstring::operator[] CTBint i_ind const
 

Returns character at position i_ind.

A value of 0 is returned if i_ind is < 0 or > Length().

Definition at line 664 of file CTBstring.cxx.

CTBstring CTBstring::operator() CTBint i_length const [inline]
 

Create substring.

Definition at line 232 of file CTBstring.icc.

CTBstring CTBstring::operator() CTBint i_offset,
CTBint i_length
const [inline]
 

Create substring.

Definition at line 239 of file CTBstring.icc.

CTBstring::operator const char * const
 

Convert to char*.

The returned pointer is valid as long as the CTBstring object is alive and as long as it is not mmodified. Note, that returned pointer is always non-null, it refers to an empty string ("") if the CTBstring object is in the IsNull() state.

Definition at line 681 of file CTBstring.cxx.

const CTBstring & CTBstring::NullString [static]
 

Returns reference of a Null string.

Definition at line 766 of file CTBstring.cxx.

Referenced by CTBattrList::operator[]().

const CTBstring & CTBstring::EmptyString [static]
 

Returns reference of an Empty string.

Definition at line 775 of file CTBstring.cxx.

Referenced by CTBxmlIStream::GetDataStream(), and CTBxmlIStream::GetTaggedValue().

void CTBstring::Unshare [private]
 

Make sure the string isn't shared and isn't a substring.

Definition at line 784 of file CTBstring.cxx.

Referenced by CollapseWhite(), ToLowerCase(), and ToUpperCase().

void CTBstring::EnsureUnsharedCapacity CTBint i_capacity [private]
 

Get enough writable buffer.

This method makes sure that the buffer is unshared and has space for i_capacity characters plus a terminating zero. Note, that it assumes that the whole buffer is written afterwards, it will not preserve the context of a substring !!

Definition at line 804 of file CTBstring.cxx.

Referenced by AppendData(), and NewString().

void CTBstring::NewString const char * c_str,
CTBint i_len
[private]
 

New string from 1 source.

If c_str is null the CTBstring object will be reset to a null string. Otherwise a string with i_len characters is created. Note that this method expects that there are no null characters in c_str[0] ... c_str[i_len-1] .

Definition at line 834 of file CTBstring.cxx.

Referenced by CTBstring(), Copy(), Terminate(), Unshare(), and operator+().

void CTBstring::NewString const char * c_str1,
CTBint i_len1,
const char * c_str2,
CTBint i_len2
[private]
 

New string from 2 sources.

If c_str1 and c_str2 are null the CTBstring object will be reset to a null string. Otherwise the first i_len1 characters of the C string c_str1 and the first i_len2 characters of the C string c_str2 are concatinated. Note that this method exprects that there are no null characters in c_str1[0] ... c_str1[i_len1-1] and c_str2[0] ... c_str2[i_len2-1].

Definition at line 864 of file CTBstring.cxx.

void CTBstring::AppendData const char * c_str,
CTBint i_len
[private]
 

Internal append engine.

Definition at line 891 of file CTBstring.cxx.

Referenced by Append().

void CTBstring::Terminate [private]
 

Terminate a substring.

Definition at line 925 of file CTBstring.cxx.

Referenced by operator const char *().

CTBint CTBstring::FindCharacter const char * c_set,
CTBint i_len,
CTBint i_offset
const [private]
 

Find first occurence of a character in set c_set with length i_len.

Scans the string starting at offset i_offset for a character in the set c_set[0],...c_set[i_len-1]. The method returns the index of the first match. If no match found, the length of this is returned. If i_offset is < 0 it is set to 0 and the full string is processed. If i_offset is >= Length(), a return value of Length() is returned.

Definition at line 951 of file CTBstring.cxx.


Friends And Related Function Documentation

CTBstring operator+ const CTBstring & lhs,
const CTBstring & rhs
[friend]
 

Concatinate string + string.

Definition at line 711 of file CTBstring.cxx.

CTBstring operator+ const CTBstring & lhs,
const char * c_rhs
[friend]
 

Concatinate string + char*.

Definition at line 726 of file CTBstring.cxx.

CTBstring operator+ const char * c_lhs,
const CTBstring & rhs
[friend]
 

Concatinate char* + string.

Definition at line 741 of file CTBstring.cxx.

bool operator== const CTBstring & lhs,
const CTBstring & rhs
[friend]
 

Comparison string - string.

Definition at line 255 of file CTBstring.icc.

bool operator< const CTBstring & lhs,
const CTBstring & rhs
[friend]
 

Comparison string - string.

Definition at line 265 of file CTBstring.icc.

bool operator== const CTBstring & lhs,
const char * c_rhs
[friend]
 

Comparison string - char*.

Definition at line 275 of file CTBstring.icc.

bool operator< const CTBstring & lhs,
const char * c_rhs
[friend]
 

Comparison string - char*.

Definition at line 285 of file CTBstring.icc.

bool operator== const char * c_lhs,
const CTBstring & rhs
[friend]
 

Comparison char* - string.

Definition at line 295 of file CTBstring.icc.

bool operator< const char * c_lhs,
const CTBstring & rhs
[friend]
 

Comparison char* - string.

Definition at line 305 of file CTBstring.icc.

ostream & operator<< ostream & os,
const CTBstring & rhs
[friend]
 

ostream insertion operator.

Definition at line 756 of file CTBstring.cxx.


Member Data Documentation

CTBsharedBuffer<char> CTBstring::m_sbuf [private]
 

shared char buffer.

Definition at line 147 of file CTBstring.hxx.

CTBint CTBstring::mi_offset [private]
 

substring offset.

Definition at line 148 of file CTBstring.hxx.

CTBint CTBstring::mi_length [private]
 

length.

Definition at line 149 of file CTBstring.hxx.


The documentation for this class was generated from the following files:
Generated at Fri Oct 24 18:14:11 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001