5#include "../DataTypes.h"
35 Set(
const_cast<wchar_t *
>(data.data()),
static_cast<int32
>(data.size()));
45 Set(
const_cast<wchar_t *
>(data),
static_cast<int32
>(wcslen(data)));
51 WideString(
const wchar_t *data, int32 length) : m_Data(nullptr),
54 Set(
const_cast<wchar_t *
>(data), length);
60 WideString(
const wchar_t *start,
const wchar_t *end) : m_Data(nullptr),
63 Set(
const_cast<wchar_t *
>(start),
static_cast<int32
>(end - start));
92 Set(str.Get(), str.m_Length);
97 m_Length(str.m_Length)
107 Set(str.
Get(), str.m_Length);
117 Set(str.
Get(), str.m_Length);
121 str.m_Data =
nullptr;
128 return wcscmp(this->
Get(), str.
Get()) == 0;
131 WideString operator+(
const wchar_t *str)
const
133 int32 newLength = this->GetLength() +
static_cast<int32
>(wcslen(str)) + 1;
134 wchar_t *data =
new wchar_t[newLength];
136 memcpy(data, this->
Get(), this->GetLength() *
sizeof(
wchar_t));
147 int32 newLength = this->GetLength() +
static_cast<int32
>(wcslen(str.
Get())) + 1;
148 wchar_t *data =
new wchar_t[newLength];
150 memcpy(data, this->
Get(), this->GetLength() *
sizeof(
wchar_t));
151 wcscat(data, str.
Get());
164 void Set(
wchar_t *data, int32 length);
177 [[nodiscard]]
inline wchar_t *
Get()
const
182 [[nodiscard]]
inline int32 GetLength()
const
187 [[nodiscard]]
bool StartsWith(
const WideString &other)
const;
189 [[nodiscard]] int32 HashCode()
const;
Represents a mutable sequence of utf-16 characters, providing various member functions for string man...
Definition WideString.h:14
WideString()
Initializes a new instance of the WideString class.
Definition WideString.h:23
void Set(wchar_t *data, int32 length)
Sets an array of characters to the string.
Definition Strings.cpp:84
wchar_t * Get() const
Gets a raw char sequence.
Definition WideString.h:177
WideString(wchar_t c)
Initializes a new instance of the WideString class.
Definition WideString.h:69
WideString(const WideString &str)
Initializes a new instance of the WideString class.
Definition WideString.h:87
WideString(const wchar_t *data, int32 length)
Initializes a new instance of the WideString class.
Definition WideString.h:51
WideString(const wchar_t *start, const wchar_t *end)
Initializes a new instance of the WideString class.
Definition WideString.h:60
WideString(const std::wstring &data)
Initializes a new instance of the WideString class.
Definition WideString.h:32
WideString(const wchar_t *data)
Initializes a new instance of the WideString class.
Definition WideString.h:42
void Allocate(int32 length)
Use only when string is empty.
Definition Strings.cpp:97