Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

look::LookString Class Reference

A string class. More...

#include <lkstring.h>

Inheritance diagram for look::LookString::

look::LookTypeBase List of all members.

Public Types

enum  StripType { leading = 1, trailing, both }
 Which end to strip.


Public Methods

 LookString (const char *theString)
 Constructor like std::string.

 LookString (const char *theString, stringBaseType::size_type theSize)
 Constructor like std::string.

 LookString (const LookString &theString)
 Copy constructor.

 LookString (const LookString &theString, stringBaseType::size_type theStart, stringBaseType::size_type theSize)
 Copy constructor like std::string.

 LookString (const stringBaseType &theString)
 Copy constructor.

 LookString (stringBaseType::size_type theSize, char theChar)
 Constructor like std::string. More...

 LookString ()
 Default Constructor.

 ~LookString (void)
 Destructor.

LookString& operator= (const LookString &theOther)
 Assignment.

LookString& operator= (const char *theString)
 Assignment from const char*.

LookString& operator= (stringBaseType theString)
 Assignment from std::string.

char& operator[] (int position)
 Operator[] like std::string.

char operator[] (int position) const
 Operator[] like std::string.

 operator const char * (void) const
 Cast to const char*. More...

LookTypeBaseGetNewCopy (void) const
 Get a new copy. More...

long GetTypeID (void) const
 Get Type ID. More...

void Strip (StripType theStripType, char theChar)
 Strip character from ends. More...

void Strip (StripType theStripType, const LookString &theChars)
 Strip characters from ends. More...

void StripNotIn (StripType theStripType, const LookString &theChars)
 Strip characters from ends. More...

void ToLower (void)
 Converts to lowercase using tolower.

void ToUpper (void)
 Converts to uppercase using toupper.

int ReplaceStrings (const LookString &theFromString, const LookString &theToString)
 Replace strings. More...


Detailed Description

A string class.

This is essentially std::string but also a LookTypeBase and there are a couple of other methods that I wanted.

Remember std::string doesn't have a virtual destructor, so take care with pointers to std::string (don't use them?).

(otoh LookTypeBase is designed to be used as pointers).


Constructor & Destructor Documentation

look::LookString::LookString ( stringBaseType::size_type theSize,
char theChar )
 

Constructor like std::string.

Creates a string of theSize theChars.

Parameters:
theSize   Number of characters in the new string
theChar   Character to use.


Member Function Documentation

LookTypeBase * look::LookString::GetNewCopy ( void ) const [virtual]
 

Get a new copy.

Virtual copy constructor, aka clone.

Returns:
A new copy of this. (You are responsible for deleting it).

Reimplemented from look::LookTypeBase.

long look::LookString::GetTypeID ( void ) const [virtual]
 

Get Type ID.

Pseudo-rtti, or isA.

Returns:
LookStringID

Reimplemented from look::LookTypeBase.

int look::LookString::ReplaceStrings ( const LookString & theFromString,
const LookString & theToString )
 

Replace strings.

Eg ReplaceStrings( "fred", "jim" ) on "fred lived with other fred" will give "jim lived with other jim" and return 2.

Parameters:
theFromString   String to replace
theToString   String to replace with
Returns:
How many were replaced

void look::LookString::Strip ( StripType theStripType,
const LookString & theChars )
 

Strip characters from ends.

Strips any of the characters in theChars from the ends of the string.

Eg Strip( LookString::both, " _" ) on " _ fred _was_ here " will give "fred _was_ here".

Parameters:
theStripType   leading, trailing or both
theChars   Characters to strip. Eg " \t
" strips whitespace.

void look::LookString::Strip ( StripType theStripType,
char theChar )
 

Strip character from ends.

Strips the character theChar from the ends of the string.

Eg Strip( LookString::both, ' ' ) on " fred was here " will give "fred was here".

Parameters:
theStripType   leading, trailing or both
theChar   Character to strip

void look::LookString::StripNotIn ( StripType theStripType,
const LookString & theChars )
 

Strip characters from ends.

Strips any of the characters NOT in theChars from the ends of the string.

Eg StripNotIn( LookString::both, "123" ) on "fred lived at 22 High Street. He moved there on the 21st" will give "22 High Street. He moved there on the 21".

Parameters:
theStripType   leading, trailing or both
theChars   Characters not to strip. Eg "0123456789" strips all but digits.

look::LookString::operator const char * ( void ) const
 

Cast to const char*.

Yes, I know there are reasons why std::string doesn't have this cast but I find it more useful than not.


The documentation for this class was generated from the following files:
Generated at Thu Jan 17 12:53:09 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001