Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions

RakNet::RakString Class Reference

String class. More...

#include <RakString.h>

Collaboration diagram for RakNet::RakString:
Collaboration graph
[legend]

List of all members.

Classes

struct  SharedString

Public Member Functions

 RakString ()
 RakString (char input)
 RakString (unsigned char input)
 RakString (const unsigned char *format,...)
 RakString (const char *format,...)
 ~RakString ()
 RakString (const RakString &rhs)
 operator const char * () const
 Implicit return of const char*.
const char * C_String (void) const
 Same as std::string::c_str.
char * C_StringUnsafe (void)
RakStringoperator= (const RakString &rhs)
 Assigment operators.
RakStringoperator= (const char *str)
RakStringoperator= (char *str)
RakStringoperator= (const char c)
RakStringoperator+= (const RakString &rhs)
 Concatenation.
RakStringoperator+= (const char *str)
RakStringoperator+= (char *str)
RakStringoperator+= (const char c)
unsigned char operator[] (const unsigned int position) const
 Character index. Do not use to change the string however.
size_t Find (const char *stringToFind, size_t pos=0)
bool operator== (const RakString &rhs) const
 Equality.
bool operator== (const char *str) const
bool operator== (char *str) const
bool operator< (const RakString &right) const
bool operator<= (const RakString &right) const
bool operator> (const RakString &right) const
bool operator>= (const RakString &right) const
bool operator!= (const RakString &rhs) const
 Inequality.
bool operator!= (const char *str) const
bool operator!= (char *str) const
const char * ToLower (void)
 Change all characters to lowercase.
const char * ToUpper (void)
 Change all characters to uppercase.
void Set (const char *format,...)
 Set the value of the string.
RakString Assign (const char *str, size_t pos, size_t n)
bool IsEmpty (void) const
 Returns if the string is empty. Also, C_String() would return "".
size_t GetLength (void) const
 Returns the length of the string.
void Replace (unsigned index, unsigned count, unsigned char c)
 Replace character(s) in starting at index, for count, with c.
void SetChar (unsigned index, unsigned char c)
 Replace character at index with c.
void SetChar (unsigned index, RakNet::RakString s)
 Replace character at index with string s.
void Truncate (unsigned length)
 Make sure string is no longer than length.
RakString SubStr (unsigned int index, unsigned int count) const
void Erase (unsigned int index, unsigned int count)
 Erase characters out of the string at index for count.
void TerminateAtFirstCharacter (char c)
 Set the first instance of c with a NULL terminator.
void TerminateAtLastCharacter (char c)
 Set the last instance of c with a NULL terminator.
void RemoveCharacter (char c)
 Remove all instances of c.
void AppendBytes (const char *bytes, unsigned int count)
int StrCmp (const RakString &rhs) const
 Compare strings (case sensitive).
int StrICmp (const RakString &rhs) const
 Compare strings (not case sensitive).
void Clear (void)
 Clear the string.
void Printf (void)
 Print the string to the screen.
void FPrintf (FILE *fp)
 Print the string to a file.
bool IPAddressMatch (const char *IP)
 Does the given IP address match the IP address encoded into this string, accounting for wildcards?
bool ContainsNonprintableExceptSpaces (void) const
 Does the string contain non-printable characters other than spaces?
bool IsEmailAddress (void) const
 Is this a valid email address?
RakNet::RakStringURLEncode (void)
 URL Encode the string. See http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4029/.
RakNet::RakStringURLDecode (void)
 URL decode the string.
RakNet::RakStringSQLEscape (void)
 Scan for quote, double quote, and backslash and prepend with backslash.
RakNet::RakStringMakeFilePath (void)
 Fix to be a file path, ending with /.
void Serialize (BitStream *bs) const
void SerializeCompressed (BitStream *bs, int languageId=0, bool writeLanguageId=false) const
bool Deserialize (BitStream *bs)
bool DeserializeCompressed (BitStream *bs, bool readLanguageId=false)
 RakString (SharedString *_sharedString)

Static Public Member Functions

static RakNet::RakString NonVariadic (const char *str)
static unsigned long ToInteger (const char *str)
 Has the string into an unsigned int.
static unsigned long ToInteger (const RakString &rs)
static void FreeMemory (void)
static void FreeMemoryNoMutex (void)
static void Serialize (const char *str, BitStream *bs)
 Static version of the Serialize function.
static void SerializeCompressed (const char *str, BitStream *bs, int languageId=0, bool writeLanguageId=false)
 Static version of the SerializeCompressed function.
static bool Deserialize (char *str, BitStream *bs)
 Static version of the Deserialize() function.
static bool DeserializeCompressed (char *str, BitStream *bs, bool readLanguageId=false)
 Static version of the DeserializeCompressed() function.
static const char * ToString (int64_t i)
static const char * ToString (uint64_t i)
static size_t GetSizeToAllocate (size_t bytes)
static int RakStringComp (RakString const &key, RakString const &data)
static void LockMutex (void)
static void UnlockMutex (void)

Public Attributes

SharedStringsharedString

Static Public Attributes

static SharedString emptyString = {0,0,0,"",""}
static DataStructures::List
< SharedString * > 
freeList
static unsigned int nPos = (unsigned int) -1
 Means undefined position.

Protected Member Functions

void Allocate (size_t len)
void Assign (const char *str)
void Assign (const char *str, va_list ap)
void Clone (void)
void Free (void)
unsigned char ToLower (unsigned char c)
unsigned char ToUpper (unsigned char c)
void Realloc (SharedString *sharedString, size_t bytes)

Detailed Description

String class.

Has the following improvements over std::string -Reference counting: Suitable to store in lists -Variadic assignment operator -Doesn't cause linker errors

Definition at line 22 of file RakString.h.


Constructor & Destructor Documentation

RakString::RakString (  ) 

Definition at line 42 of file RakString.cpp.

Here is the caller graph for this function:

RakString::RakString ( char  input  ) 

Definition at line 50 of file RakString.cpp.

Here is the call graph for this function:

RakString::RakString ( unsigned char  input  ) 

Definition at line 57 of file RakString.cpp.

Here is the call graph for this function:

RakString::RakString ( const unsigned char *  format,
  ... 
)

Definition at line 64 of file RakString.cpp.

Here is the call graph for this function:

RakString::RakString ( const char *  format,
  ... 
)

Definition at line 69 of file RakString.cpp.

Here is the call graph for this function:

RakString::~RakString (  ) 

Definition at line 94 of file RakString.cpp.

Here is the call graph for this function:

RakString::RakString ( const RakString rhs  ) 

Definition at line 74 of file RakString.cpp.

Here is the call graph for this function:

RakString::RakString ( RakString::SharedString _sharedString  ) 

Definition at line 46 of file RakString.cpp.


Member Function Documentation

void RakString::Allocate ( size_t  len  )  [protected]

Definition at line 885 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::AppendBytes ( const char *  bytes,
unsigned int  count 
)

Definition at line 1019 of file RakString.cpp.

Here is the call graph for this function:

RakNet::RakString RakString::Assign ( const char *  str,
size_t  pos,
size_t  n 
)

Sets a copy of a substring of str as the new content. The substring is the portion of str that begins at the character position pos and takes up to n characters (it takes less than n if the end of str is reached before).

Parameters:
[in] str The string to copy in
[in] pos The position on str to start the copy
[in] n How many chars to copy
Returns:
Returns the string, note that the current string is set to that value as well

Definition at line 972 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::Assign ( const char *  str  )  [protected]

Definition at line 923 of file RakString.cpp.

Here is the call graph for this function:

void RakString::Assign ( const char *  str,
va_list  ap 
) [protected]

Definition at line 935 of file RakString.cpp.

Here is the call graph for this function:

const char* RakNet::RakString::C_String ( void   )  const [inline]

Same as std::string::c_str.

Definition at line 38 of file RakString.h.

Here is the caller graph for this function:

char* RakNet::RakString::C_StringUnsafe ( void   )  [inline]

Definition at line 42 of file RakString.h.

void RakString::Clear ( void   ) 

Clear the string.

Definition at line 881 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::Clone ( void   )  [protected]

Definition at line 1027 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool RakString::ContainsNonprintableExceptSpaces ( void   )  const

Does the string contain non-printable characters other than spaces?

Definition at line 569 of file RakString.cpp.

bool RakString::Deserialize ( BitStream bs  ) 

Deserialize what was written by Serialize

Parameters:
[in] bs Bitstream to serialize from
Returns:
true if the deserialization was successful

Definition at line 801 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool RakString::Deserialize ( char *  str,
BitStream bs 
) [static]

Static version of the Deserialize() function.

Definition at line 821 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::DeserializeCompressed ( char *  str,
BitStream bs,
bool  readLanguageId = false 
) [static]

Static version of the DeserializeCompressed() function.

Definition at line 844 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::DeserializeCompressed ( BitStream bs,
bool  readLanguageId = false 
)

Deserialize compressed string, written by SerializeCompressed

Parameters:
[in] bs Bitstream to serialize from
[in] readLanguageId If true, looks for the variable langaugeId in the data stream. Must match what was passed to SerializeCompressed
Returns:
true if the deserialization was successful
Precondition:
StringCompressor::AddReference must have been called to instantiate the class (Happens automatically from RakPeer::Startup())

Definition at line 835 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::Erase ( unsigned int  index,
unsigned int  count 
)

Erase characters out of the string at index for count.

Definition at line 448 of file RakString.cpp.

Here is the call graph for this function:

size_t RakString::Find ( const char *  stringToFind,
size_t  pos = 0 
)

String class find replacement Searches the string for the content specified in stringToFind and returns the position of the first occurrence in the string. Search only includes characters on or after position pos, ignoring any possible occurrences in previous locations.

Parameters:
[in] stringToFind The string to find inside of this object's string
[in] pos The position in the string to start the search
Returns:
Returns the position of the first occurrence in the string.

Definition at line 390 of file RakString.cpp.

Here is the call graph for this function:

void RakString::FPrintf ( FILE *  fp  ) 

Print the string to a file.

Definition at line 514 of file RakString.cpp.

void RakString::Free ( void   )  [protected]

Definition at line 1046 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::FreeMemory ( void   )  [static]

RakString uses a freeList of old no-longer used strings Call this function to clear this memory on shutdown

Definition at line 766 of file RakString.cpp.

Here is the call graph for this function:

void RakString::FreeMemoryNoMutex ( void   )  [static]

Definition at line 772 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t RakString::GetLength ( void   )  const

Returns the length of the string.

Definition at line 357 of file RakString.cpp.

Here is the caller graph for this function:

static size_t RakNet::RakString::GetSizeToAllocate ( size_t  bytes  )  [inline, static]

Definition at line 226 of file RakString.h.

Here is the caller graph for this function:

bool RakString::IPAddressMatch ( const char *  IP  ) 

Does the given IP address match the IP address encoded into this string, accounting for wildcards?

Definition at line 518 of file RakString.cpp.

bool RakString::IsEmailAddress ( void   )  const

Is this a valid email address?

Definition at line 580 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::IsEmpty ( void   )  const

Returns if the string is empty. Also, C_String() would return "".

Definition at line 353 of file RakString.cpp.

Here is the caller graph for this function:

void RakString::LockMutex ( void   )  [static]

Definition at line 1088 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

RakNet::RakString & RakString::MakeFilePath ( void   ) 

Fix to be a file path, ending with /.

Definition at line 732 of file RakString.cpp.

Here is the call graph for this function:

RakNet::RakString RakString::NonVariadic ( const char *  str  )  [static]

Create a RakString with a value, without doing printf style parsing Equivalent to assignment operator

Definition at line 999 of file RakString.cpp.

Here is the caller graph for this function:

RakNet::RakString::operator const char * (  )  const [inline]

Implicit return of const char*.

Definition at line 35 of file RakString.h.

bool RakString::operator!= ( const RakString rhs  )  const

Inequality.

Definition at line 236 of file RakString.cpp.

bool RakString::operator!= ( const char *  str  )  const

Definition at line 240 of file RakString.cpp.

bool RakString::operator!= ( char *  str  )  const

Definition at line 244 of file RakString.cpp.

RakString & RakString::operator+= ( const RakString rhs  ) 

Concatenation.

Definition at line 156 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

RakString & RakString::operator+= ( const char *  str  ) 

Definition at line 174 of file RakString.cpp.

Here is the call graph for this function:

RakString & RakString::operator+= ( char *  str  ) 

Definition at line 192 of file RakString.cpp.

Here is the call graph for this function:

RakString & RakString::operator+= ( const char  c  ) 

Definition at line 196 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::operator< ( const RakString right  )  const

Definition at line 220 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::operator<= ( const RakString right  )  const

Definition at line 224 of file RakString.cpp.

Here is the call graph for this function:

RakString & RakString::operator= ( const RakString rhs  ) 

Assigment operators.

Definition at line 98 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

RakString & RakString::operator= ( const char *  str  ) 

Definition at line 117 of file RakString.cpp.

Here is the call graph for this function:

RakString & RakString::operator= ( char *  str  ) 

Definition at line 123 of file RakString.cpp.

Here is the call graph for this function:

RakString & RakString::operator= ( const char  c  ) 

Definition at line 127 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::operator== ( char *  str  )  const

Definition at line 216 of file RakString.cpp.

bool RakString::operator== ( const RakString rhs  )  const

Equality.

Definition at line 208 of file RakString.cpp.

bool RakString::operator== ( const char *  str  )  const

Definition at line 212 of file RakString.cpp.

bool RakString::operator> ( const RakString right  )  const

Definition at line 228 of file RakString.cpp.

Here is the call graph for this function:

bool RakString::operator>= ( const RakString right  )  const

Definition at line 232 of file RakString.cpp.

Here is the call graph for this function:

unsigned char RakString::operator[] ( const unsigned int  position  )  const

Character index. Do not use to change the string however.

Definition at line 203 of file RakString.cpp.

Here is the call graph for this function:

void RakString::Printf ( void   ) 

Print the string to the screen.

Definition at line 510 of file RakString.cpp.

int RakString::RakStringComp ( RakString const &  key,
RakString const &  data 
) [static]

Definition at line 37 of file RakString.cpp.

Here is the call graph for this function:

void RakString::Realloc ( SharedString sharedString,
size_t  bytes 
) [protected]

Definition at line 134 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::RemoveCharacter ( char  c  ) 

Remove all instances of c.

Definition at line 487 of file RakString.cpp.

Here is the call graph for this function:

void RakString::Replace ( unsigned  index,
unsigned  count,
unsigned char  c 
)

Replace character(s) in starting at index, for count, with c.

Definition at line 361 of file RakString.cpp.

Here is the call graph for this function:

void RakString::Serialize ( BitStream bs  )  const

Serialize to a bitstream, uncompressed (slightly faster)

Parameters:
[out] bs Bitstream to serialize to

Definition at line 781 of file RakString.cpp.

Here is the caller graph for this function:

void RakString::Serialize ( const char *  str,
BitStream bs 
) [static]

Static version of the Serialize function.

Definition at line 785 of file RakString.cpp.

Here is the call graph for this function:

void RakString::SerializeCompressed ( const char *  str,
BitStream bs,
int  languageId = 0,
bool  writeLanguageId = false 
) [static]

Static version of the SerializeCompressed function.

Definition at line 795 of file RakString.cpp.

Here is the call graph for this function:

void RakString::SerializeCompressed ( BitStream bs,
int  languageId = 0,
bool  writeLanguageId = false 
) const

Serialize to a bitstream, compressed (better bandwidth usage)

Parameters:
[out] bs Bitstream to serialize to
[in] languageId languageId to pass to the StringCompressor class
[in] writeLanguageId encode the languageId variable in the stream. If false, 0 is assumed, and DeserializeCompressed will not look for this variable in the stream (saves bandwidth)
Precondition:
StringCompressor::AddReference must have been called to instantiate the class (Happens automatically from RakPeer::Startup())

Definition at line 791 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::Set ( const char *  format,
  ... 
)

Set the value of the string.

Definition at line 346 of file RakString.cpp.

Here is the call graph for this function:

void RakString::SetChar ( unsigned  index,
unsigned char  c 
)

Replace character at index with c.

Definition at line 373 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::SetChar ( unsigned  index,
RakNet::RakString  s 
)

Replace character at index with string s.

Definition at line 379 of file RakString.cpp.

Here is the call graph for this function:

RakNet::RakString & RakString::SQLEscape ( void   ) 

Scan for quote, double quote, and backslash and prepend with backslash.

Definition at line 696 of file RakString.cpp.

Here is the call graph for this function:

int RakString::StrCmp ( const RakString rhs  )  const

Compare strings (case sensitive).

Definition at line 502 of file RakString.cpp.

Here is the caller graph for this function:

int RakString::StrICmp ( const RakString rhs  )  const

Compare strings (not case sensitive).

Definition at line 506 of file RakString.cpp.

RakString RakString::SubStr ( unsigned int  index,
unsigned int  count 
) const

Definition at line 432 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void RakString::TerminateAtFirstCharacter ( char  c  ) 

Set the first instance of c with a NULL terminator.

Definition at line 474 of file RakString.cpp.

Here is the call graph for this function:

void RakString::TerminateAtLastCharacter ( char  c  ) 

Set the last instance of c with a NULL terminator.

Definition at line 461 of file RakString.cpp.

Here is the call graph for this function:

unsigned long RakString::ToInteger ( const RakString rs  )  [static]

Definition at line 1015 of file RakString.cpp.

Here is the call graph for this function:

unsigned long RakString::ToInteger ( const char *  str  )  [static]

Has the string into an unsigned int.

Definition at line 1005 of file RakString.cpp.

Here is the caller graph for this function:

const char * RakString::ToLower ( void   ) 

Change all characters to lowercase.

Definition at line 326 of file RakString.cpp.

Here is the call graph for this function:

unsigned char RakString::ToLower ( unsigned char  c  )  [protected]

Definition at line 1076 of file RakString.cpp.

const char * RakString::ToString ( uint64_t  i  )  [static]

Definition at line 867 of file RakString.cpp.

const char * RakString::ToString ( int64_t  i  )  [static]

Definition at line 853 of file RakString.cpp.

unsigned char RakString::ToUpper ( unsigned char  c  )  [protected]

Definition at line 1082 of file RakString.cpp.

const char * RakString::ToUpper ( void   ) 

Change all characters to uppercase.

Definition at line 336 of file RakString.cpp.

Here is the call graph for this function:

void RakString::Truncate ( unsigned  length  ) 

Make sure string is no longer than length.

Definition at line 425 of file RakString.cpp.

Here is the call graph for this function:

void RakString::UnlockMutex ( void   )  [static]

Definition at line 1092 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

RakNet::RakString & RakString::URLDecode ( void   ) 

URL decode the string.

Definition at line 655 of file RakString.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

RakNet::RakString & RakString::URLEncode ( void   ) 

URL Encode the string. See http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4029/.

Definition at line 620 of file RakString.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 255 of file RakString.h.

Definition at line 261 of file RakString.h.

unsigned int RakString::nPos = (unsigned int) -1 [static]

Means undefined position.

Definition at line 264 of file RakString.h.

Definition at line 250 of file RakString.h.


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