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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# RakNet::RakString Class Reference

String class Has the following improvements over std::string Reference counting: Suitable to store in lists Varidic assignment operator Doesn't cause linker errors. More...

`#include <RakString.h>`

List of all members.

## Public Member Functions
| RakString ()
| Constructors.
| operator const char * () const
| Implicit return of const char*.
const char * | C_String (void) const
| Same as std::string::c_str.
RakString & | operator= (const RakString &rhs)
| Assigment operators.
RakString & | operator+= (const RakString &rhs)
| Concatenation.
unsigned char | operator[] (const unsigned int position) const
| Character index. Do not use to change the string however.
bool | operator== (const RakString &rhs) const
| Equality.
bool | operator!= (const RakString &rhs) const
| Inequality.
void | ToLower (void)
| Change all characters to lowercase.
void | ToUpper (void)
| Change all characters to uppercase.
void | Set (const char *format,...)
| Set the value of the string.
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 | Erase (unsigned index, unsigned count)
| Erase characters out of the string at index for 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?
void | URLEncode (void)
| URL Encode the string. See http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4029/.
void | Serialize (BitStream *bs)
void | SerializeCompressed (BitStream *bs, int languageId=0, bool writeLanguageId=false)
bool | Deserialize (BitStream *bs)
bool | DeserializeCompressed (BitStream *bs, bool readLanguageId=false)
## Static Public Member Functions
static void | FreeMemory (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 Public Attributes
static unsigned int | nPos
| Means undefined position.

## Detailed Description

String class Has the following improvements over std::string Reference counting: Suitable to store in lists Varidic assignment operator Doesn't cause linker errors.

## Member Function Documentation

void RakString::FreeMemory | ( | void |  | ) | `[static]`

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

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

Serialize to a bitstream, uncompressed (slightly faster)

Parameters:

  `[out]` | bs | Bitstream to serialize to

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

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())

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

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())

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

- C:/RakNet/Source/RakString.h
- C:/RakNet/Source/RakString.cpp