1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #ifndef STRING_H
- #define STRING_H
- #include "common/utils/Types.h"
- class String final {
- public:
- String();
- String(const char* str);
- bool operator==(const String& other) const;
- bool operator!=(const String& other) const;
- operator const char*() const;
- char operator[](uint index) const;
- uint getLength() const;
- template<typename T>
- String& append(const char* format, const T& t) {
- uint left = MAX_LENGTH - length;
- uint written = snprintf(data + length, left, format, t);
- if(written < left) {
- length += written;
- } else {
- length = MAX_LENGTH;
- }
- return *this;
- }
- String& append(char c);
- String& append(const char* str);
- String& append(uint i);
- String& append(int i);
- String& append(float f);
- String& append(bool b);
-
- String& clear();
-
- static constexpr uint MAX_LENGTH = 255;
- private:
- char data[MAX_LENGTH];
- u8 length;
- };
- #endif
|