Class String
Defined in File String.h
Class Documentation
-
class String
Custom string class that we can use safely across a DLL boundary.
Public Functions
-
String()
Constructs an empty string.
-
~String()
Destructor.
Frees string memory.
-
explicit String(char const *const Text, size_t Length)
Constructs a string from a pointer with a given length.
- Parameters
Text – const char* : Pointer to a string buffer to copy data from
Length – size_t : Size of buffer
-
explicit String(size_t Length)
Constructs a string with a given length.
Buffer is set to 0 for debug builds. Buffer isn’t guaranteed to be set to a particular value for release builds.
- Parameters
Length – size_t : Size of buffer
-
String(const char *Text)
Constructs a string from a cstring.
In buffer is treated as a cstring and will assume the end of the buffer is the first /0.
- Parameters
Text – const char* : Pointer to a string buffer to copy data from
-
String &operator=(char const *const Text)
Assigns a cstring to the string.
- Parameters
Text – const char* : Pointer to a string buffer to copy data from
-
inline operator char const*() const
Auto converts to cstring by returning internal buffer.
-
inline char const *c_str() const
Returns internal buffer.
- Returns
char const*
-
List<String> Split(char Delimiter) const
Splits current string by a given delimiter into individual elements.
- Parameters
Delimiter – char
- Returns
csp::common::List<csp::common::String>
-
bool operator==(const char *Other) const
-
bool operator!=(const char *Other) const
-
void Append(const String &Other)
Appends given string.
This will resize the buffer of the current string.
-
void Append(const char *Other)
Appends given cstring.
This will resize the buffer of the current string.
- Parameters
Other – const char* : Cstring to append
-
String &operator+=(const String &Other)
Appends given string.
This will resize the buffer of the current string.
-
String &operator+=(const char *Other)
Appends given cstring.
This will resize the buffer of the current string.
- Parameters
Other – const char* : Cstring to append
- Returns
-
size_t Length() const
Returns the length of the string.
- Returns
size_t
-
size_t AllocatedMemorySize() const
Returns the length of the string including the terminator.
- Returns
size_t
-
bool IsEmpty() const
Checks if the string has any data.
- Returns
bool : Returns true if buffer size > 0
Public Static Functions
-
static String Join(const List<String> &Parts, Optional<char> Separator = nullptr)
Concatenates all elements in the list with a separator after each element and returns as a string.
-
static String Join(const std::initializer_list<String> &Parts, Optional<char> Separator = nullptr)
Concatenates all elements in the initializer_list and returns as a string.
- Parameters
Parts – const std::initializer_list<String>& : initializer_list to concatenate
Separator – csp::common::Optional<char> : An optional separator to add after each concatenated element
- Returns
-
String()