1234567891011121314151617181920212223242526 |
- #include <cstring>
- #include "common/utils/String.h"
- String::String() : length(0) {
- data[0] = '\0';
- }
- String::String(const char* str) : length(0) {
- for(; length < BUFFER_LENGTH - 1 && str[length] != '\0'; length++) {
- data[length] = str[length];
- }
- data[length] = '\0';
- }
- bool String::operator==(const String& other) const {
- return length == other.length && strcmp(data, other.data) == 0;
- }
- bool String::operator!=(const String& other) const {
- return !(*this == other);
- }
- String::operator const char*() const {
- return data;
- }
|