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

skString Class Reference

This class encapsulates a null-terminated 8-bit c-string It uses a pointer to a string plus a reference count to save copying when passed by value. More...

#include <skString.h>

List of all members.

Public Methods

 skString ()
 Default Constructor - constructs a blank string.

 skString (const char *)
 Constructor - from a null-terminated c-string.

 skString (const unsigned char *)
 Constructor - from a null-terminated c-string.

 skString (const skString&)
 Copy Constructor.

 skString (const unsigned char * buffer, USize len)
 Constructor - from a non null-terminated buffer. More...

 skString (const unsigned char repeatChar, USize len)
 Constructor - a repeated list of characters. More...

virtual ~skString ()
 Destructor.

skString& operator= (const skString&)
 Assignment operator - increments reference count of underlying P_String object.

skString& operator= (const unsigned char *)
 Assignment operator - dereferences the P_String object and makes a new one by copying the given buffer.

skString& operator= (const char *)
 Assignment operator - dereferences the P_String object and makes a new one by copying the given buffer.

bool operator< (const skString&) const
 Comparison operator. More...

bool operator== (const skString&) const
 Equality operator. More...

bool operator== (const unsigned char *) const
 Equality operator. More...

bool operator== (const char *) const
 Equality operator. More...

bool operator!= (const skString&) const
 Inequality operator. More...

bool operator!= (const char *) const
 Inequality operator. More...

bool operator!= (const unsigned char *) const
 Inequality operator. More...

 operator const unsigned char * () const
 Conversion operator. More...

 operator const char * () const
 Conversion operator. More...

USize hash () const
 Returns a hash value for this string.

unsigned char at (USize index) const
 Returns a character within the string. More...

skString substr (USize start,USize length) const
 Returns a substring of this string. More...

skString substr (USize start) const
 Returns the substring from the start up to the end of the current string. More...

skString operator+ (const skString&) const
 Addition operator. More...

skString& operator+= (const skString&)
 Increment operator - dereferences the P_String object, and replaces it with the concatenation of this string and the other one. More...

USize length () const
 Length of the string. More...

int indexOf (char c)
 returns the index of the first occurrence of the given character within the string. More...

int to () const
 Converts the string to an integer.

float toFloat () const
 Converts the string to a float.


Static Public Methods

skString literal (const char *)
 Constructs a string from static string - the static string is *not* copied.

skString from (int)
 Constructs a string from a signed integer.

skString from (USize)
 Constructs a string from an unsigned integer.

skString from (float)
 Constructs a string from a float.

skString from (unsigned char ch)
 Constructs a string from a character.

skString fromBuffer (unsigned char * buffer)
 Constructs a string from a buffer, which is *not* copied. More...


Protected Methods

 skString (P_String *)
 Constructor - internal taking a P_String and not copying it.

 skString (const unsigned char * s,int)
 Constructor - internal, taking a buffer and not copying it.

void assign (const unsigned char *,int len=0)
 Assigns another buffer to this one, and copies it.

void deRef ()
 Dereferences the P_String object, deleting it if the reference count is zero.


Protected Attributes

P_String* pimp
 The underlying string object.


Detailed Description

This class encapsulates a null-terminated 8-bit c-string It uses a pointer to a string plus a reference count to save copying when passed by value.


Constructor & Destructor Documentation

skString::skString ( const unsigned char * s,
USize len )
 

Constructor - from a non null-terminated buffer.

Parameters:
buffer   - the buffer to be copied from
len   - the length of the data to be copied

skString::skString ( const unsigned char repeatChar,
USize len )
 

Constructor - a repeated list of characters.

Parameters:
repeatChar   - the character to be repeated
len   - the number of times the character is repeated


Member Function Documentation

unsigned char skString::at ( USize index ) const [inline]
 

Returns a character within the string.

Parameters:
index   - the index of the character, starting at 0
Returns:
the character, or 0 if the index does not lie within the length of the string

skString skString::fromBuffer ( unsigned char * buffer ) [static]
 

Constructs a string from a buffer, which is *not* copied.

The string will delete the buffer when the reference count reaches zero

int skString::indexOf ( char c )
 

returns the index of the first occurrence of the given character within the string.

Returns:
an index, or -1 if not found

USize skString::length ( ) const [inline]
 

Length of the string.

Returns:
the length of the buffer in the P_String object

skString::operator const char * ( ) const [inline]
 

Conversion operator.

Returns:
a pointer to the buffer contained within the P_String object

skString::operator const unsigned char * ( ) const [inline]
 

Conversion operator.

Returns:
a pointer to the buffer contained within the P_String object

bool skString::operator!= ( const unsigned char * s ) const
 

Inequality operator.

Returns:
true if the other c-string is different to the current one

bool skString::operator!= ( const char * s ) const
 

Inequality operator.

Returns:
true if the other c-string is different to the current one

bool skString::operator!= ( const skString & s ) const
 

Inequality operator.

Returns:
true if the other string is different to the current one

skString skString::operator+ ( const skString & s ) const
 

Addition operator.

Returns:
a String that contains this string followed by the other string

skString & skString::operator+= ( const skString & s )
 

Increment operator - dereferences the P_String object, and replaces it with the concatenation of this string and the other one.

Returns:
this string

bool skString::operator< ( const skString & s ) const [inline]
 

Comparison operator.

Returns:
true if the current string is alphabetically before the other string

bool skString::operator== ( const char * s ) const [inline]
 

Equality operator.

Returns:
true if the other c-string is the same as the current one

bool skString::operator== ( const unsigned char * s ) const [inline]
 

Equality operator.

Returns:
true if the other c-string is the same as the current one

bool skString::operator== ( const skString & s ) const [inline]
 

Equality operator.

Returns:
true if the other string is the same as the current one

skString skString::substr ( USize start ) const
 

Returns the substring from the start up to the end of the current string.

Parameters:
start   - the 0-based start of the substring
Returns:
a new String for the substring, or a blank string if the start does not lie within the current string

skString skString::substr ( USize start,
USize length ) const
 

Returns a substring of this string.

Parameters:
start   - the 0-based start of the substring
length   - the length of the substring
Returns:
a new String for the substring, or a blank string if the start and length do not lie within the current string


The documentation for this class was generated from the following files:
Generated at Wed May 9 11:32:22 2001 for Simkin by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000