Nebula
|
#include <string.h>
Nebula's universal string class.
An empty string object is always 32 bytes big. The string class tries to avoid costly heap allocations with the following tactics:
Heap allocations are performed through a local heap which should be faster then going through the process heap.
Besides the usual string manipulation methods, the String class also offers methods to convert basic Nebula datatypes from and to string, and a group of methods which manipulate filename strings.
Public Member Functions | |
String () | |
constructor | |
String (const String &rhs) | |
copy constructor | |
String (String &&rhs) noexcept | |
move constructor | |
String (const char *cStr) | |
construct from C string | |
String (const char *cStr, size_t len) | |
construct from C string | |
~String () | |
destructor | |
void | operator= (const String &rhs) |
assignment operator | |
void | operator= (String &&rhs) noexcept |
move operator | |
void | operator= (const char *cStr) |
assign from const char* | |
void | operator+= (const String &rhs) |
+= operator | |
char | operator[] (IndexT i) const |
read-only index operator | |
char & | operator[] (IndexT i) |
read/write index operator | |
void | Reserve (SizeT newSize) |
reserve internal buffer size to prevent heap allocs | |
SizeT | Length () const |
return length of string | |
void | Clear () |
clear the string | |
bool | IsEmpty () const |
return true if string object is empty | |
bool | IsValid () const |
return true if string object is not empty | |
bool | CopyToBuffer (char *buf, SizeT bufSize) const |
copy to char buffer (return false if buffer is too small) | |
void | Append (const String &str) |
append string | |
void | Append (const char *str) |
append c-string | |
void | AppendRange (const char *str, SizeT numChars) |
append a range of characters | |
void | ToLower () |
convert string to lower case | |
void | ToUpper () |
convert string to upper case | |
void | FirstCharToUpper () |
convert first char of string to upper case | |
SizeT | Tokenize (const String &whiteSpace, Array< String > &outTokens) const |
tokenize string into a provided String array (faster if tokens array can be reused) | |
Array< String > | Tokenize (const String &whiteSpace) const |
tokenize string into a provided String array, SLOW since new array will be constructed | |
SizeT | Tokenize (const String &whiteSpace, char fence, Array< String > &outTokens) const |
tokenize string, keep strings within fence characters intact (faster if tokens array can be reused) | |
Array< String > | Tokenize (const String &whiteSpace, char fence) const |
tokenize string, keep strings within fence characters intact, SLOW since new array will be constructed | |
String | ExtractRange (IndexT fromIndex, SizeT numChars) const |
extract substring | |
String | ExtractToEnd (IndexT fromIndex) const |
extract substring to end of this string | |
void | Strip (const String &charSet) |
terminate string at first occurence of character in set | |
IndexT | FindStringIndex (const String &s, IndexT startIndex=0) const |
return start index of substring, or InvalidIndex if not found | |
IndexT | FindCharIndex (char c, IndexT startIndex=0) const |
return index of character in string, or InvalidIndex if not found | |
bool | BeginsWithString (const String &s) const |
returns true if string begins with string | |
bool | EndsWithString (const String &s) const |
returns true if string ends with string | |
void | TerminateAtIndex (IndexT index) |
terminate string at given index | |
bool | ContainsCharFromSet (const String &charSet) const |
returns true if string contains any character from set | |
void | TrimLeft (const String &charSet) |
delete characters from charset at left side of string | |
void | TrimRight (const String &charSet) |
delete characters from charset at right side of string | |
void | Trim (const String &charSet) |
trim characters from charset at both sides of string | |
void | SubstituteString (const String &str, const String &substStr) |
substitute every occurance of a string with another string | |
void | SubstituteChar (char c, char subst) |
substitute every occurance of a character with another character | |
void __cdecl | Format (const char *fmtString,...) |
format string printf-style | |
void __cdecl | FormatArgList (const char *fmtString, va_list argList) |
format string printf-style with varargs list | |
bool | CheckValidCharSet (const String &charSet) const |
return true if string only contains characters from charSet argument | |
void | ReplaceChars (const String &charSet, char replacement) |
replace any char set character within a string with the replacement character | |
uint32_t | HashCode () const |
return a 32-bit hash code for the string | |
void | SetCharPtr (const char *s) |
set content to char ptr | |
void | Set (const char *ptr, SizeT length) |
set as char ptr, with explicit length | |
void | Set (const char *ptr, size_t length) |
set as char ptr, with explicit length. will assert if size_t exceeds 2^32 | |
void | SetByte (byte val) |
set as byte value | |
void | SetUByte (ubyte val) |
set as ubyte value | |
void | SetShort (short val) |
set as short value | |
void | SetUShort (ushort val) |
set as ushort value | |
void | SetInt (int val) |
set as int value | |
void | SetUInt (uint val) |
set as uint value | |
void | SetLong (long val) |
set as long value | |
void | SetSizeT (size_t val) |
set as long value | |
void | SetLongLong (long long val) |
set as long long value | |
void | SetFloat (float val) |
set as float value | |
void | SetDouble (double val) |
set as double value | |
void | SetBool (bool val) |
set as bool value | |
void | Fill (SizeT length, unsigned char character) |
set string length and fill all characters with arg | |
void | SetVec2 (const Math::vec2 &v) |
set as vec2 value | |
void | SetVec3 (const Math::vec3 &v) |
set as vec3 value | |
void | SetVec4 (const Math::vec4 &v) |
set as vec4 value | |
void | SetFloat2 (const Math::float2 &v) |
set as vec2 value | |
void | SetFloat3 (const Math::float3 &v) |
set as vec3 value | |
void | SetFloat4 (const Math::float4 &v) |
set as vec4 value | |
void | SetQuaternion (const Math::quat &v) |
set as quaternion | |
void | SetMat4 (const Math::mat4 &v) |
set as mat4 value | |
void | SetTransform44 (const Math::transform44 &v) |
set as transform44 value | |
template<typename T > | |
void | Set (const T &t) |
generic setter | |
void | AppendChar (char val) |
append character | |
void | AppendInt (int val) |
append int value | |
void | AppendByte (byte val) |
append byte value | |
void | AppendUByte (ubyte val) |
append unsigned byte value | |
void | AppendFloat (float val) |
append float value | |
void | AppendBool (bool val) |
append bool value | |
void | AppendVec2 (const Math::vec2 &v) |
append vec2 value | |
void | AppendVec3 (const Math::vec3 &v) |
append vec3 value | |
void | AppendVec4 (const Math::vec4 &v) |
append vec4 value | |
void | AppendMat4 (const Math::mat4 &v) |
append mat4 value | |
template<typename T > | |
void | Append (const T &t) |
generic append | |
const char * | AsCharPtr () const |
return contents as character pointer | |
const char * | Get () const |
*** OBSOLETE *** only Nebula2 compatibility | |
int | AsInt () const |
return contents as integer | |
long long | AsLongLong () const |
return contents as long long | |
float | AsFloat () const |
return contents as float | |
bool | AsBool () const |
return contents as bool | |
Math::vec2 | AsVec2 () const |
return contents as vec2 | |
Math::vec3 | AsVec3 () const |
return contents as vec3 | |
Math::vec4 | AsVec4 () const |
return contents as vec4 | |
Math::float2 | AsFloat2 () const |
return contents as vec2 | |
Math::float3 | AsFloat3 () const |
return contents as vec3 | |
Math::float4 | AsFloat4 () const |
return contents as vec4 | |
Math::mat4 | AsMat4 () const |
return contents as mat4 | |
Math::transform44 | AsTransform44 () const |
return contents as transform44 | |
Util::Blob | AsBlob () const |
return contents as blob | |
Util::String | AsBase64 () const |
return contents as base64 string | |
template<typename T > | |
T | As () const |
convert to "anything" | |
bool | IsValidInt () const |
return true if the content is a valid integer | |
bool | IsValidFloat () const |
return true if the content is a valid float | |
bool | IsValidBool () const |
return true if the content is a valid bool | |
bool | IsValidVec2 () const |
return true if the content is a valid vec2 | |
bool | IsValidVec4 () const |
return true if the content is a valid vec4 | |
bool | IsValidMat4 () const |
return true if content is a valid mat4 | |
bool | IsValidTransform44 () const |
return true if content is a valid transform44 | |
template<typename T > | |
bool | IsValid () const |
generic valid checker | |
String | GetFileExtension () const |
get filename extension without dot | |
bool | CheckFileExtension (const String &ext) const |
check file extension | |
void | ConvertBackslashes () |
convert backslashes to slashes | |
void | StripFileExtension () |
remove file extension | |
void | ChangeFileExtension (const Util::String &newExt) |
change file extension | |
void | StripAssignPrefix () |
remove assign prefix (for example tex:) | |
void | ChangeAssignPrefix (const Util::String &newPref) |
change assign prefix | |
String | ExtractFileName () const |
extract the part after the last directory separator | |
String | ExtractLastDirName () const |
extract the last directory of the path | |
String | ExtractDirName () const |
extract the part before the last directory separator | |
String | ExtractToLastSlash () const |
extract path until last slash | |
void | ReplaceIllegalFilenameChars (char replacement) |
replace illegal filename characters | |
const char * | c_str () const |
helpers to interface with libraries that expect std::string like apis | |
size_t | length () const |
bool | empty () const |
Static Public Member Functions | |
static String | Sprintf (const char *fmtString,...) |
static constructor for string using printf | |
static String | Concatenate (const Array< String > &strArray, const String &whiteSpace) |
concatenate array of strings into new string | |
static bool | MatchPattern (const String &str, const String &pattern) |
pattern matching | |
static String | FromByte (byte i) |
construct a string from a byte | |
static String | FromUByte (ubyte i) |
construct a string from a ubyte | |
static String | FromShort (short i) |
construct a string from a short | |
static String | FromUShort (ushort i) |
construct a string from a ushort | |
static String | FromInt (int i) |
construct a string from an int | |
static String | FromUInt (uint i) |
construct a string from a uint | |
static String | FromLong (long i) |
construct a string from a long | |
static String | FromSize (size_t i) |
construct a string from a size_t | |
static String | FromLongLong (long long i) |
construct a string from a long long | |
static String | FromFloat (float f) |
construct a string from a float | |
static String | FromDouble (double f) |
construct a string from a double | |
static String | FromBool (bool b) |
construct a string from a bool | |
static String | FromVec2 (const Math::vec2 &v) |
construct a string from vec2 | |
static String | FromVec3 (const Math::vec3 &v) |
construct a string from vec3 | |
static String | FromVec4 (const Math::vec4 &v) |
construct a string from vec4 | |
static String | FromFloat2 (const Math::float2 &v) |
construct a string from float2 | |
static String | FromFloat3 (const Math::float3 &v) |
construct a string from float2 | |
static String | FromFloat4 (const Math::float4 &v) |
construct a string from float2 | |
static String | FromQuat (const Math::quat &q) |
construct a string from quat | |
static String | FromMat4 (const Math::mat4 &m) |
construct a string from mat4 | |
static String | FromTransform44 (const Math::transform44 &m) |
construct a string from transform44 | |
static String | FromBlob (const Util::Blob &b) |
create from blob | |
static String | FromBase64 (const String &) |
create from base64 | |
template<typename T > | |
static String | From (const T &t) |
convert from "anything" | |
static constexpr uint | Hash (const char *c, std::size_t s) |
Hash a string. | |
template<typename INTEGER > | |
static String | Hex (INTEGER i) |
construct a hex string from an int | |
static bool | IsDigit (char c) |
test if provided character is a digit (0..9) | |
static bool | IsAlpha (char c) |
test if provided character is an alphabet character (A..Z, a..z) | |
static bool | IsAlNum (char c) |
test if provided character is an alpha-numeric character (A..Z,a..z,0..9) | |
static bool | IsLower (char c) |
test if provided character is a lower case character | |
static bool | IsUpper (char c) |
test if provided character is an upper-case character | |
static int | StrCmp (const char *str0, const char *str1) |
lowlevel string compare wrapper function | |
static int | StrLen (const char *str) |
lowlevel string length function | |
static const char * | StrChr (const char *str, int c) |
find character in string | |
static Dictionary< String, String > | ParseKeyValuePairs (const String &str) |
parse key/value pair string ("key0=value0 key1=value1") | |
Public Attributes | |
string | heap |
fixed char | local [20] |
int | strLen |
int | heapBufferSize |
Private Types | |
enum | { LocalStringSize = 16 } |
Private Member Functions | |
void | Delete () |
delete contents | |
char * | GetLastSlash () const |
get pointer to last directory separator | |
void | Alloc (SizeT size) |
allocate the string buffer (discards old content) | |
void | Realloc (SizeT newSize) |
(re-)allocate the string buffer (copies old content) | |
Private Attributes | |
char * | heapBuffer |
char | localBuffer [LocalStringSize] |
SizeT | strLen |
SizeT | heapBufferSize |
Friends | |
bool | operator== (const String &a, const String &b) |
equality operator | |
bool | operator== (const String &a, const char *cStr) |
shortcut equality operator | |
bool | operator== (const char *cStr, const String &a) |
shortcut equality operator | |
bool | operator== (const String &a, std::nullptr_t) |
empty string operator | |
bool | operator!= (const String &a, const String &b) |
inequality operator | |
bool | operator< (const String &a, const String &b) |
less-then operator | |
bool | operator> (const String &a, const String &b) |
greater-then operator | |
bool | operator<= (const String &a, const String &b) |
less-or-equal operator | |
bool | operator>= (const String &a, const String &b) |
greater-then operator | |
|
inline |
constructor
|
inline |
copy constructor
|
inlinenoexcept |
move constructor
|
inline |
construct from C string
|
inline |
construct from C string
|
inline |
destructor
|
private |
allocate the string buffer (discards old content)
Allocate a new heap buffer, discards old contents.
void Util::String::Append | ( | const char * | str | ) |
append c-string
|
inline |
append string
void Util::String::Append | ( | const T & | t | ) |
generic append
|
inline |
append bool value
|
inline |
append byte value
|
inline |
append character
|
inline |
append float value
|
inline |
append int value
|
inline |
append mat4 value
void Util::String::AppendRange | ( | const char * | str, |
SizeT | numChars ) |
append a range of characters
|
inline |
append unsigned byte value
|
inline |
append vec2 value
|
inline |
append vec3 value
|
inline |
append vec4 value
T Util::String::As | ( | ) | const |
convert to "anything"
Util::String Util::String::AsBase64 | ( | ) | const |
return contents as base64 string
Util::Blob Util::String::AsBlob | ( | ) | const |
return contents as blob
bool Util::String::AsBool | ( | ) | const |
return contents as bool
|
inline |
return contents as character pointer
float Util::String::AsFloat | ( | ) | const |
return contents as float
Returns content as float.
Note: this method doesn't check whether the contents is actually a valid float. Use the IsValidInt() method for this!
Math::float2 Util::String::AsFloat2 | ( | ) | const |
return contents as vec2
Math::float3 Util::String::AsFloat3 | ( | ) | const |
return contents as vec3
Math::float4 Util::String::AsFloat4 | ( | ) | const |
return contents as vec4
int Util::String::AsInt | ( | ) | const |
return contents as integer
Returns content as integer.
Note: this method doesn't check whether the contents is actually a valid integer. Use the IsValidInteger() method for this!
long long Util::String::AsLongLong | ( | ) | const |
return contents as long long
Returns content as integer.
Note: this method doesn't check whether the contents is actually a valid integer. Use the IsValidInteger() method for this!
Math::mat4 Util::String::AsMat4 | ( | ) | const |
return contents as mat4
Returns content as mat4.
Note: this method doesn't check whether the contents is actually a valid mat4. Use the IsValidMat4() method for this!
Math::transform44 Util::String::AsTransform44 | ( | ) | const |
return contents as transform44
Math::vec2 Util::String::AsVec2 | ( | ) | const |
return contents as vec2
Returns content as vec2.
Note: this method doesn't check whether the contents is actually a valid vec4. Use the IsValidFloat2() method for this!
Math::vec3 Util::String::AsVec3 | ( | ) | const |
return contents as vec3
Math::vec4 Util::String::AsVec4 | ( | ) | const |
return contents as vec4
Returns content as vec4.
Note: this method doesn't check whether the contents is actually a valid vec4. Use the IsValidVec4() method for this!
bool Util::String::BeginsWithString | ( | const String & | s | ) | const |
returns true if string begins with string
|
inline |
helpers to interface with libraries that expect std::string like apis
void Util::String::ChangeAssignPrefix | ( | const Util::String & | newPref | ) |
change assign prefix
void Util::String::ChangeFileExtension | ( | const Util::String & | newExt | ) |
change file extension
|
inline |
check file extension
|
inline |
return true if string only contains characters from charSet argument
Return true if the string only contains characters which are in the defined character set.
|
inline |
clear the string
|
static |
concatenate array of strings into new string
bool Util::String::ContainsCharFromSet | ( | const String & | charSet | ) | const |
returns true if string contains any character from set
Returns true if string contains one of the characters from charset.
|
inline |
convert backslashes to slashes
Converts backslashes to slashes.
bool Util::String::CopyToBuffer | ( | char * | buf, |
SizeT | bufSize ) const |
copy to char buffer (return false if buffer is too small)
|
inlineprivate |
delete contents
|
inline |
bool Util::String::EndsWithString | ( | const String & | s | ) | const |
returns true if string ends with string
String Util::String::ExtractDirName | ( | ) | const |
extract the part before the last directory separator
Return a String object containing the part before the last directory separator.
NOTE: I left my fix in that returns the last slash (or colon), this was necessary to tell if a dirname is a normal directory or an assign.
|
inline |
extract the part after the last directory separator
Return a String object containing the part after the last path separator.
String Util::String::ExtractLastDirName | ( | ) | const |
extract the last directory of the path
Return a String object containing the last directory of the path, i.e.
a category.
extract substring
Extract a substring range.
extract substring to end of this string
Extract a substring until the end of the original string.
|
inline |
extract path until last slash
Return a path string object which contains of the complete path up to the last slash.
Returns an empty string if there is no slash in the path.
void Util::String::Fill | ( | SizeT | length, |
unsigned char | character ) |
set string length and fill all characters with arg
return index of character in string, or InvalidIndex if not found
Return index of character in string, or InvalidIndex if not found.
return start index of substring, or InvalidIndex if not found
Return the index of a substring, or InvalidIndex if not found.
void Util::String::FirstCharToUpper | ( | ) |
convert first char of string to upper case
void __cdecl Util::String::Format | ( | const char * | fmtString, |
... ) |
format string printf-style
void __cdecl Util::String::FormatArgList | ( | const char * | fmtString, |
va_list | argList ) |
format string printf-style with varargs list
|
static |
convert from "anything"
|
static |
create from base64
|
static |
create from blob
|
inlinestatic |
construct a string from a bool
|
inlinestatic |
construct a string from a byte
|
inlinestatic |
construct a string from a double
|
inlinestatic |
construct a string from a float
|
inlinestatic |
construct a string from float2
|
inlinestatic |
construct a string from float2
|
inlinestatic |
construct a string from float2
|
inlinestatic |
construct a string from an int
|
inlinestatic |
construct a string from a long
|
inlinestatic |
construct a string from a long long
|
inlinestatic |
construct a string from mat4
|
inlinestatic |
construct a string from quat
|
inlinestatic |
construct a string from a short
|
inlinestatic |
construct a string from a size_t
|
inlinestatic |
construct a string from transform44
|
inlinestatic |
construct a string from vec2
|
inlinestatic |
construct a string from vec3
|
inlinestatic |
construct a string from vec4
|
inline |
*** OBSOLETE *** only Nebula2 compatibility
String Util::String::GetFileExtension | ( | ) | const |
get filename extension without dot
|
private |
get pointer to last directory separator
Get a pointer to the last directory separator.
|
staticconstexpr |
Hash a string.
|
inline |
return a 32-bit hash code for the string
This method computes a hash code for the string.
The method is compatible with the Util::HashTable class.
|
inlinestatic |
construct a hex string from an int
|
static |
test if provided character is an alpha-numeric character (A..Z,a..z,0..9)
|
static |
test if provided character is an alphabet character (A..Z, a..z)
|
static |
test if provided character is a digit (0..9)
|
inline |
return true if string object is empty
|
static |
test if provided character is a lower case character
|
static |
test if provided character is an upper-case character
|
inline |
return true if string object is not empty
bool Util::String::IsValid | ( | ) | const |
generic valid checker
bool Util::String::IsValidBool | ( | ) | const |
return true if the content is a valid bool
|
inline |
return true if the content is a valid float
Note: this method is not 100% correct, it just checks for invalid characters.
|
inline |
return true if the content is a valid integer
bool Util::String::IsValidMat4 | ( | ) | const |
return true if content is a valid mat4
Note: this method is not 100% correct, it just checks for invalid characters.
bool Util::String::IsValidTransform44 | ( | ) | const |
return true if content is a valid transform44
Note: this method is not 100% correct, it just checks for invalid characters.
bool Util::String::IsValidVec2 | ( | ) | const |
return true if the content is a valid vec2
Note: this method is not 100% correct, it just checks for invalid characters.
bool Util::String::IsValidVec4 | ( | ) | const |
return true if the content is a valid vec4
Note: this method is not 100% correct, it just checks for invalid characters.
|
inline |
return length of string
|
inline |
pattern matching
Pattern-matching, TCL-style.
|
inline |
+= operator
|
inline |
assign from const char*
|
inline |
assignment operator
|
inlinenoexcept |
move operator
|
inline |
read/write index operator
NOTE: unlike the read-only indexer, the terminating 0 is NOT a valid part of the string because it may not be overwritten!!!
|
inline |
read-only index operator
|
static |
parse key/value pair string ("key0=value0 key1=value1")
|
private |
(re-)allocate the string buffer (copies old content)
(Re-)allocate external buffer and copy existing string contents there.
void Util::String::ReplaceChars | ( | const String & | charSet, |
char | replacement ) |
replace any char set character within a string with the replacement character
|
inline |
replace illegal filename characters
void Util::String::Reserve | ( | SizeT | newSize | ) |
reserve internal buffer size to prevent heap allocs
Reserves internal space to prevent excessive heap re-allocations.
If you plan to do many Append() operations this may help alot.
void Util::String::Set | ( | const char * | ptr, |
size_t | length ) |
set as char ptr, with explicit length. will assert if size_t exceeds 2^32
void Util::String::Set | ( | const char * | str, |
SizeT | length ) |
set as char ptr, with explicit length
Sets a new string content.
This will handle all special cases and try to minimize heap allocations as much as possible.
void Util::String::Set | ( | const T & | t | ) |
generic setter
void Util::String::SetBool | ( | bool | val | ) |
set as bool value
void Util::String::SetByte | ( | byte | val | ) |
set as byte value
void Util::String::SetCharPtr | ( | const char * | s | ) |
set content to char ptr
void Util::String::SetDouble | ( | double | val | ) |
set as double value
void Util::String::SetFloat | ( | float | val | ) |
set as float value
void Util::String::SetFloat2 | ( | const Math::float2 & | v | ) |
set as vec2 value
void Util::String::SetFloat3 | ( | const Math::float3 & | v | ) |
set as vec3 value
void Util::String::SetFloat4 | ( | const Math::float4 & | v | ) |
set as vec4 value
void Util::String::SetInt | ( | int | val | ) |
set as int value
void Util::String::SetLong | ( | long | val | ) |
set as long value
void Util::String::SetLongLong | ( | long long | val | ) |
set as long long value
void Util::String::SetMat4 | ( | const Math::mat4 & | v | ) |
set as mat4 value
void Util::String::SetQuaternion | ( | const Math::quat & | v | ) |
set as quaternion
void Util::String::SetShort | ( | short | val | ) |
set as short value
void Util::String::SetSizeT | ( | size_t | val | ) |
set as long value
void Util::String::SetTransform44 | ( | const Math::transform44 & | v | ) |
set as transform44 value
void Util::String::SetUByte | ( | ubyte | val | ) |
set as ubyte value
void Util::String::SetUInt | ( | uint | val | ) |
set as uint value
void Util::String::SetUShort | ( | ushort | val | ) |
set as ushort value
void Util::String::SetVec2 | ( | const Math::vec2 & | v | ) |
set as vec2 value
void Util::String::SetVec3 | ( | const Math::vec3 & | v | ) |
set as vec3 value
void Util::String::SetVec4 | ( | const Math::vec4 & | v | ) |
set as vec4 value
|
static |
static constructor for string using printf
|
static |
find character in string
|
static |
lowlevel string compare wrapper function
void Util::String::Strip | ( | const String & | charSet | ) |
terminate string at first occurence of character in set
Terminates the string at the first occurance of one of the characters in charSet.
void Util::String::StripAssignPrefix | ( | ) |
remove assign prefix (for example tex:)
void Util::String::StripFileExtension | ( | ) |
remove file extension
Remove the file extension.
|
static |
lowlevel string length function
|
inline |
substitute every occurance of a character with another character
Replace character with another.
substitute every occurance of a string with another string
Substitute every occurance of origStr with substStr.
void Util::String::TerminateAtIndex | ( | IndexT | index | ) |
terminate string at given index
Terminates the string at the given index.
tokenize string into a provided String array, SLOW since new array will be constructed
This is the slow-but-convenient Tokenize() method.
Slow since the returned string array will be constructed anew with every method call. Consider the Tokenize() method which takes a string array as input, since this may allow reusing of the array, reducing heap allocations.
tokenize string, keep strings within fence characters intact, SLOW since new array will be constructed
Slow version of Tokenize() with fence character.
See above Tokenize() for details.
SizeT Util::String::Tokenize | ( | const String & | whiteSpace, |
char | fence, | ||
Array< String > & | outTokens ) const |
tokenize string, keep strings within fence characters intact (faster if tokens array can be reused)
Tokenize a string, but keeps the string within the fence-character intact.
For instance for the sentence:
He said: "I don't know."
A Tokenize(" ", '"', tokens) would return:
token 0: He token 1: said: token 2: I don't know.
void Util::String::ToLower | ( | ) |
convert string to lower case
void Util::String::ToUpper | ( | ) |
convert string to upper case
void Util::String::Trim | ( | const String & | charSet | ) |
trim characters from charset at both sides of string
Trim both sides of a string.
void Util::String::TrimLeft | ( | const String & | charSet | ) |
delete characters from charset at left side of string
Removes all characters in charSet from the left side of the string.
void Util::String::TrimRight | ( | const String & | charSet | ) |
delete characters from charset at right side of string
Removes all characters in charSet from the right side of the string.
|
friend |
shortcut equality operator
|
friend |
shortcut equality operator
|
friend |
empty string operator
string Util.String.heap |
|
private |
int Util.String.heapBufferSize |
|
private |
fixed char Util.String.local[20] |
|
private |
int Util.String.strLen |
|
private |