NovaTK::NString Class Reference

List of all members.


Detailed Description

NString is a string class intended to contain UTF-8 encoded strings. It is used throughout NovaTK to ensure that the entire API supports Unicode. Its interface is somewhat similar to that of an STL string for familiarity but it is NOT identical.

Public Member Functions

NOVATKAPI Iterator Begin () const
NOVATKAPI Iterator End () const
NOVATKAPI NString ()
NOVATKAPI NString (const char *cstr)
NOVATKAPI NString (const NString &s)
NOVATKAPI NString (nchar c)
NOVATKAPI NString (char c)
NOVATKAPI ~NString ()
NOVATKAPI size_t size () const
NOVATKAPI void clear ()
NOVATKAPI bool empty () const
NOVATKAPI size_t bytes () const
NOVATKAPI NString operator= (const char *cstr)
NOVATKAPI NString operator= (const NString &s)
NOVATKAPI NString operator+= (const char *cstr)
NOVATKAPI NString operator+= (const NString &s)
NOVATKAPI NString operator+= (const char c)
NOVATKAPI NString operator+= (const nchar c)
NOVATKAPI const nchar operator[] (int i) const
NOVATKAPI bool operator== (const NString &s) const
NOVATKAPI bool operator== (const char *cstr) const
NOVATKAPI bool operator!= (const NString &s) const
NOVATKAPI bool operator!= (const char *cstr) const
NOVATKAPI const char * data () const
NOVATKAPI const char * c_str () const
NOVATKAPI void append (const char *cstr, int nbytes)
NOVATKAPI void append (const NString &s, int nchars)
NOVATKAPI void append (const nchar c)
NOVATKAPI size_t copy (NString &out, size_t len, size_t pos=0) const
NOVATKAPI size_t copy (NString &out, size_t len, const NString::Iterator &pos) const
NOVATKAPI void insert (const NString s, size_t pos)
NOVATKAPI void erase (size_t pos, size_t length=1)
NOVATKAPI size_t find (const char c, size_t pos=0) const
NOVATKAPI size_t find (const nchar c, size_t pos=0) const
NOVATKAPI size_t find (const NString &substr, size_t pos=0) const
NOVATKAPI size_t rfind (const char c) const
NOVATKAPI size_t rfind (const nchar c) const
NOVATKAPI size_t rfind (const NString &substr) const
NOVATKAPI size_t rfind (const NString &substr, size_t pos) const
NOVATKAPI int compare (const NString &s) const

Static Public Member Functions

static NOVATKAPI bool validate (const char *data)

Static Public Attributes

static const size_t invalidpos = -1

Classes

class  Iterator

Constructor & Destructor Documentation

NovaTK::NString::NString (  ) 

Constructs an empty string.

NovaTK::NString::NString ( const char *  cstr  ) 

Constructs a string from a C string containing UTF-8 data.

NovaTK::NString::NString ( const NString s  ) 

Constructs a string that is a copy of s.

NovaTK::NString::NString ( nchar  c  ) 

Constructs a string containing the specified UTF-32 character.

NovaTK::NString::NString ( char  c  ) 

Constructs a string containing the specified ASCII character.

NovaTK::NString::~NString (  ) 

Destroys the string.


Member Function Documentation

NOVATKAPI Iterator NovaTK::NString::Begin (  )  const [inline]

Returns:
An iterator pointing at the beginning of the string.

NOVATKAPI Iterator NovaTK::NString::End (  )  const [inline]

Returns:
An iterator pointing at the end of the string.

bool NovaTK::NString::validate ( const char *  data  )  [static]

Validates a whether a given character is valid UTF-8. If there is more than one character in data then only the first on is checked. This is a class utility function. It operates only on the data passed to it and not on the member data of an instance of the class.

Returns:
TRUE if the data is a valid UTF-8 character. Otherwise returns FALSE.

size_t NovaTK::NString::size (  )  const

Returns:
The number of UTF-8 characters in the string.

NOVATKAPI void NovaTK::NString::clear (  )  [inline]

Deletes the entire contents of the string leaving it empty.

NOVATKAPI bool NovaTK::NString::empty (  )  const [inline]

Returns:
TRUE if the string is empty. Otherwise returns FALSE.

size_t NovaTK::NString::bytes (  )  const

Returns:
The number of BYTES in the string.

NString NovaTK::NString::operator= ( const char *  cstr  ) 

Replaces the contents of the string with the contents of cstr.

Parameters:
cstr - C string containing VALID UTF-8 data.

NString NovaTK::NString::operator= ( const NString s  ) 

Replaces the contents of the string with the contents of s.

NString NovaTK::NString::operator+= ( const char *  cstr  ) 

Appends the contents of cstr to the end of this string.

Parameters:
cstr - C string containing VALID UTF-8 data.

NString NovaTK::NString::operator+= ( const NString s  ) 

Appends the contents of s to the end of this string.

NString NovaTK::NString::operator+= ( const char  c  ) 

Appends the ASCII character stored in c to the end of the string.

NString NovaTK::NString::operator+= ( const nchar  c  ) 

Appends the UTF-32 character stored in c to the end of the string.

const nchar NovaTK::NString::operator[] ( int  i  )  const

Returns:
A UTF-32 character representing the character at the position in the string specified by i.

bool NovaTK::NString::operator== ( const NString s  )  const

Returns:
TRUE if s and this string are equal. Otherwise returns FALSE. Note that string comparisons are CASE-SENSITIVE.

bool NovaTK::NString::operator== ( const char *  cstr  )  const

Parameters:
cstr - C string containing VALID UTF-8 data.
Returns:
TRUE if cstr and this string are equal. Otherwise returns FALSE. Note that string comparisons are CASE-SENSITIVE.

bool NovaTK::NString::operator!= ( const NString s  )  const

Returns:
FALSE if s and this string are equal. Otherwise returns TRUE. Note that string comparisons are CASE-SENSITIVE.

bool NovaTK::NString::operator!= ( const char *  cstr  )  const

Parameters:
cstr - C string containing VALID UTF-8 data.
Returns:
FALSE if cstr and this string are equal. Otherwise returns TRUE. Note that string comparisons are CASE-SENSITIVE.

NOVATKAPI const char* NovaTK::NString::data (  )  const [inline]

Returns:
The raw UTF-8 string data stored in the string. Note that the data returned IS NOT NULL terminated.

const char * NovaTK::NString::c_str (  )  const

Returns:
A NULL terminated C string containing the data stored in the string in the UTF-8 encoding.

void NovaTK::NString::append ( const char *  cstr,
int  nbytes 
)

Appends nbytes bytes of the C String cstr to the end of the string. Note that the C String should contain valid UTF-8 data.

void NovaTK::NString::append ( const NString s,
int  nchars 
)

Appends nchars characters of s to the end of this string.

void NovaTK::NString::append ( const nchar  c  ) 

Appends the character c to the end of this string.

size_t NovaTK::NString::copy ( NString out,
size_t  len,
size_t  pos = 0 
) const

Copies a substring from this string to out.

Parameters:
out - The destination of the substring.
len - The length of the substring.
pos - The offset of the substring in this string.
Returns:
The number of characters copied.

size_t NovaTK::NString::copy ( NString out,
size_t  len,
const NString::Iterator pos 
) const

Copies a substring from this string to out.

Parameters:
out - The destination of the substring.
len - The length of the substring.
pos - The offset of the substring in this string.
Returns:
The number of characters copied.

void NovaTK::NString::insert ( const NString  s,
size_t  pos 
)

Inserts the string s into this string at pos.

void NovaTK::NString::erase ( size_t  pos,
size_t  length = 1 
)

Erases characters from the string.

Parameters:
pos - The offset of the characters to be erased.
len - The number of characters to be erased.

size_t NovaTK::NString::find ( const char  c,
size_t  pos = 0 
) const

Finds the specified character character in the string.

Parameters:
c - The character to search for.
pos - Position in the string to start searching from.
Returns:
The position of the first instance of c in the string or invalid_pos if it was not found.

size_t NovaTK::NString::find ( const nchar  c,
size_t  pos = 0 
) const

Finds the specified character character in the string.

Parameters:
c - The character to search for.
pos - Position in the string to start searching from.
Returns:
The position of the first instance of c in the string or invalid_pos if it was not found.

size_t NovaTK::NString::find ( const NString substr,
size_t  pos = 0 
) const

Finds the specified substring in this string.

Parameters:
substr - The substring to search for.
pos - Position in the string to start searching from.
Returns:
The position of the first instance of substr in the string or invalid_pos if it was not found.

size_t NovaTK::NString::rfind ( const char  c  )  const

Searches the string in reverse for the specified character.

Parameters:
c - The character to search for.
Returns:
The position of the first instance of c in the string or invalid_pos if it was not found.

size_t NovaTK::NString::rfind ( const nchar  c  )  const

Searches the string in reverse for the specified character.

Parameters:
c - The character to search for.
Returns:
The position of the first instance of c in the string or invalid_pos if it was not found.

size_t NovaTK::NString::rfind ( const NString substr  )  const

Searches the string in reverse for the specified substring.

Parameters:
substr - The substring to search for.
c - The character to search for.
Returns:
The position of the first instance of substr in the string or invalid_pos if it was not found.

size_t NovaTK::NString::rfind ( const NString substr,
size_t  pos 
) const

Searches the string in reverse for the specified substring.

Parameters:
substr - The substring to search for.
c - The character to search for.
pos - The position to begin searching from.
Returns:
The position of the first instance of substr in the string or invalid_pos if it was not found.

int NovaTK::NString::compare ( const NString s  )  const

Returns:
TRUE if this string and s match, otherwise returns FALSE. Note that string comparisons are CaSE-SeNSitive.


Member Data Documentation

const size_t NovaTK::NString::invalidpos = -1 [static]

Represents an invalid character position. This value will be returned by functions which return character positions in the string.


The documentation for this class was generated from the following files:

Generated on Sat Sep 13 22:34:20 2008 for NovaTK by  doxygen 1.5.5