SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
SLNet::RakString Class Reference

String class. More...

`#include <slikenet/string.h>`

## 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)
RakString & | operator= (const RakString &rhs)
| Assigment operators.
RakString & | operator= (const char *str)
RakString & | operator= (char *str)
RakString & | operator= (const unsigned char *str)
RakString & | operator= (char unsigned *str)
RakString & | operator= (const char c)
RakString & | operator+= (const RakString &rhs)
| Concatenation.
RakString & | operator+= (const char *str)
RakString & | operator+= (char *str)
RakString & | operator+= (const unsigned char *str)
RakString & | operator+= (char unsigned *str)
RakString & | operator+= (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.
size_t | GetLengthUTF8 (void) const
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, SLNet::RakString s)
| Replace character at index with string s.
void | Truncate (unsigned int length)
| Make sure string is no longer than length.
void | TruncateUTF8 (unsigned int length)
RakString | SubStr (unsigned int index, size_t 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 | StartAfterFirstCharacter (char c)
void | StartAfterLastCharacter (char c)
int | GetCharacterCount (char c)
| Returns how many occurances there are of c in the string.
void | RemoveCharacter (char c)
| Remove all instances of c.
void | AppendBytes (const char *bytes, size_t count)
int | StrCmp (const RakString &rhs) const
| Compare strings (case sensitive)
int | StrNCmp (const RakString &rhs, size_t num) const
| Compare strings (case sensitive), up to num characters.
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?
SLNet::RakString & | URLEncode (void)
| URL Encode the string. See http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4029/.
SLNet::RakString & | URLDecode (void)
| URL decode the string.
void | SplitURI (SLNet::RakString &header, SLNet::RakString &domain, SLNet::RakString &path)
| https://servers.api.rackspacecloud.com/v1.0 to https://, servers.api.rackspacecloud.com, /v1.0
SLNet::RakString & | SQLEscape (void)
| Scan for quote, double quote, and backslash and prepend with backslash.
SLNet::RakString & | MakeFilePath (void)
| Fix to be a file path, ending with /.
void | Serialize (BitStream *bs) const
void | SerializeCompressed (BitStream *bs, uint8_t 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 SLNet::RakString | NonVariadic (const char *str)
static unsigned long | ToInteger (const char *str)
| Hash the string into an unsigned int.
static unsigned long | ToInteger (const RakString &rs)
static int | ReadIntFromSubstring (const char *str, size_t pos, size_t n)
| Read an integer out of a substring.
static SLNet::RakString | FormatForPOST (const char *uri, const char *contentType, const char *body, const char *extraHeaders="")
static SLNet::RakString | FormatForPUT (const char *uri, const char *contentType, const char *body, const char *extraHeaders="")
static SLNet::RakString | FormatForGET (const char *uri, const char *extraHeaders="")
static SLNet::RakString | FormatForDELETE (const char *uri, const char *extraHeaders="")
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, uint8_t 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

SharedString * | sharedString

## Static Public Attributes

static SharedString | emptyString ={0,0,0,(char*) "",(char*) ""}
static DataStructures::List < SharedString * > | freeList

## 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 *inSharedString, size_t bytes)

## Static Protected Member Functions

static SLNet::RakString | FormatForPUTOrPost (const char *type, const char *uri, const char *contentType, const char *body, const char *extraHeaders)

## 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 44 of file string.h.

## Class Documentation

struct SLNet::RakString::SharedString

Definition at line 309 of file string.h.

Class Members
char * | bigString |
size_t | bytesUsed |
char * | c_str |
unsigned int | refCount |
SimpleMutex * | refCountMutex |
char | smallString |

## Constructor & Destructor Documentation

RakString::RakString | ( |  | ) |

Definition at line 61 of file RakString.cpp.

References emptyString, and sharedString.

Referenced by SubStr().

RakString::RakString | ( | char | input | ) |

Definition at line 69 of file RakString.cpp.

References Assign().

RakString::RakString | ( | unsigned char | input | ) |

Definition at line 76 of file RakString.cpp.

References Assign().

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

Definition at line 83 of file RakString.cpp.

References Assign().

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

Definition at line 89 of file RakString.cpp.

References Assign().

RakString::~RakString | ( |  | ) |

Definition at line 115 of file RakString.cpp.

References Free().

RakString::RakString | ( | const RakString & | rhs | ) |

Definition at line 95 of file RakString.cpp.

References emptyString, SLNet::SimpleMutex::Lock(), SLNet::RakString::SharedString::refCount, SLNet::RakString::SharedString::refCountMutex, sharedString, and SLNet::SimpleMutex::Unlock().

RakString::RakString | ( | RakString::SharedString * | _sharedString | ) |

Definition at line 65 of file RakString.cpp.

References sharedString.

## Member Function Documentation

void RakString::Allocate | ( | size_t | len | ) |

protected

Definition at line 1333 of file RakString.cpp.

References _FILE_AND_LINE_, SLNet::RakString::SharedString::bigString, SLNet::RakString::SharedString::bytesUsed, SLNet::RakString::SharedString::c_str, freeList, DataStructures::List< list_type >::Insert(), LockMutex(), rakMalloc_Ex, SLNet::RakString::SharedString::refCount, SLNet::RakString::SharedString::refCountMutex, DataStructures::List< list_type >::RemoveAtIndex(), sharedString, DataStructures::List< list_type >::Size(), SLNet::RakString::SharedString::smallString, and UnlockMutex().

Referenced by AppendBytes(), Assign(), Deserialize(), SplitURI(), SubStr(), URLDecode(), and URLEncode().

void RakString::AppendBytes | ( | const char * | bytes,
|  | size_t | count
| ) |  |

Definition at line 1483 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::c_str, Clone(), GetLength(), IsEmpty(), Realloc(), and sharedString.

SLNet::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 1427 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::c_str, Clone(), emptyString, and sharedString.

Referenced by Assign(), Clone(), operator+=(), operator=(), RakString(), and Set().

void RakString::Assign | ( | const char * | str | ) |

protected

Definition at line 1371 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::c_str, emptyString, and sharedString.

void RakString::Assign | ( | const char * | str,
|  | va_list | ap
| ) |  |

protected

Definition at line 1383 of file RakString.cpp.

References _FILE_AND_LINE_, Assign(), emptyString, notifyOutOfMemory, rakFree_Ex, rakRealloc_Ex, and sharedString.

const char* SLNet::RakString::C_String | ( | void |  | ) | const

inline

Same as std::string::c_str.

Definition at line 60 of file string.h.

Referenced by SLNet::StringCompressor::EncodeString(), FormatForDELETE(), FormatForGET(), FormatForPUTOrPost(), operator+=(), operator<(), operator<=(), SLNet::RakWString::operator=(), operator>(), operator>=(), SerializeCompressed(), StrCmp(), StrICmp(), StrNCmp(), and ToInteger().

char* SLNet::RakString::C_StringUnsafe | ( | void |  | ) |

inline

Definition at line 64 of file string.h.

void RakString::Clear | ( | void |  | ) |

Clear the string.

Definition at line 1329 of file RakString.cpp.

References Free().

Referenced by SLNet::StringCompressor::DecodeString(), Deserialize(), RemoveCharacter(), Set(), and SplitURI().

void RakString::Clone | ( | void |  | ) |

protected

Definition at line 1502 of file RakString.cpp.

References Assign(), SLNet::RakString::SharedString::c_str, emptyString, SLNet::SimpleMutex::Lock(), RakAssert, SLNet::RakString::SharedString::refCount, SLNet::RakString::SharedString::refCountMutex, sharedString, and SLNet::SimpleMutex::Unlock().

Referenced by AppendBytes(), Assign(), Erase(), MakeFilePath(), operator+=(), RemoveCharacter(), Replace(), SetChar(), SQLEscape(), TerminateAtFirstCharacter(), TerminateAtLastCharacter(), ToLower(), and ToUpper().

bool RakString::ContainsNonprintableExceptSpaces | ( | void |  | ) | const

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

Definition at line 818 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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 1249 of file RakString.cpp.

References SLNet::BitStream::AlignReadToByteBoundary(), Allocate(), SLNet::RakString::SharedString::c_str, Clear(), SLNet::BitStream::Read(), SLNet::BitStream::ReadAlignedBytes(), and sharedString.

Referenced by SLNet::BitStream::Read().

bool RakString::Deserialize | ( | char * | str,
|  | BitStream * | bs
| ) |  |

static

Static version of the Deserialize() function.

Definition at line 1269 of file RakString.cpp.

References SLNet::BitStream::Read(), and SLNet::BitStream::ReadAlignedBytes().

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 1283 of file RakString.cpp.

References SLNet::StringCompressor::DecodeString(), SLNet::StringCompressor::Instance(), and SLNet::BitStream::ReadCompressed().

Referenced by SLNet::BitStream::ReadCompressed().

bool RakString::DeserializeCompressed | ( | char * | str,
|  | BitStream * | bs,
|  | bool | readLanguageId = `false`
| ) |  |

static

Static version of the DeserializeCompressed() function.

Definition at line 1292 of file RakString.cpp.

References SLNet::StringCompressor::DecodeString(), SLNet::StringCompressor::Instance(), and SLNet::BitStream::ReadCompressed().

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

Erase characters out of the string at index for count.

Definition at line 647 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), GetLength(), RakAssert, and sharedString.

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 558 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, GetLength(), and sharedString.

RakString RakString::FormatForDELETE | ( | const char * | uri,
|  | const char * | extraHeaders = `""`
| ) |  |

static

Format as a DELETE command that can be sent to a webserver

Parameters

  [in] | uri | For example, masterserver2.raknet.com/testServer?__gameId=comprehensivePCGame&__rowId=1

Returns
  Formatted string

Definition at line 1142 of file RakString.cpp.

References C_String(), IsEmpty(), Set(), and SplitURI().

RakString RakString::FormatForGET | ( | const char * | uri,
|  | const char * | extraHeaders = `""`
| ) |  |

static

Format as a GET command that can be sent to a webserver

Parameters

  [in] | uri | For example, masterserver2.raknet.com/testServer?__gameId=comprehensivePCGame

Returns
  Formatted string

Definition at line 1106 of file RakString.cpp.

References C_String(), IsEmpty(), Set(), and SplitURI().

RakString RakString::FormatForPOST | ( | const char * | uri,
|  | const char * | contentType,
|  | const char * | body,
|  | const char * | extraHeaders = `""`
| ) |  |

static

Format as a POST command that can be sent to a webserver

Parameters

  [in] | uri | For example, masterserver2.raknet.com/testServer
  [in] | contentType | For example, text/plain; charset=UTF-8
  [in] | body | Body of the post

Returns
  Formatted string

Definition at line 1098 of file RakString.cpp.

References FormatForPUTOrPost().

RakString RakString::FormatForPUT | ( | const char * | uri,
|  | const char * | contentType,
|  | const char * | body,
|  | const char * | extraHeaders = `""`
| ) |  |

static

Definition at line 1102 of file RakString.cpp.

References FormatForPUTOrPost().

SLNet::RakString RakString::FormatForPUTOrPost | ( | const char * | type,
|  | const char * | uri,
|  | const char * | contentType,
|  | const char * | body,
|  | const char * | extraHeaders
| ) |  |

staticprotected

Definition at line 1043 of file RakString.cpp.

References C_String(), IsEmpty(), Set(), and SplitURI().

Referenced by FormatForPOST(), and FormatForPUT().

void RakString::FPrintf | ( | FILE * | fp | ) |

Print the string to a file.

Definition at line 766 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

void RakString::Free | ( | void |  | ) |

protected

Definition at line 1522 of file RakString.cpp.

References _FILE_AND_LINE_, SLNet::RakString::SharedString::bigString, SLNet::RakString::SharedString::bytesUsed, emptyString, freeList, DataStructures::List< list_type >::Insert(), SLNet::SimpleMutex::Lock(), LockMutex(), rakFree_Ex, SLNet::RakString::SharedString::refCount, SLNet::RakString::SharedString::refCountMutex, sharedString, SLNet::SimpleMutex::Unlock(), and UnlockMutex().

Referenced by Clear(), operator=(), and ~RakString().

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 1214 of file RakString.cpp.

References FreeMemoryNoMutex(), LockMutex(), and UnlockMutex().

void RakString::FreeMemoryNoMutex | ( | void |  | ) |

static

Definition at line 1220 of file RakString.cpp.

References _FILE_AND_LINE_, DataStructures::List< list_type >::Clear(), freeList, SLNet::OP_DELETE(), rakFree_Ex, and DataStructures::List< list_type >::Size().

Referenced by FreeMemory().

int RakString::GetCharacterCount | ( | char | c | ) |

Returns how many occurances there are of c in the string.

Definition at line 720 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, GetLength(), and sharedString.

size_t RakString::GetLength | ( | void |  | ) | const

Returns the length of the string.

Definition at line 396 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

Referenced by AppendBytes(), Erase(), Find(), GetCharacterCount(), operator+(), operator+=(), operator[](), Replace(), SetChar(), SplitURI(), SQLEscape(), StartAfterFirstCharacter(), StartAfterLastCharacter(), SubStr(), TerminateAtFirstCharacter(), TerminateAtLastCharacter(), and Truncate().

size_t RakString::GetLengthUTF8 | ( | void |  | ) | const

Definition at line 429 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, porges_strlen2(), and sharedString.

static size_t SLNet::RakString::GetSizeToAllocate | ( | size_t | bytes | ) |

inlinestatic

Definition at line 299 of file string.h.

Referenced by operator+(), and Realloc().

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 770 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

bool RakString::IsEmailAddress | ( | void |  | ) | const

Is this a valid email address?

Definition at line 829 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, IsEmpty(), and sharedString.

bool RakString::IsEmpty | ( | void |  | ) | const

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

Definition at line 392 of file RakString.cpp.

References emptyString, and sharedString.

Referenced by AppendBytes(), FormatForDELETE(), FormatForGET(), FormatForPUTOrPost(), IsEmailAddress(), MakeFilePath(), operator+(), and operator+=().

void RakString::LockMutex | ( | void |  | ) |

static

Definition at line 1564 of file RakString.cpp.

References GetPoolMutex(), and SLNet::SimpleMutex::Lock().

Referenced by Allocate(), Free(), FreeMemory(), and operator+().

SLNet::RakString & RakString::MakeFilePath | ( | void |  | ) |

Fix to be a file path, ending with /.

Definition at line 1180 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), IsEmpty(), and sharedString.

SLNet::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 1454 of file RakString.cpp.

SLNet::RakString::operator const char * | ( |  | ) | const

inline

Implicit return of const char*.

Definition at line 57 of file string.h.

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

Inequality.

Definition at line 274 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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

Definition at line 278 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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

Definition at line 282 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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

Concatenation.

Definition at line 186 of file RakString.cpp.

References SLNet::RakString::SharedString::bytesUsed, SLNet::RakString::SharedString::c_str, C_String(), Clone(), GetLength(), IsEmpty(), operator=(), Realloc(), and sharedString.

Referenced by operator+=().

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

Definition at line 204 of file RakString.cpp.

References Assign(), SLNet::RakString::SharedString::bytesUsed, SLNet::RakString::SharedString::c_str, Clone(), GetLength(), IsEmpty(), Realloc(), and sharedString.

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

Definition at line 222 of file RakString.cpp.

References operator+=().

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

Definition at line 226 of file RakString.cpp.

References operator+=().

RakString& SLNet::RakString::operator+= | ( | char unsigned * | str | ) |

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

Definition at line 234 of file RakString.cpp.

References operator+=().

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

Definition at line 258 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

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

Definition at line 262 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

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

Assigment operators.

Definition at line 119 of file RakString.cpp.

References emptyString, Free(), SLNet::SimpleMutex::Lock(), SLNet::RakString::SharedString::refCount, SLNet::RakString::SharedString::refCountMutex, sharedString, and SLNet::SimpleMutex::Unlock().

Referenced by operator+=(), and operator=().

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

Definition at line 138 of file RakString.cpp.

References Assign(), and Free().

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

Definition at line 144 of file RakString.cpp.

References operator=().

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

Definition at line 148 of file RakString.cpp.

References operator=().

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

Definition at line 152 of file RakString.cpp.

References operator=().

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

Definition at line 156 of file RakString.cpp.

References operator=().

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

Equality.

Definition at line 246 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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

Definition at line 250 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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

Definition at line 254 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

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

Definition at line 266 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

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

Definition at line 270 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

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

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

Definition at line 241 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, GetLength(), RakAssert, and sharedString.

void RakString::Printf | ( | void |  | ) |

Print the string to the screen.

Definition at line 762 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, RAKNET_DEBUG_PRINTF, and sharedString.

int SLNet::RakString::RakStringComp | ( | RakString const & | key,
|  | RakString const & | data
| ) |  |

static

Definition at line 56 of file RakString.cpp.

References StrCmp().

int RakString::ReadIntFromSubstring | ( | const char * | str,
|  | size_t | pos,
|  | size_t | n
| ) |  |

static

Read an integer out of a substring.

Parameters

  [in] | str | The string
  [in] | pos | The position on str where the integer starts
  [in] | n | How many chars to copy

Definition at line 1474 of file RakString.cpp.

void RakString::Realloc | ( | SharedString * | inSharedString,
|  | size_t | bytes
| ) |  |

protected

Definition at line 163 of file RakString.cpp.

References _FILE_AND_LINE_, SLNet::RakString::SharedString::bigString, SLNet::RakString::SharedString::bytesUsed, SLNet::RakString::SharedString::c_str, GetSizeToAllocate(), RakAssert, rakMalloc_Ex, rakRealloc_Ex, and SLNet::RakString::SharedString::smallString.

Referenced by AppendBytes(), operator+=(), and SQLEscape().

void RakString::RemoveCharacter | ( | char | c | ) |

Remove all instances of c.

Definition at line 733 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clear(), Clone(), and sharedString.

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

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

Definition at line 433 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), GetLength(), RakAssert, and sharedString.

void RakString::Serialize | ( | BitStream * | bs | ) | const

Serialize to a bitstream, uncompressed (slightly faster)

Parameters

  [out] | bs | Bitstream to serialize to

Definition at line 1229 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

Referenced by SLNet::BitStream::Write().

void RakString::Serialize | ( | const char * | str,
|  | BitStream * | bs
| ) |  |

static

Static version of the Serialize function.

Definition at line 1233 of file RakString.cpp.

References SLNet::BitStream::Write(), and SLNet::BitStream::WriteAlignedBytes().

void RakString::SerializeCompressed | ( | BitStream * | bs,
|  | uint8_t | 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 1239 of file RakString.cpp.

References C_String().

Referenced by SLNet::BitStream::WriteCompressed().

void RakString::SerializeCompressed | ( | const char * | str,
|  | BitStream * | bs,
|  | uint8_t | languageId = `0`,
|  | bool | writeLanguageId = `false`
| ) |  |

static

Static version of the SerializeCompressed function.

Definition at line 1243 of file RakString.cpp.

References SLNet::StringCompressor::EncodeString(), SLNet::StringCompressor::Instance(), and SLNet::BitStream::WriteCompressed().

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

Set the value of the string.

Definition at line 384 of file RakString.cpp.

References Assign(), and Clear().

Referenced by FormatForDELETE(), FormatForGET(), and FormatForPUTOrPost().

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

Replace character at index with c.

Definition at line 446 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), GetLength(), RakAssert, and sharedString.

Referenced by Truncate().

void RakString::SetChar | ( | unsigned | index,
|  | SLNet::RakString | s
| ) |  |

Replace character at index with string s.

Definition at line 452 of file RakString.cpp.

References Clone(), GetLength(), RakAssert, and SubStr().

void RakString::SplitURI | ( | SLNet::RakString & | header,
|  | SLNet::RakString & | domain,
|  | SLNet::RakString & | path
| ) |  |

https://servers.api.rackspacecloud.com/v1.0 to https://, servers.api.rackspacecloud.com, /v1.0

Definition at line 954 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::bytesUsed, SLNet::RakString::SharedString::c_str, Clear(), GetLength(), and sharedString.

Referenced by FormatForDELETE(), FormatForGET(), and FormatForPUTOrPost().

SLNet::RakString & RakString::SQLEscape | ( | void |  | ) |

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

Definition at line 1007 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), GetLength(), Realloc(), and sharedString.

void RakString::StartAfterFirstCharacter | ( | char | c | ) |

Definition at line 704 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, GetLength(), sharedString, and SubStr().

void RakString::StartAfterLastCharacter | ( | char | c | ) |

Definition at line 673 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, GetLength(), sharedString, and SubStr().

int RakString::StrCmp | ( | const RakString & | rhs | ) | const

Compare strings (case sensitive)

Definition at line 750 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

Referenced by RakStringComp().

int RakString::StrICmp | ( | const RakString & | rhs | ) | const

Compare strings (not case sensitive)

Definition at line 758 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

int RakString::StrNCmp | ( | const RakString & | rhs,
|  | size_t | num
| ) |  | const

Compare strings (case sensitive), up to num characters.

Definition at line 754 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, C_String(), and sharedString.

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

Definition at line 631 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::c_str, GetLength(), RakString(), and sharedString.

Referenced by SetChar(), StartAfterFirstCharacter(), and StartAfterLastCharacter().

void RakString::TerminateAtFirstCharacter | ( | char | c | ) |

Set the first instance of c with a NULL terminator.

Definition at line 689 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), GetLength(), and sharedString.

void RakString::TerminateAtLastCharacter | ( | char | c | ) |

Set the last instance of c with a NULL terminator.

Definition at line 660 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), GetLength(), and sharedString.

unsigned long RakString::ToInteger | ( | const char * | str | ) |

static

Hash the string into an unsigned int.

Definition at line 1460 of file RakString.cpp.

Referenced by ToInteger().

unsigned long RakString::ToInteger | ( | const RakString & | rs | ) |

static

Definition at line 1470 of file RakString.cpp.

References C_String(), and ToInteger().

const char * RakString::ToLower | ( | void |  | ) |

Change all characters to lowercase.

Definition at line 364 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), and sharedString.

unsigned char RakString::ToLower | ( | unsigned char | c | ) |

protected

Definition at line 1552 of file RakString.cpp.

const char * RakString::ToString | ( | int64_t | i | ) |

static

Definition at line 1301 of file RakString.cpp.

const char * RakString::ToString | ( | uint64_t | i | ) |

static

Definition at line 1315 of file RakString.cpp.

const char * RakString::ToUpper | ( | void |  | ) |

Change all characters to uppercase.

Definition at line 374 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, Clone(), and sharedString.

unsigned char RakString::ToUpper | ( | unsigned char | c | ) |

protected

Definition at line 1558 of file RakString.cpp.

void RakString::Truncate | ( | unsigned int | length | ) |

Make sure string is no longer than length.

Definition at line 623 of file RakString.cpp.

References GetLength(), and SetChar().

void RakString::TruncateUTF8 | ( | unsigned int | length | ) |

Definition at line 593 of file RakString.cpp.

References SLNet::RakString::SharedString::c_str, and sharedString.

void RakString::UnlockMutex | ( | void |  | ) |

static

Definition at line 1568 of file RakString.cpp.

References GetPoolMutex(), and SLNet::SimpleMutex::Unlock().

Referenced by Allocate(), Free(), FreeMemory(), and operator+().

SLNet::RakString & RakString::URLDecode | ( | void |  | ) |

URL decode the string.

Definition at line 905 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::c_str, and sharedString.

SLNet::RakString & RakString::URLEncode | ( | void |  | ) |

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

Definition at line 869 of file RakString.cpp.

References Allocate(), SLNet::RakString::SharedString::c_str, Itoa(), and sharedString.

## Member Data Documentation

RakString::SharedString RakString::emptyString ={0,0,0,(char*) "",(char*) ""}

static

Definition at line 328 of file string.h.

Referenced by Assign(), Clone(), Free(), IsEmpty(), operator+(), operator=(), and RakString().

DataStructures::List< RakString::SharedString * > RakString::freeList

static

Definition at line 334 of file string.h.

Referenced by Allocate(), Free(), FreeMemoryNoMutex(), and operator+().

SharedString* SLNet::RakString::sharedString

Definition at line 323 of file string.h.

Referenced by Allocate(), AppendBytes(), Assign(), Clone(), ContainsNonprintableExceptSpaces(), Deserialize(), Erase(), Find(), FPrintf(), Free(), GetCharacterCount(), GetLength(), GetLengthUTF8(), IPAddressMatch(), IsEmailAddress(), IsEmpty(), MakeFilePath(), operator!=(), operator+(), operator+=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), operator[](), Printf(), RakString(), RemoveCharacter(), Replace(), Serialize(), SetChar(), SplitURI(), SQLEscape(), StartAfterFirstCharacter(), StartAfterLastCharacter(), StrCmp(), StrICmp(), StrNCmp(), SubStr(), TerminateAtFirstCharacter(), TerminateAtLastCharacter(), ToLower(), ToUpper(), TruncateUTF8(), URLDecode(), and URLEncode().

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

- Source/include/slikenet/string.h
- Source/src/RakString.cpp