String class. More...
#include <RakString.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 char c) |
RakString & | operator+= (const RakString &rhs) |
Concatenation. | |
RakString & | operator+= (const char *str) |
RakString & | operator+= (char *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. | |
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::RakString & | URLEncode (void) |
URL Encode the string. See http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4029/. | |
RakNet::RakString & | URLDecode (void) |
URL decode the string. | |
RakNet::RakString & | SQLEscape (void) |
Scan for quote, double quote, and backslash and prepend with backslash. | |
RakNet::RakString & | MakeFilePath (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 | |
SharedString * | sharedString |
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) |
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.
RakString::RakString | ( | ) |
RakString::RakString | ( | char | input | ) |
RakString::RakString | ( | unsigned char | input | ) |
RakString::RakString | ( | const unsigned char * | format, | |
... | ||||
) |
RakString::RakString | ( | const char * | format, | |
... | ||||
) |
RakString::~RakString | ( | ) |
RakString::RakString | ( | const RakString & | rhs | ) |
RakString::RakString | ( | RakString::SharedString * | _sharedString | ) |
Definition at line 46 of file RakString.cpp.
void RakString::Allocate | ( | size_t | len | ) | [protected] |
Definition at line 885 of file RakString.cpp.
void RakString::AppendBytes | ( | const char * | bytes, | |
unsigned int | count | |||
) |
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).
[in] | str | The string to copy in |
[in] | pos | The position on str to start the copy |
[in] | n | How many chars to copy |
Definition at line 972 of file RakString.cpp.
void RakString::Assign | ( | const char * | str | ) | [protected] |
void RakString::Assign | ( | const char * | str, | |
va_list | ap | |||
) | [protected] |
const char* RakNet::RakString::C_String | ( | void | ) | const [inline] |
Same as std::string::c_str.
Definition at line 38 of file RakString.h.
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.
void RakString::Clone | ( | void | ) | [protected] |
Definition at line 1027 of file RakString.cpp.
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
[in] | bs | Bitstream to serialize from |
Definition at line 801 of file RakString.cpp.
bool RakString::Deserialize | ( | char * | str, | |
BitStream * | bs | |||
) | [static] |
Static version of the Deserialize() function.
Definition at line 821 of file RakString.cpp.
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.
bool RakString::DeserializeCompressed | ( | BitStream * | bs, | |
bool | readLanguageId = false | |||
) |
Deserialize compressed string, written by SerializeCompressed
[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 |
Definition at line 835 of file RakString.cpp.
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.
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.
[in] | stringToFind | The string to find inside of this object's string |
[in] | pos | The position in the string to start the search |
Definition at line 390 of file RakString.cpp.
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.
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.
void RakString::FreeMemoryNoMutex | ( | void | ) | [static] |
Definition at line 772 of file RakString.cpp.
size_t RakString::GetLength | ( | void | ) | const |
Returns the length of the string.
Definition at line 357 of file RakString.cpp.
static size_t RakNet::RakString::GetSizeToAllocate | ( | size_t | bytes | ) | [inline, static] |
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.
bool RakString::IsEmpty | ( | void | ) | const |
Returns if the string is empty. Also, C_String() would return "".
Definition at line 353 of file RakString.cpp.
void RakString::LockMutex | ( | void | ) | [static] |
Definition at line 1088 of file RakString.cpp.
RakNet::RakString & RakString::MakeFilePath | ( | void | ) |
Fix to be a file path, ending with /.
Definition at line 732 of file RakString.cpp.
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.
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.
Concatenation.
Definition at line 156 of file RakString.cpp.
RakString & RakString::operator+= | ( | const char * | str | ) |
RakString & RakString::operator+= | ( | char * | str | ) |
RakString & RakString::operator+= | ( | const char | c | ) |
bool RakString::operator< | ( | const RakString & | right | ) | const |
bool RakString::operator<= | ( | const RakString & | right | ) | const |
Assigment operators.
Definition at line 98 of file RakString.cpp.
RakString & RakString::operator= | ( | const char * | str | ) |
RakString & RakString::operator= | ( | char * | str | ) |
RakString & RakString::operator= | ( | const char | c | ) |
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 |
bool RakString::operator>= | ( | const RakString & | right | ) | const |
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.
void RakString::Printf | ( | void | ) |
Print the string to the screen.
Definition at line 510 of file RakString.cpp.
void RakString::Realloc | ( | SharedString * | sharedString, | |
size_t | bytes | |||
) | [protected] |
Definition at line 134 of file RakString.cpp.
void RakString::RemoveCharacter | ( | char | c | ) |
Remove all instances of c.
Definition at line 487 of file RakString.cpp.
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.
void RakString::Serialize | ( | BitStream * | bs | ) | const |
Serialize to a bitstream, uncompressed (slightly faster)
[out] | bs | Bitstream to serialize to |
Definition at line 781 of file RakString.cpp.
void RakString::Serialize | ( | const char * | str, | |
BitStream * | bs | |||
) | [static] |
Static version of the Serialize function.
Definition at line 785 of file RakString.cpp.
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.
void RakString::SerializeCompressed | ( | BitStream * | bs, | |
int | languageId = 0 , |
|||
bool | writeLanguageId = false | |||
) | const |
Serialize to a bitstream, compressed (better bandwidth usage)
[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) |
Definition at line 791 of file RakString.cpp.
void RakString::Set | ( | const char * | format, | |
... | ||||
) |
Set the value of the string.
Definition at line 346 of file RakString.cpp.
void RakString::SetChar | ( | unsigned | index, | |
unsigned char | c | |||
) |
Replace character at index with c.
Definition at line 373 of file RakString.cpp.
void RakString::SetChar | ( | unsigned | index, | |
RakNet::RakString | s | |||
) |
Replace character at index with string s.
Definition at line 379 of file RakString.cpp.
RakNet::RakString & RakString::SQLEscape | ( | void | ) |
Scan for quote, double quote, and backslash and prepend with backslash.
Definition at line 696 of file RakString.cpp.
int RakString::StrCmp | ( | const RakString & | rhs | ) | const |
Compare strings (case sensitive).
Definition at line 502 of file RakString.cpp.
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.
void RakString::TerminateAtFirstCharacter | ( | char | c | ) |
Set the first instance of c with a NULL terminator.
Definition at line 474 of file RakString.cpp.
void RakString::TerminateAtLastCharacter | ( | char | c | ) |
Set the last instance of c with a NULL terminator.
Definition at line 461 of file RakString.cpp.
unsigned long RakString::ToInteger | ( | const RakString & | rs | ) | [static] |
unsigned long RakString::ToInteger | ( | const char * | str | ) | [static] |
Has the string into an unsigned int.
Definition at line 1005 of file RakString.cpp.
const char * RakString::ToLower | ( | void | ) |
Change all characters to lowercase.
Definition at line 326 of file RakString.cpp.
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.
void RakString::Truncate | ( | unsigned | length | ) |
Make sure string is no longer than length.
Definition at line 425 of file RakString.cpp.
void RakString::UnlockMutex | ( | void | ) | [static] |
Definition at line 1092 of file RakString.cpp.
RakNet::RakString & RakString::URLDecode | ( | void | ) |
URL decode the string.
Definition at line 655 of file RakString.cpp.
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.
RakString::SharedString RakString::emptyString = {0,0,0,"",""} [static] |
Definition at line 255 of file RakString.h.
DataStructures::List< RakString::SharedString * > RakString::freeList [static] |
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.