#pragma once #include #include #include namespace BAN { class String { public: using size_type = size_t; public: String(); String(const String&); String(String&&); String(const StringView&); String(const char*, size_type = -1); ~String(); String& operator=(const String&); String& operator=(String&&); ErrorOr PushBack(char); ErrorOr Insert(char, size_type); ErrorOr Append(const char*); ErrorOr Append(const String&); void PopBack(); void Remove(size_type); void Clear(); char operator[](size_type) const; char& operator[](size_type); bool operator==(const String&) const; bool operator==(StringView) const; bool operator==(const char*) const; ErrorOr Resize(size_type, char = '\0'); ErrorOr Reserve(size_type); StringView SV() const; bool Empty() const; size_type Size() const; size_type Capasity() const; const char* Data() const; private: ErrorOr EnsureCapasity(size_type); ErrorOr copy_impl(const char*, size_type); void move_impl(String&&); private: char* m_data = nullptr; size_type m_capasity = 0; size_type m_size = 0; }; } namespace BAN::Formatter { template void print_argument_impl(F putc, const String& string, const ValueFormat&) { for (String::size_type i = 0; i < string.Size(); i++) putc(string[i]); } }