61 String(
const char* cStr,
size_t len);
112 void Append(
const char* str);
161 void __cdecl
Format(
const char* fmtString, ...);
163 void __cdecl
FormatArgList(
const char* fmtString, va_list argList);
182 void Set(
const char* ptr,
size_t length);
232 template<
typename T>
void Set(
const T& t);
255 template<
typename T>
void Append(
const T& t);
260 const char*
Get()
const;
290 template<
typename T> T
As()
const;
358 static constexpr uint Hash(
const char* c, std::size_t s);
361 template<
typename INTEGER>
408 static int StrCmp(
const char* str0,
const char* str1);
410 static int StrLen(
const char* str);
412 static const char*
StrChr(
const char* str,
int c);
458 this->heapBuffer =
nullptr;
519 heapBuffer(rhs.heapBuffer),
521 heapBufferSize(rhs.heapBufferSize)
525 rhs.heapBuffer =
nullptr;
526 this->localBuffer[0] = 0;
530 if (this->strLen > 0)
532 Memory::Copy(rhs.localBuffer, this->localBuffer, this->strLen);
534 this->localBuffer[this->strLen] = 0;
584 this->strLen = rhs.strLen;
588 this->heapBuffer = rhs.heapBuffer;
589 this->heapBufferSize = rhs.heapBufferSize;
590 rhs.heapBuffer =
nullptr;
591 rhs.heapBufferSize = 0;
595 if (this->strLen > 0)
597 Memory::Copy(rhs.localBuffer, this->localBuffer, this->strLen);
599 this->localBuffer[this->strLen] = 0;
677 return (0 == this->
strLen);
686 return (0 != this->
strLen);
719 char* ptr =
const_cast<char*
>(this->
AsCharPtr());
721 for (i = 0; i <= this->
strLen; i++)
761 pathString = &(lastSlash[1]);
801 for (i = 0; i < this->
strLen; i++)
1075template<
typename INTEGER>
1079 constexpr SizeT hexLength =
sizeof(INTEGER) << 1;
1085 for (
SizeT n = 0, j = (hexLength - 1) * 4; n < hexLength; ++n, j -= 4)
1194 for (i = 0; i < s; i++)
1215Util::String operator ""_str(
const char* c, std::size_t s);
1222operator ""_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:1206
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:987
void SetInt(int val)
set as int value
Definition string.cc:1405
Math::mat4 AsMat4() const
return contents as mat4
Definition string.cc:705
Util::Blob AsBlob() const
return contents as blob
Definition string.cc:1231
static bool IsAlpha(char c)
test if provided character is an alphabet character (A..Z, a..z)
Definition string.cc:1103
static String FromUByte(ubyte i)
construct a string from a ubyte
Definition string.h:854
void SetShort(short val)
set as short value
Definition string.cc:1387
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:1605
String ExtractToLastSlash() const
extract path until last slash
Definition string.h:777
static String FromUInt(uint i)
construct a string from a uint
Definition string.h:898
static String FromFloat2(const Math::float2 &v)
construct a string from float2
Definition string.h:1009
void Clear()
clear the string
Definition string.h:666
void SetTransform44(const Math::transform44 &v)
set as transform44 value
Definition string.cc:1577
~String()
destructor
Definition string.h:469
static const char * StrChr(const char *str, int c)
find character in string
Definition string.cc:1159
void Capitalize()
convert first char of string to upper case
Definition string.cc:941
void AppendVec4(const Math::vec4 &v)
append vec4 value
Definition string.h:1170
SizeT Length() const
return length of string
Definition string.h:657
@ LocalStringSize
Definition string.h:429
size_t length() const
Definition string.h:392
void AppendChar(char val)
append character
Definition string.h:1097
bool IsValidBool() const
return true if the content is a valid bool
Definition string.cc:1015
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:964
static String FromByte(byte i)
construct a string from a byte
Definition string.h:843
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:1133
void AppendByte(byte val)
append byte value
Definition string.h:1115
static String FromQuat(const Math::quat &q)
construct a string from quat
Definition string.h:1042
void ConvertBackslashes()
convert backslashes to slashes
Definition string.h:735
void SetVec2(const Math::vec2 &v)
set as vec2 value
Definition string.cc:1498
int strLen
Definition String.cs:11
static String FromDouble(double f)
construct a string from a double
Definition string.h:953
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:684
void StripFileExtension()
remove file extension
Definition string.cc:801
void SetBool(bool val)
set as bool value
Definition string.cc:1468
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:1142
static String FromTransform44(const Math::transform44 &m)
construct a string from transform44
Definition string.h:1064
void SetDouble(double val)
set as double value
Definition string.cc:1459
void AppendVec2(const Math::vec2 &v)
append vec2 value
Definition string.h:1152
bool AsBool() const
return contents as bool
Definition string.cc:1072
void SetLongLong(long long val)
set as long long value
Definition string.cc:1441
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:1094
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:1543
char operator[](IndexT i) const
read-only index operator
Definition string.h:635
void Fill(SizeT length, unsigned char character)
set string length and fill all characters with arg
Definition string.cc:1484
bool IsValidInt() const
return true if the content is a valid integer
Definition string.h:815
static String FromInt(int i)
construct a string from an int
Definition string.h:887
static String FromFloat(float f)
construct a string from a float
Definition string.h:942
static String FromVec4(const Math::vec4 &v)
construct a string from vec4
Definition string.h:998
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:1063
String()
constructor
Definition string.h:441
void ChangeAssignPrefix(const Util::String &newPref)
change assign prefix
Definition string.cc:1196
void ReplaceIllegalFilenameChars(char replacement)
replace illegal filename characters
Definition string.h:834
void Delete()
delete contents
Definition string.h:453
Util::String AsBase64() const
return contents as base64 string
Definition string.cc:1265
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:1672
bool CheckFileExtension(const String &ext) const
check file extension
Definition string.h:744
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:755
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:1282
void SetMat4(const Math::mat4 &v)
set as mat4 value
Definition string.cc:1561
bool IsValidFloat() const
return true if the content is a valid float
Definition string.h:825
void SetSizeT(size_t val)
set as long value
Definition string.cc:1432
Math::float3 AsFloat3() const
return contents as vec3
Definition string.cc:1698
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:1301
Math::vec2 AsVec2() const
return contents as vec2
Definition string.cc:1643
static String FromFloat3(const Math::float3 &v)
construct a string from float2
Definition string.h:1020
void ChangeFileExtension(const Util::String &newExt)
change file extension
Definition string.cc:1186
static bool IsUpper(char c)
test if provided character is an upper-case character
Definition string.cc:1130
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:617
Math::float4 AsFloat4() const
return contents as vec4
Definition string.cc:1711
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:1124
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:1190
static int StrCmp(const char *str0, const char *str1)
lowlevel string compare wrapper function
Definition string.cc:1139
char * GetLastSlash() const
get pointer to last directory separator
Definition string.cc:1002
SizeT heapBufferSize
Definition string.h:434
static String From(const T &t)
convert from "anything"
void operator=(const String &rhs)
assignment operator
Definition string.h:567
void SetLong(long val)
set as long value
Definition string.cc:1423
static String FromLongLong(long long i)
construct a string from a long long
Definition string.h:931
void SetByte(byte val)
set as byte value
Definition string.cc:1369
Math::float2 AsFloat2() const
return contents as vec2
Definition string.cc:1685
static String FromMat4(const Math::mat4 &m)
construct a string from mat4
Definition string.h:1053
int AsInt() const
return contents as integer
Definition string.cc:1039
void SetVec3(const Math::vec3 &v)
set as vec3 value
Definition string.cc:1507
void SetUInt(uint val)
set as uint value
Definition string.cc:1414
static String FromBlob(const Util::Blob &b)
create from blob
Definition string.cc:1206
static String FromShort(short i)
construct a string from a short
Definition string.h:865
void AppendVec3(const Math::vec3 &v)
append vec3 value
Definition string.h:1161
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:876
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:1516
void AppendMat4(const Math::mat4 &v)
append mat4 value
Definition string.h:1179
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:542
void AppendInt(int val)
append int value
Definition string.h:1106
static String FromVec2(const Math::vec2 &v)
construct a string from vec2
Definition string.h:976
void Realloc(SizeT newSize)
(re-)allocate the string buffer (copies old content)
Definition string.cc:1324
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:1450
static int StrLen(const char *str)
lowlevel string length function
Definition string.cc:1149
char * heapBuffer
Definition string.h:431
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:1169
void SetFloat2(const Math::float2 &v)
set as vec2 value
Definition string.cc:1525
bool IsValidTransform44() const
return true if content is a valid transform44
Definition string.cc:1629
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:1617
const char * Get() const
*** OBSOLETE *** only Nebula2 compatibility
Definition string.h:558
static bool IsLower(char c)
test if provided character is a lower case character
Definition string.cc:1121
bool IsEmpty() const
return true if string object is empty
Definition string.h:675
String GetFileExtension() const
get filename extension without dot
Definition string.cc:985
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:909
char localBuffer[LocalStringSize]
Definition string.h:432
void operator+=(const String &rhs)
+= operator
Definition string.h:626
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:1552
const char * c_str() const
helpers to interface with libraries that expect std::string like apis
Definition string.h:390
void CamelCaseToWords()
insert spaces before each capital letter in the string.
Definition string.cc:951
static String FromSize(size_t i)
construct a string from a size_t
Definition string.h:920
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:695
void SubstituteChar(char c, char subst)
substitute every occurance of a character with another character
Definition string.h:717
static String Hex(INTEGER i)
construct a hex string from an int
Definition string.h:1077
void SetUByte(ubyte val)
set as ubyte value
Definition string.cc:1378
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:1051
void SetUShort(ushort val)
set as ushort value
Definition string.cc:1396
static String FromFloat4(const Math::float4 &v)
construct a string from float2
Definition string.h:1031
Math::vec3 AsVec3() const
return contents as vec3
Definition string.cc:1656
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:798
bool IsValid() const
generic valid checker
bool empty() const
Definition string.h:394
SizeT strLen
Definition string.h:433
void Reserve(SizeT newSize)
reserve internal buffer size to prevent heap allocs
Definition string.cc:1357
bool ContainsCharFromSet(const String &charSet) const
returns true if string contains any character from set
Definition string.cc:973
void SetFloat3(const Math::float3 &v)
set as vec3 value
Definition string.cc:1534
static bool IsAlNum(char c)
test if provided character is an alpha-numeric character (A..Z,a..z,0..9)
Definition string.cc:1112
bool IsValidVec2() const
return true if the content is a valid vec2
Definition string.cc:1593
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