91 T operator[](
size_t index) const;
94 static constexpr
size_t InitSize = 512;
95 T mBuffer[InitSize] = {
'\0'};
96 T *mStringBuffer{
nullptr};
98 size_t mCapacity{InitSize};
116 if (
nullptr != ptr) {
144 if (mStringBuffer !=
nullptr) {
145 return mStringBuffer;
153 if (mStringBuffer !=
nullptr) {
154 delete [] mStringBuffer;
155 mStringBuffer =
nullptr;
156 mCapacity = InitSize;
163 if (ptr ==
nullptr) {
167 T *targetPtr = base.mBuffer;
172 if (
size > base.mCapacity) {
173 if (base.mStringBuffer !=
nullptr) {
174 delete [] base.mStringBuffer;
176 base.mStringBuffer =
new T[
size + 1];
177 base.mCapacity =
size + 1;
178 targetPtr = base.mStringBuffer;
180 memcpy(targetPtr, ptr,
size *
sizeof(T));
181 targetPtr[
size] =
'\0';
187 if (rhs.mSize != mSize) {
191 if (mHashId != rhs.mHashId) {
196 return memcmp(
c_str(), rhs.
c_str(), mSize *
sizeof(T)) == 0;
201 return !(*
this == rhs);
223 if (index >= mSize) {
226 return mBuffer[index];
static T toHash(const char *buffer, T base)
Computes the hash value for a given character buffer.
const char * c_str() const
void set(const char *ptr, size_t size)
bool operator==(const TStringBase< T > &rhs) const
Compare operator.
static void copyFrom(TStringBase< char > &base, const char *pPtr, size_t size)
bool operator!=(const TStringBase< T > &rhs) const
Not equal operator.
TStringBase< T > & operator+=(const TStringBase< T > &rhs)
~TStringBase()
The class destructor.
TStringBase() noexcept=default
The default class constructor.
T operator[](size_t index) const