Example #1
0
SimpleString& SimpleString::operator=(const SimpleString& other)
{
    if (this != &other) {
        deallocStringBuffer(buffer_, __FILE__, __LINE__);
        buffer_ = copyToNewBuffer(other.buffer_);
    }
    return *this;
}
Example #2
0
SimpleString::SimpleString(const char *otherBuffer)
{
    if (otherBuffer == 0) {
        buffer_ = getEmptyString();
    }
    else {
        buffer_ = copyToNewBuffer(otherBuffer);
    }
}
Example #3
0
SimpleString& SimpleString::operator+=(const char* rhs)
{
    size_t originalSize = this->size();
    size_t additionalStringSize = StrLen(rhs) + 1;
    size_t sizeOfNewString = originalSize + additionalStringSize;
    char* tbuffer = copyToNewBuffer(this->buffer_, sizeOfNewString);
    StrNCpy(tbuffer + originalSize, rhs, additionalStringSize);
    deallocStringBuffer(this->buffer_, __FILE__, __LINE__);
    this->buffer_ = tbuffer;
    return *this;
}
Example #4
0
void SimpleString::split(const SimpleString& delimiter, SimpleStringCollection& col) const
{
    size_t num = count(delimiter);
    size_t extraEndToken = (endsWith(delimiter)) ? 0 : 1U;
    col.allocate(num + extraEndToken);

    char* str = buffer_;
    char* prev;
    for (size_t i = 0; i < num; ++i) {
        prev = str;
        str = StrStr(str, delimiter.buffer_) + 1;
        size_t len = (size_t) (str - prev) + 1;
        col[i].buffer_ = copyToNewBuffer(prev, len);
    }
    if (extraEndToken) {
        col[num] = str;
    }
}
Example #5
0
SimpleString::SimpleString(const SimpleString& other)
{
    buffer_ = copyToNewBuffer(other.buffer_);
}