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 Member Functions

 skString ()
 Default Constructor - constructs a blank string.

 skString (const skString &)
 Copy Constructor.

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

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

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

virtual ~skString ()
 Destructor.

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

skString & operator= (Char c)
 Assigns a character.

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.

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

bool operator== (const Char *) const
 Equality operator.

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

bool operator!= (const Char *) const
 Inequality operator.

 operator const Char * () const
 Conversion operator.

const Char * ptr () const
 Accesses underlying buffer.

const Char * c_str () const
 Accesses underlying buffer.

bool equalsIgnoreCase (const skString &) const
 Case-insensitive equality.

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

Char at (USize index) const
 Returns a character within the string.

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

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

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

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

USize length () const
 Length of the string.

int indexOf (const skString &s) const
 returns the index of the first occurrence of the given string within the string

int indexOf (Char c) const
 returns the index of the first occurrence of the given character within the string

int indexOfLast (Char c) const
 returns the index of the last occurrence of the given character within the string

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

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

skString ltrim () const
skString removeInitialBlankLines () const
 This method removes any initial blank lines from the given string.

void writeToFile (const skString &filename)
 Writes the string to a file.

skString replace (const skString &old_substr, const skString &new_substr) const
 Replaces a substring with another.

skString replace (const Char *old_substr, const Char *new_substr) const
 Replaces a substring with another.

void replaceInPlace (Char old_char, Char new_char)
 This method replaces a character with a different one within this string.


Static Public Member Functions

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 (Char ch)
 Constructs a string from a character.

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

skString copyFromBuffer (const Char *buffer, USize length)
 Constructs a string from the subset of a buffer, the contents are copied.

skString readFromFile (const skString &filename)
 Reads the contents of a file as a string.

skString addStrings (const skString &s1, const skString &s2)
 Efficiently adds 2 strings.

skString addStrings (const skString &s1, const skString &s2, const skString &s3)
 Efficiently adds 3 strings.

skString addStrings (const skString &s1, const skString &s2, const skString &s3, const skString &s4)
 Efficiently adds 4 strings.

skString addStrings (const skString &s1, const skString &s2, const skString &s3, const skString &s4, const skString &s5)
 Efficiently adds 5 strings.

skString addStrings (const skString &s1, const skString &s2, const skString &s3, const skString &s4, const skString &s5, const skString &s6)
 Efficiently adds 6 strings.

skString addStrings (const skString &s1, const skString &s2, const skString &s3, const skString &s4, const skString &s5, const skString &s6, const skString &s7)
 Efficiently adds 7 strings.

skString addStrings (const skString &s1, const skString &s2, const skString &s3, const skString &s4, const skString &s5, const skString &s6, const skString &s7, const skString &s8)
 Efficiently adds 8 strings.


Protected Member Functions

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

void assign (const 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 - this is null if the string is blank.


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 Char *   )  [inline]
 

Constructor - from a null-terminated c-string.

Remarks:
not available in Symbian version

skString::skString const Char *  buffer,
USize  len
[inline]
 

Constructor - from a non null-terminated buffer.

Remarks:
not available in Symbian version
Parameters:
buffer - the buffer to be copied from
len - the length of the data to be copied

skString::skString const Char  repeatChar,
USize  len
 

Constructor - a repeated list of characters.

Remarks:
not available in Symbian version
Parameters:
repeatChar - the character to be repeated
len - the number of times the character is repeated


Member Function Documentation

skString skString::addStrings const skString &  s1,
const skString &  s2,
const skString &  s3,
const skString &  s4,
const skString &  s5,
const skString &  s6,
const skString &  s7,
const skString &  s8
[static]
 

Efficiently adds 8 strings.

Exceptions:
Symbian - a leaving function

skString skString::addStrings const skString &  s1,
const skString &  s2,
const skString &  s3,
const skString &  s4,
const skString &  s5,
const skString &  s6,
const skString &  s7
[static]
 

Efficiently adds 7 strings.

Exceptions:
Symbian - a leaving function

skString skString::addStrings const skString &  s1,
const skString &  s2,
const skString &  s3,
const skString &  s4,
const skString &  s5,
const skString &  s6
[static]
 

Efficiently adds 6 strings.

Exceptions:
Symbian - a leaving function

skString skString::addStrings const skString &  s1,
const skString &  s2,
const skString &  s3,
const skString &  s4,
const skString &  s5
[static]
 

Efficiently adds 5 strings.

Exceptions:
Symbian - a leaving function

skString skString::addStrings const skString &  s1,
const skString &  s2,
const skString &  s3,
const skString &  s4
[static]
 

Efficiently adds 4 strings.

Exceptions:
Symbian - a leaving function

skString skString::addStrings const skString &  s1,
const skString &  s2,
const skString &  s3
[static]
 

Efficiently adds 3 strings.

Exceptions:
Symbian - a leaving function

skString skString::addStrings const skString &  s1,
const skString &  s2
[static]
 

Efficiently adds 2 strings.

Exceptions:
Symbian - a leaving function

void skString::assign const Char *  ,
int  len = 0
[protected]
 

Assigns another buffer to this one, and copies it.

Exceptions:
Symbian - a leaving function

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

const Char * skString::c_str  )  const [inline]
 

Accesses underlying buffer.

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

skString skString::copyFromBuffer const Char *  buffer,
USize  length
[static]
 

Constructs a string from the subset of a buffer, the contents are copied.

Exceptions:
Symbian - a leaving function

bool skString::equalsIgnoreCase const skString &   )  const
 

Case-insensitive equality.

Remarks:
Symbian version performs a folding comparison
Returns:
true if the other string is the same as the current one, ignoring case

skString skString::from Char  ch  )  [static]
 

Constructs a string from a character.

Exceptions:
Symbian - a leaving function

skString skString::from float   )  [static]
 

Constructs a string from a float.

Exceptions:
Symbian - a leaving function

skString skString::from USize   )  [static]
 

Constructs a string from an unsigned integer.

Exceptions:
Symbian - a leaving function

skString skString::from int   )  [static]
 

Constructs a string from a signed integer.

Exceptions:
Symbian - a leaving function

skString skString::fromBuffer 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

Exceptions:
Symbian - a leaving function

int skString::indexOf Char  c  )  const
 

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

Returns:
an index, or -1 if not found

int skString::indexOf const skString &  s  )  const
 

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

Returns:
an index, or -1 if not found

int skString::indexOfLast Char  c  )  const
 

returns the index of the last 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 skString::literal const Char *   )  [static]
 

Constructs a string from static string - the static string is *not* copied.

Exceptions:
Symbian - a leaving function

skString skString::ltrim  )  const
 

Returns:
returns a version of this string with leading blanks removed
Exceptions:
Symbian - a leaving function

skString::operator const Char *  )  const [inline]
 

Conversion operator.

Remarks:
not available in Symbian version
Returns:
a pointer to the buffer contained within the P_String object

bool skString::operator!= const Char *   )  const
 

Inequality operator.

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

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

Inequality operator.

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

skString skString::operator+ const skString &   )  const
 

Addition operator.

Returns:
a String that contains this string followed by the other string
Exceptions:
Symbian - a leaving function

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

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

Returns:
this string
Exceptions:
Symbian - a leaving function

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

Comparison operator.

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

skString & skString::operator= const Char *   ) 
 

Assignment operator - dereferences the P_String object and makes a new one by copying the given buffer.

Exceptions:
Symbian - a leaving function

skString & skString::operator= Char  c  ) 
 

Assigns a character.

Parameters:
c - the character to be assigned
Exceptions:
Symbian - a leaving function

bool skString::operator== const Char *   )  const [inline]
 

Equality operator.

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

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

Equality operator.

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

const Char * skString::ptr  )  const [inline]
 

Accesses underlying buffer.

Remarks:
not available in Symbian version
Returns:
a pointer to the buffer contained within the P_String object

skString skString::readFromFile const skString &  filename  )  [static]
 

Reads the contents of a file as a string.

Remarks:
not available in Symbian version
Parameters:
filename the name of the file to read from

skString skString::removeInitialBlankLines  )  const
 

This method removes any initial blank lines from the given string.

This is useful for trimming the beginning of methods in Simkin scripts.

Returns:
returns the trimmed string
Exceptions:
Symbian - a leaving function

skString skString::replace const Char *  old_substr,
const Char *  new_substr
const
 

Replaces a substring with another.

Parameters:
old_substr the substring to be replaced
new_substr the new substring
Exceptions:
Symbian - a leaving function

skString skString::replace const skString &  old_substr,
const skString &  new_substr
const
 

Replaces a substring with another.

Parameters:
old_substr the substring to be replaced
new_substr the new substring
Exceptions:
Symbian - a leaving function

void skString::replaceInPlace Char  old_char,
Char  new_char
 

This method replaces a character with a different one within this string.

The underlying data *is* modified

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
Exceptions:
Symbian - a leaving function

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
Exceptions:
Symbian - a leaving function

void skString::writeToFile const skString &  filename  ) 
 

Writes the string to a file.

Remarks:
not available in Symbian version
Parameters:
filename the name of the file to write to


The documentation for this class was generated from the following files:
Generated on Fri Dec 17 20:27:35 2004 for Simkin by doxygen1.3