123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include <iostream>
- #include <cstring>
- #include "String.h"
- #include "Types.h"
- String::String() : length(0) {
- data[0] = '\0';
- }
- String::operator const char*() const {
- return data;
- }
- String& String::append(char c) {
- if(length + 1 < LENGTH) {
- data[length++] = c;
- data[length] = '\0';
- }
- return *this;
- }
- String& String::append(const char* str) {
- for(uint i = 0; length + 1 < LENGTH && str[i] != '\0'; length++, i++) {
- data[length] = str[i];
- }
- data[length] = '\0';
- return *this;
- }
- uint String::getLength() const {
- return length;
- }
- void String::clear() {
- length = 0;
- data[0] = '\0';
- }
- bool String::operator==(const char* str) const {
- return strcmp(data, str) == 0;
- }
|