#include #include "utils/String.h" String::String() : String("") { } String::String(const char* str) : usedCapacity(1) { *this += str; } String& String::operator+=(const char* str) { usedCapacity--; size_t start = usedCapacity; while(usedCapacity + 1 < capacity && str[usedCapacity - start] != '\0') { path[usedCapacity] = str[usedCapacity - start]; usedCapacity++; } path[usedCapacity++] = '\0'; return *this; } String& String::operator+=(char c) { if(usedCapacity + 1 < capacity) { path[usedCapacity - 1] = c; path[usedCapacity] = '\0'; usedCapacity++; } return *this; } String& String::operator+=(unsigned int i) { usedCapacity += snprintf(path + usedCapacity - 1, capacity - usedCapacity, "%u", i); return *this; } String& String::operator+=(double d) { usedCapacity += snprintf(path + usedCapacity - 1, capacity - usedCapacity, (d == (long) d) ? "%lg.0" : "%lg", d); return *this; } String String::operator+(const char* str) const { String s(this->path); s += str; return s; } String::operator const char*() const { return path; }