Hello everybody!
I have made a simple fixed string class available at: FixedString/FixedString at master · MrAviator93/FixedString · GitHub
Feel free to use FixedString.h file for any purpose.
Class Interface:
CFixedString() noexcept;
CFixedString(const char* pString);
CFixedString(const int value);
explicit CFixedString(const int value, StrBaseEnum type);
explicit CFixedString(const char singleChar, uint32 numToRepeat) noexcept;
~CFixedString();
uint32 getSize() const { return m_stringSize; }
uint32 getLength() const { return m_stringSize; }
uint32 getReservedSize() const { return FS_MAX_CHAR_COUNT; }
const char* getData() { return m_fixedString; }
const char* data() { return m_fixedString; }
const char* buffer() const { return m_fixedString; }
//For Range-based for Statement
char* begin() { return &m_fixedString[0]; }
char* end() { return &m_fixedString[m_stringSize]; }
void lower();
void upper();
CFixedString& clear();
bool isEmpty();
bool isNumeric();
bool isHexDecimal();
bool isBinary();
bool startsWithNoCase(const char* pString);
bool startsWith(const char* pString);
bool endsWith(const char* pString);
bool contains(const char* pString);
int countNoOccurances(const char& ch);
int countNoOccurances(const char* pString);
CFixedString<FS_MAX_CHAR_COUNT> substr(uint32 pos, uint32 len);
bool append(const char ch);
bool append(const char* pString);
bool appendPrefix(const char* pString);
int compare(const char* pString);
int compareNoCase(const char* pString);
int find(char ch, uint32 startPos = 0);
int find(const char* pStrSub, uint32 startPos = 0);
int findLastOccurance(char ch);
int findLastOccurance(const char* pStrSub);
int reverseFind(char ch);
int findOneOf(const char* pStrCharSet, uint32 startPos = 0);
bool replace(uint32 pos, uint32 size, const char* pString);
void trimLeft(const int trimCutSet);
void trimRight(const int trimCutSet);
void trim(const int trimCutSet);
//Assignment operators "="
const CFixedString<FS_MAX_CHAR_COUNT>& operator=(char ch);
const CFixedString<FS_MAX_CHAR_COUNT>& operator=(const char* pString);
//Append operators "+="
const CFixedString<FS_MAX_CHAR_COUNT>& operator+=(char ch);
const CFixedString<FS_MAX_CHAR_COUNT>& operator+=(const char* pString);
// Access by reference.
char& operator[](int index);
// Access by copy.
char operator[](int index) const;
int asInt32() const;
uint32 asUint32() const;
int64 asInt64() const;
uint64 asUint64() const;
float asFloat() const;
double asDouble() const;
Usage is as follows:
Prefer numBytesOccupy to have a value of power of 2.
CFixedString<numBytesOccupy> myFixedString(provide args. for any of constructors);
Please provide any suggestions or mods that can be done on it.