61 String(
const char* cStr,
size_t len);
112 void Append(
const char* str);
159 void __cdecl
Format(
const char* fmtString, ...);
161 void __cdecl
FormatArgList(
const char* fmtString, va_list argList);
180 void Set(
const char* ptr,
size_t length);
230 template<
typename T>
void Set(
const T& t);
253 template<
typename T>
void Append(
const T& t);
258 const char*
Get()
const;
288 template<
typename T> T
As()
const;
356 static constexpr uint Hash(
const char* c, std::size_t s);
359 template<
typename INTEGER>
406 static int StrCmp(
const char* str0,
const char* str1);
408 static int StrLen(
const char* str);
410 static const char*
StrChr(
const char* str,
int c);
456 this->heapBuffer =
nullptr;
517 heapBuffer(rhs.heapBuffer),
519 heapBufferSize(rhs.heapBufferSize)
523 rhs.heapBuffer =
nullptr;
524 this->localBuffer[0] = 0;
528 if (this->strLen > 0)
530 Memory::Copy(rhs.localBuffer, this->localBuffer, this->strLen);
532 this->localBuffer[this->strLen] = 0;
582 this->strLen = rhs.strLen;
586 this->heapBuffer = rhs.heapBuffer;
587 this->heapBufferSize = rhs.heapBufferSize;
588 rhs.heapBuffer =
nullptr;
589 rhs.heapBufferSize = 0;
593 if (this->strLen > 0)
595 Memory::Copy(rhs.localBuffer, this->localBuffer, this->strLen);
597 this->localBuffer[this->strLen] = 0;
675 return (0 == this->
strLen);
684 return (0 != this->
strLen);
717 char* ptr =
const_cast<char*
>(this->
AsCharPtr());
719 for (i = 0; i <= this->
strLen; i++)
759 pathString = &(lastSlash[1]);
799 for (i = 0; i < this->
strLen; i++)
1073template<
typename INTEGER>
1077 constexpr SizeT hexLength =
sizeof(INTEGER) << 1;
1083 for (
SizeT n = 0, j = (hexLength - 1) * 4; n < hexLength; ++n, j -= 4)
1192 for (i = 0; i < s; i++)
1213Util::String operator ""_str(
const char* c, std::size_t s);
1220operator ""_hash(
const char* c, std::size_t s)
Nebula's dynamic array class.
Definition array.h:60
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:34
#define n_assert(exp)
Definition debug.h:50
Different curves.
Definition angularpfeedbackloop.h:17
half operator+(half one, half two)
Definition half.h:105
void Copy(const void *from, void *to, size_t numBytes)
Copy a chunk of memory (note the argument order is different from memcpy()!!!)
Definition osxmemory.cc:213
void Free(HeapType heapType, void *ptr)
Free a block of memory.
Definition osxmemory.cc:136
@ StringDataHeap
Definition osxmemoryconfig.h:31
A pinned array is an array which manages its own virtual memory.
Definition String.cs:6
auto Format
Definition string.h:1204
A 4x4 single point precision float matrix.
Definition mat4.h:49
A quaternion is usually used to represent an orientation in 3D space.
Definition quat.h:30
A 2-component float vector class.
Definition vec2.h:21
A 3D vector.
Definition vec3.h:40
A 4D vector.
Definition vec4.h:24
Nebula's universal string class.
Definition string.h:50
void SetCharPtr(const char *s)
set content to char ptr
Definition string.cc:763
T As() const
convert to "anything"
static String FromVec3(const Math::vec3 &v)
construct a string from vec3
Definition string.h:985
void SetInt(int val)
set as int value
Definition string.cc:1384
Math::mat4 AsMat4() const
return contents as mat4
Definition string.cc:705
Util::Blob AsBlob() const
return contents as blob
Definition string.cc:1210
static bool IsAlpha(char c)
test if provided character is an alphabet character (A..Z, a..z)
Definition string.cc:1082
static String FromUByte(ubyte i)
construct a string from a ubyte
Definition string.h:852
void SetShort(short val)
set as short value
Definition string.cc:1366
void ToLower()
convert string to lower case
Definition string.cc:913
bool IsValidVec4() const
return true if the content is a valid vec4
Definition string.cc:1584
String ExtractToLastSlash() const
extract path until last slash
Definition string.h:775
static String FromUInt(uint i)
construct a string from a uint
Definition string.h:896
void FirstCharToUpper()
convert first char of string to upper case
Definition string.cc:941
static String FromFloat2(const Math::float2 &v)
construct a string from float2
Definition string.h:1007
void Clear()
clear the string
Definition string.h:664
void SetTransform44(const Math::transform44 &v)
set as transform44 value
Definition string.cc:1556
~String()
destructor
Definition string.h:467
static const char * StrChr(const char *str, int c)
find character in string
Definition string.cc:1138
void AppendVec4(const Math::vec4 &v)
append vec4 value
Definition string.h:1168
SizeT Length() const
return length of string
Definition string.h:655
@ LocalStringSize
Definition string.h:427
size_t length() const
Definition string.h:390
void AppendChar(char val)
append character
Definition string.h:1095
bool IsValidBool() const
return true if the content is a valid bool
Definition string.cc:994
friend bool operator!=(const String &a, const String &b)
inequality operator
Definition string.cc:868
static String FromBool(bool b)
construct a string from a bool
Definition string.h:962
static String FromByte(byte i)
construct a string from a byte
Definition string.h:841
void AppendRange(const char *str, SizeT numChars)
append a range of characters
Definition string.cc:161
void AppendFloat(float val)
append float value
Definition string.h:1131
void AppendByte(byte val)
append byte value
Definition string.h:1113
static String FromQuat(const Math::quat &q)
construct a string from quat
Definition string.h:1040
void ConvertBackslashes()
convert backslashes to slashes
Definition string.h:733
void SetVec2(const Math::vec2 &v)
set as vec2 value
Definition string.cc:1477
int strLen
Definition String.cs:11
static String FromDouble(double f)
construct a string from a double
Definition string.h:951
IndexT FindCharIndex(char c, IndexT startIndex=0) const
return index of character in string, or InvalidIndex if not found
Definition string.cc:371
bool IsValid() const
return true if string object is not empty
Definition string.h:682
void StripFileExtension()
remove file extension
Definition string.cc:801
void SetBool(bool val)
set as bool value
Definition string.cc:1447
void Set(const char *ptr, SizeT length)
set as char ptr, with explicit length
Definition string.cc:112
void AppendBool(bool val)
append bool value
Definition string.h:1140
static String FromTransform44(const Math::transform44 &m)
construct a string from transform44
Definition string.h:1062
void SetDouble(double val)
set as double value
Definition string.cc:1438
void AppendVec2(const Math::vec2 &v)
append vec2 value
Definition string.h:1150
bool AsBool() const
return contents as bool
Definition string.cc:1051
void SetLongLong(long long val)
set as long long value
Definition string.cc:1420
void ToUpper()
convert string to upper case
Definition string.cc:927
friend bool operator<=(const String &a, const String &b)
less-or-equal operator
Definition string.cc:895
static bool IsDigit(char c)
test if provided character is a digit (0..9)
Definition string.cc:1073
static String Concatenate(const Array< String > &strArray, const String &whiteSpace)
concatenate array of strings into new string
Definition string.cc:742
void TrimLeft(const String &charSet)
delete characters from charset at left side of string
Definition string.cc:408
friend bool operator==(const String &a, const String &b)
equality operator
Definition string.cc:830
void StripAssignPrefix()
remove assign prefix (for example tex:)
Definition string.cc:816
void SetFloat4(const Math::float4 &v)
set as vec4 value
Definition string.cc:1522
char operator[](IndexT i) const
read-only index operator
Definition string.h:633
void Fill(SizeT length, unsigned char character)
set string length and fill all characters with arg
Definition string.cc:1463
bool IsValidInt() const
return true if the content is a valid integer
Definition string.h:813
static String FromInt(int i)
construct a string from an int
Definition string.h:885
static String FromFloat(float f)
construct a string from a float
Definition string.h:940
static String FromVec4(const Math::vec4 &v)
construct a string from vec4
Definition string.h:996
void __cdecl FormatArgList(const char *fmtString, va_list argList)
format string printf-style with varargs list
Definition string.cc:78
float AsFloat() const
return contents as float
Definition string.cc:1042
String()
constructor
Definition string.h:439
void ChangeAssignPrefix(const Util::String &newPref)
change assign prefix
Definition string.cc:1175
void ReplaceIllegalFilenameChars(char replacement)
replace illegal filename characters
Definition string.h:832
void Delete()
delete contents
Definition string.h:451
Util::String AsBase64() const
return contents as base64 string
Definition string.cc:1244
bool CopyToBuffer(char *buf, SizeT bufSize) const
copy to char buffer (return false if buffer is too small)
Definition string.cc:38
Math::vec4 AsVec4() const
return contents as vec4
Definition string.cc:1651
bool CheckFileExtension(const String &ext) const
check file extension
Definition string.h:742
void ReplaceChars(const String &charSet, char replacement)
replace any char set character within a string with the replacement character
Definition string.cc:682
String ExtractFileName() const
extract the part after the last directory separator
Definition string.h:753
void Append(const T &t)
generic append
String ExtractToEnd(IndexT fromIndex) const
extract substring to end of this string
Definition string.cc:319
static String FromBase64(const String &)
create from base64
Definition string.cc:1261
void SetMat4(const Math::mat4 &v)
set as mat4 value
Definition string.cc:1540
bool IsValidFloat() const
return true if the content is a valid float
Definition string.h:823
void SetSizeT(size_t val)
set as long value
Definition string.cc:1411
Math::float3 AsFloat3() const
return contents as vec3
Definition string.cc:1677
void TrimRight(const String &charSet)
delete characters from charset at right side of string
Definition string.cc:450
int heapBufferSize
Definition String.cs:12
void Alloc(SizeT size)
allocate the string buffer (discards old content)
Definition string.cc:1280
Math::vec2 AsVec2() const
return contents as vec2
Definition string.cc:1622
static String FromFloat3(const Math::float3 &v)
construct a string from float2
Definition string.h:1018
void ChangeFileExtension(const Util::String &newExt)
change file extension
Definition string.cc:1165
static bool IsUpper(char c)
test if provided character is an upper-case character
Definition string.cc:1109
Math::transform44 AsTransform44() const
return contents as transform44
Definition string.cc:722
void Set(const T &t)
generic setter
void Append(const String &str)
append string
Definition string.h:615
Math::float4 AsFloat4() const
return contents as vec4
Definition string.cc:1690
friend bool operator<(const String &a, const String &b)
less-then operator
Definition string.cc:877
void AppendUByte(ubyte val)
append unsigned byte value
Definition string.h:1122
String ExtractDirName() const
extract the part before the last directory separator
Definition string.cc:580
static constexpr uint Hash(const char *c, std::size_t s)
Hash a string.
Definition string.h:1188
static int StrCmp(const char *str0, const char *str1)
lowlevel string compare wrapper function
Definition string.cc:1118
char * GetLastSlash() const
get pointer to last directory separator
Definition string.cc:981
SizeT heapBufferSize
Definition string.h:432
static String From(const T &t)
convert from "anything"
void operator=(const String &rhs)
assignment operator
Definition string.h:565
void SetLong(long val)
set as long value
Definition string.cc:1402
static String FromLongLong(long long i)
construct a string from a long long
Definition string.h:929
void SetByte(byte val)
set as byte value
Definition string.cc:1348
Math::float2 AsFloat2() const
return contents as vec2
Definition string.cc:1664
static String FromMat4(const Math::mat4 &m)
construct a string from mat4
Definition string.h:1051
int AsInt() const
return contents as integer
Definition string.cc:1018
void SetVec3(const Math::vec3 &v)
set as vec3 value
Definition string.cc:1486
void SetUInt(uint val)
set as uint value
Definition string.cc:1393
static String FromBlob(const Util::Blob &b)
create from blob
Definition string.cc:1185
static String FromShort(short i)
construct a string from a short
Definition string.h:863
void AppendVec3(const Math::vec3 &v)
append vec3 value
Definition string.h:1159
void Strip(const String &charSet)
terminate string at first occurence of character in set
Definition string.cc:330
static String FromUShort(ushort i)
construct a string from a ushort
Definition string.h:874
void TerminateAtIndex(IndexT index)
terminate string at given index
Definition string.cc:788
bool BeginsWithString(const String &s) const
returns true if string begins with string
Definition string.cc:389
void SetVec4(const Math::vec4 &v)
set as vec4 value
Definition string.cc:1495
void AppendMat4(const Math::mat4 &v)
append mat4 value
Definition string.h:1177
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:540
void AppendInt(int val)
append int value
Definition string.h:1104
static String FromVec2(const Math::vec2 &v)
construct a string from vec2
Definition string.h:974
void Realloc(SizeT newSize)
(re-)allocate the string buffer (copies old content)
Definition string.cc:1303
String ExtractLastDirName() const
extract the last directory of the path
Definition string.cc:540
void SetFloat(float val)
set as float value
Definition string.cc:1429
static int StrLen(const char *str)
lowlevel string length function
Definition string.cc:1128
char * heapBuffer
Definition string.h:429
SizeT Tokenize(const String &whiteSpace, Array< String > &outTokens) const
tokenize string into a provided String array (faster if tokens array can be reused)
Definition string.cc:203
static Dictionary< String, String > ParseKeyValuePairs(const String &str)
parse key/value pair string ("key0=value0 key1=value1")
Definition string.cc:1148
void SetFloat2(const Math::float2 &v)
set as vec2 value
Definition string.cc:1504
bool IsValidTransform44() const
return true if content is a valid transform44
Definition string.cc:1608
void Trim(const String &charSet)
trim characters from charset at both sides of string
Definition string.cc:493
friend bool operator>(const String &a, const String &b)
greater-then operator
Definition string.cc:886
bool IsValidMat4() const
return true if content is a valid mat4
Definition string.cc:1596
const char * Get() const
*** OBSOLETE *** only Nebula2 compatibility
Definition string.h:556
static bool IsLower(char c)
test if provided character is a lower case character
Definition string.cc:1100
bool IsEmpty() const
return true if string object is empty
Definition string.h:673
String GetFileExtension() const
get filename extension without dot
Definition string.cc:964
void SubstituteString(const String &str, const String &substStr)
substitute every occurance of a string with another string
Definition string.cc:504
static bool MatchPattern(const String &str, const String &pattern)
pattern matching
Definition string.cc:607
static String FromLong(long i)
construct a string from a long
Definition string.h:907
char localBuffer[LocalStringSize]
Definition string.h:430
void operator+=(const String &rhs)
+= operator
Definition string.h:624
bool EndsWithString(const String &s) const
returns true if string ends with string
Definition string.cc:398
static String Sprintf(const char *fmtString,...)
static constructor for string using printf
Definition string.cc:96
void SetQuaternion(const Math::quat &v)
set as quaternion
Definition string.cc:1531
const char * c_str() const
helpers to interface with libraries that expect std::string like apis
Definition string.h:388
static String FromSize(size_t i)
construct a string from a size_t
Definition string.h:918
IndexT FindStringIndex(const String &s, IndexT startIndex=0) const
return start index of substring, or InvalidIndex if not found
Definition string.cc:346
uint32_t HashCode() const
return a 32-bit hash code for the string
Definition string.h:693
void SubstituteChar(char c, char subst)
substitute every occurance of a character with another character
Definition string.h:715
static String Hex(INTEGER i)
construct a hex string from an int
Definition string.h:1075
void SetUByte(ubyte val)
set as ubyte value
Definition string.cc:1357
String ExtractRange(IndexT fromIndex, SizeT numChars) const
extract substring
Definition string.cc:304
long long AsLongLong() const
return contents as long long
Definition string.cc:1030
void SetUShort(ushort val)
set as ushort value
Definition string.cc:1375
static String FromFloat4(const Math::float4 &v)
construct a string from float2
Definition string.h:1029
Math::vec3 AsVec3() const
return contents as vec3
Definition string.cc:1635
friend bool operator>=(const String &a, const String &b)
greater-then operator
Definition string.cc:904
bool CheckValidCharSet(const String &charSet) const
return true if string only contains characters from charSet argument
Definition string.h:796
bool IsValid() const
generic valid checker
bool empty() const
Definition string.h:392
SizeT strLen
Definition string.h:431
void Reserve(SizeT newSize)
reserve internal buffer size to prevent heap allocs
Definition string.cc:1336
bool ContainsCharFromSet(const String &charSet) const
returns true if string contains any character from set
Definition string.cc:952
void SetFloat3(const Math::float3 &v)
set as vec3 value
Definition string.cc:1513
static bool IsAlNum(char c)
test if provided character is an alpha-numeric character (A..Z,a..z,0..9)
Definition string.cc:1091
bool IsValidVec2() const
return true if the content is a valid vec2
Definition string.cc:1572
static const int InvalidIndex
Definition types.h:54
unsigned char ubyte
Definition types.h:34
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32
int IndexT
Definition types.h:48