TString Class Reference

This class defines string of characters. More...

#include <String.h>

Inheritance diagram for TString:

Inheritance graph
[legend]
Collaboration diagram for TString:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TString (void)
 Constructor.
 TString (const DWORD &size)
 Constructor.
 TString (const TString &str)
 Copy constructor.
 TString (const char *str)
 Constructor.
 ~TString (void)
 Destructor.
void operator= (const TString &str)
 Operator =.
void ReserveSize (const DWORD &newSize)
 Resize string.
void Clear (void)
 Set this string to "".
void ClearDeallocOff (void)
 Set this string to "".
void Compact (void)
 Set this string to minimal required length (minimal is 1 byte allocated for "").
DWORD Length (void) const
 Returns length of string excluding terminating character.
DWORD Capacity (void) const
 Returns space allocated for string in bytes.
DWORD FreeCapacity (void) const
 Returns count of free characters in string == number characters which may be added without allocating new characters.
BOOL Empty (void) const
 Determines whether string is empty.
const char * GetString (void) const
 Return pointer to C-string.
const char * c_str (void) const
 Return pointer to C-string.
void Add (char c)
 Add character to end of string.
void Add (const char *str)
 Add string to end of this string.
void Add (const TString &str)
 Add another string to end of this string.
void Set (char c)
 Set character to string.
void Set (const char *str)
 Set string to this string.
void Set (const TString &str)
 Add another string to end of this string.
const char & At (const DWORD &index) const
 Returns character at given position.
char & At (const DWORD &index)
 Returns character at given position.
const char & operator[] (const DWORD &index) const
 Returns character at given position.
char & operator[] (const DWORD &index)
 Returns character at given position.
BOOL Compare (const char *str) const
 Compare two strings.
BOOL Compare (const TString &str) const
 Compare two strings.
void TrimSpacesLeft (void)
 This method removes all white spaces from left.
void TrimSpacesRight (void)
 This method removes all white spaces from right.
void TrimSpaces (void)
 This method removes all white spaces from left and right.
TString Substring (const DWORD &startIndex)
 Return substring that begin at position startIndex and continues to end of original string.
TString Substring (const DWORD &startIndex, const DWORD &length)
 Return substring that begin at position STARTINDEX and has length equal to COUNT parameter.
void ToLower (void)
 Converts all characters in string to lowercase if its possible.
void ToUpper (void)
 Converts all characters in string to uppercase if its possible.
int ToInt (void) const
 Converts string to integer.
float ToFloat (void) const
 Converts string to float.

Static Public Member Functions

static TString FromDWORD (const DWORD &value)
 Convert DWORD value to string.
static TString FromINT (const int &value)
 Convert integer value to string.
static TString FromFloat (const float &value)
 Convert double value to string.

Detailed Description

This class defines string of characters.

Symbols are 8bits ASCII.

For returned values it's recommended to use pointers or references to this class.

Definition at line 27 of file String.h.


Constructor & Destructor Documentation

TString::TString void   ) 
 

Constructor.

Creates empty string - "".

Definition at line 22 of file String.cpp.

Referenced by FromDWORD(), FromFloat(), FromINT(), and Substring().

TString::TString const DWORD size  ) 
 

Constructor.

Creates empty string - "" - and allocates specified number of bytes. Number of allocated bytes is always SIZE+1

Parameters:
size [in] number of bytes allocated in this string (Number of allocated bytes is always SIZE+1)

Definition at line 37 of file String.cpp.

TString::TString const TString str  ) 
 

Copy constructor.

Creates identical copy of string.

Parameters:
str [in] original string

Definition at line 51 of file String.cpp.

References alloc, length, and text.

TString::TString const char *  str  ) 
 

Constructor.

Creates string from C-string.

Parameters:
str [in]original string - non NULL C-string terminated with ''

Definition at line 64 of file String.cpp.

TString::~TString void   ) 
 

Destructor.

Definition at line 76 of file String.cpp.


Member Function Documentation

void TString::Add const TString str  ) 
 

Add another string to end of this string.

Parameters:
str [in] string

Definition at line 266 of file String.cpp.

References length, ReserveSize(), and text.

Here is the call graph for this function:

void TString::Add const char *  str  ) 
 

Add string to end of this string.

Parameters:
str [in] non-null string terminated with null character '0'

Definition at line 244 of file String.cpp.

References ReserveSize().

Here is the call graph for this function:

void TString::Add char  c  ) 
 

Add character to end of string.

Parameters:
c [in] new character

Definition at line 228 of file String.cpp.

References ReserveSize().

Referenced by NSFileSystem::TVirtualFileReal::ReadString(), NSFileSystem::TVirtualFileCabinet::ReadString(), TFile::ReadString(), NSFileSystem::TVirtualFileReal::ReadUntil(), NSFileSystem::TVirtualFileCabinet::ReadUntil(), TFile::ReadUntil(), TFile::ReadWord(), NSFileSystem::TFSFileSystem::RegisterMultipleCabinets(), and NSFileSystem::TFSFileSystem::RegisterMultiplePaths().

Here is the call graph for this function:

char & TString::At const DWORD index  )  [inline]
 

Returns character at given position.

Position must be in range!!!

Parameters:
index [in] zero-based index of character
Returns:
character at given position

Definition at line 166 of file String.h.

const char & TString::At const DWORD index  )  const [inline]
 

Returns character at given position.

Position must be in range!!!

Parameters:
index [in] zero-based index of character
Returns:
character at given position

Definition at line 154 of file String.h.

Referenced by NSFileSystem::TFSFileSystem::RegisterMultipleCabinets(), NSFileSystem::TFSFileSystem::RegisterMultiplePaths(), and NSFileSystem::TFSFileSystem::RegisterPath().

const char * TString::c_str void   )  const [inline]
 

Return pointer to C-string.

Returns:
pointer to C-string

Definition at line 142 of file String.h.

Referenced by NSFileSystem::TFSFileSystem::Exists(), NSMeshes::TDeclarationManager::Initialize(), NSMeshes::TMeshManager::LoadRendererResources(), NSFileSystem::TVirtualFileReal::OpenFile(), NSFileSystem::TVirtualFileCabinet::OpenFile(), TFile::Write(), and TLogFile::WriteSTRING().

DWORD TString::Capacity void   )  const [inline]
 

Returns space allocated for string in bytes.

Returns:
space allocated for string in bytes

Definition at line 108 of file String.h.

void TString::Clear void   ) 
 

Set this string to "".

Allocated items doesnt change.

Definition at line 137 of file String.cpp.

Referenced by TFile::ReadString(), TFile::ReadUntil(), and TFile::ReadWord().

void TString::ClearDeallocOff void   ) 
 

Set this string to "".

Allocated items doesnt change.

Method is identical with Clear method.

Definition at line 148 of file String.cpp.

Referenced by NSFileSystem::TVirtualFileReal::ReadString(), NSFileSystem::TVirtualFileCabinet::ReadString(), NSFileSystem::TVirtualFileReal::ReadUntil(), NSFileSystem::TVirtualFileCabinet::ReadUntil(), NSFileSystem::TFSFileSystem::RegisterMultipleCabinets(), and NSFileSystem::TFSFileSystem::RegisterMultiplePaths().

void TString::Compact void   ) 
 

Set this string to minimal required length (minimal is 1 byte allocated for "").

Reallocated items to minimal required size (length+1).

This method helps reduce required memory.

Definition at line 159 of file String.cpp.

BOOL TString::Compare const TString str  )  const
 

Compare two strings.

Returns only TRUE(strings are equal) or NO(not equal). Comparing is case sensitive.

Before comparsion length of strings is compared, only strings with identical length will be compared.

Parameters:
[in] str non-null string to compare with this
Returns:
TRUE if strings are equal, FALSE otherwise

Definition at line 209 of file String.cpp.

References FALSE, length, and text.

BOOL TString::Compare const char *  str  )  const
 

Compare two strings.

Returns only TRUE(strings are equal) or NO(not equal). Comparing is case sensitive.

Before comparsion length of strings is compared, only strings with identical length will be compared. For this is better option compare TString with TString because each contain information about length - here must be length computed for C-string

Parameters:
str non-null string to compare with this
Returns:
TRUE if strings are equal, FALSE otherwise

Definition at line 184 of file String.cpp.

References FALSE.

Referenced by NSXLoader::TXFrame::GetFrameByName().

BOOL TString::Empty void   )  const [inline]
 

Determines whether string is empty.

Definition at line 124 of file String.h.

DWORD TString::FreeCapacity void   )  const [inline]
 

Returns count of free characters in string == number characters which may be added without allocating new characters.

Returns:
count of free characters in string

Definition at line 117 of file String.h.

TString TString::FromDWORD const DWORD value  )  [static]
 

Convert DWORD value to string.

Parameters:
value [in] value to convert

Definition at line 473 of file String.cpp.

References TString().

Here is the call graph for this function:

TString TString::FromFloat const float &  value  )  [static]
 

Convert double value to string.

Parameters:
value [in] value to convert

Definition at line 495 of file String.cpp.

References TString().

Here is the call graph for this function:

TString TString::FromINT const int &  value  )  [static]
 

Convert integer value to string.

Parameters:
value [in] value to convert

Definition at line 484 of file String.cpp.

References TString().

Here is the call graph for this function:

const char * TString::GetString void   )  const [inline]
 

Return pointer to C-string.

Returns:
pointer to C-string

Definition at line 133 of file String.h.

Referenced by TFile::Erase(), NSConfigFile::TConfigFile::LoadConfigFile(), NSConfigFile::TConfigFile::LoadConfigFileFromVFS(), NSMeshes::TDeclarationLoader::LoadDeclarationFromFile(), NSMeshes::TMeshLoader::LoadMeshDataFromFile(), NSMeshes::TMeshLoader::LoadMeshFromFile(), TLogFile::Open(), and TFile::Open().

DWORD TString::Length void   )  const [inline]
 

Returns length of string excluding terminating character.

E.g. for string "test" is length 4.

Returns:
length of string excluding terminating character

Definition at line 99 of file String.h.

Referenced by TGraphicTexture::LoadDDS(), NSFileSystem::TFSFileSystem::RegisterMultipleCabinets(), NSFileSystem::TFSFileSystem::RegisterMultiplePaths(), and NSFileSystem::TFSFileSystem::RegisterPath().

void TString::operator= const TString str  ) 
 

Operator =.

Parameters:
str [in] original string

Definition at line 90 of file String.cpp.

References length, and text.

char & TString::operator[] const DWORD index  )  [inline]
 

Returns character at given position.

Position must be in range!!!

Parameters:
index [in] zero-based index of character
Returns:
character at given position

Definition at line 190 of file String.h.

const char & TString::operator[] const DWORD index  )  const [inline]
 

Returns character at given position.

Position must be in range!!!

Parameters:
index [in] zero-based index of character
Returns:
character at given position

Definition at line 178 of file String.h.

void TString::ReserveSize const DWORD newSize  ) 
 

Resize string.

Original string items are copy to new string. If size in parameter is less or equal than actual size then no changes are made.

Parameters:
newSize [in] new size of string in bytes

Definition at line 119 of file String.cpp.

Referenced by Add().

void TString::Set const TString str  ) 
 

Add another string to end of this string.

Parameters:
str [in] string

Definition at line 335 of file String.cpp.

References length, and text.

void TString::Set const char *  str  ) 
 

Set string to this string.

Identical with operator=.

Parameters:
str [in] non-null string terminated with null character '0'

Definition at line 308 of file String.cpp.

void TString::Set char  c  ) 
 

Set character to string.

After calling this method string contains only one character "c"

Parameters:
c [in] new character

Definition at line 289 of file String.cpp.

Referenced by TFile::Open(), and NSXLoader::TXMaterial::operator=().

TString TString::Substring const DWORD startIndex,
const DWORD count
 

Return substring that begin at position STARTINDEX and has length equal to COUNT parameter.

Parameters:
startIndex [in] position of first character to copy
count [in] length of new substring

Definition at line 443 of file String.cpp.

References TString().

Here is the call graph for this function:

TString TString::Substring const DWORD startIndex  ) 
 

Return substring that begin at position startIndex and continues to end of original string.

If position is invalid empty string is returned.

Parameters:
startIndex [in] position of first character to copy

Definition at line 424 of file String.cpp.

References TString().

Here is the call graph for this function:

float TString::ToFloat void   )  const [inline]
 

Converts string to float.

Definition at line 204 of file String.h.

int TString::ToInt void   )  const [inline]
 

Converts string to integer.

Definition at line 197 of file String.h.

Referenced by NSConfigFile::TConfigFileSection::GetValueBOOL(), NSConfigFile::TConfigFileSection::GetValueDWORD(), NSConfigFile::TConfigFileSection::GetValueINT(), and NSMeshes::TDeclarationManager::Initialize().

void TString::ToLower void   ) 
 

Converts all characters in string to lowercase if its possible.

Definition at line 359 of file String.cpp.

void TString::ToUpper void   ) 
 

Converts all characters in string to uppercase if its possible.

Definition at line 370 of file String.cpp.

void TString::TrimSpaces void   ) 
 

This method removes all white spaces from left and right.

Definition at line 412 of file String.cpp.

References TrimSpacesLeft(), and TrimSpacesRight().

Here is the call graph for this function:

void TString::TrimSpacesLeft void   ) 
 

This method removes all white spaces from left.

Definition at line 381 of file String.cpp.

Referenced by TrimSpaces().

void TString::TrimSpacesRight void   ) 
 

This method removes all white spaces from right.

Definition at line 401 of file String.cpp.

Referenced by TrimSpaces().


The documentation for this class was generated from the following files:
Generated on Wed Nov 28 22:44:02 2007 for Joy4D by  doxygen 1.4.6-NO