class std.StringBuilder

import "std_String.jnc"

class StringBuilder {
    // fields

    char readonly* readonly m_p;
    size_t readonly m_length;
    size_t readonly m_bufferSize;

    // properties

    string_t const property m_string;
    char const* const property m_sz;

    // methods

    void clear();
    bool errorcode reserve(size_t length);
    size_t errorcode copy(string_t string);

    size_t errorcode copy(
        utf16_t const* p,
        size_t length = -1
    );

    size_t errorcode copy(
        utf32_t c,
        size_t count = 1
    );

    size_t errorcode copy(
        char const* p,
        size_t length
    );

    size_t errorcode append(string_t string);

    size_t errorcode append(
        utf16_t const* p,
        size_t length = -1
    );

    size_t errorcode append(
        utf32_t c,
        size_t count = 1
    );

    size_t errorcode append(
        char const* p,
        size_t length
    );

    size_t errorcode insert(
        size_t offset,
        string_t string
    );

    size_t errorcode insert(
        size_t offset,
        utf16_t const* p,
        size_t length
    );

    size_t errorcode insert(
        size_t offset,
        utf32_t c,
        size_t count = 1
    );

    size_t errorcode insert(
        size_t offset,
        char const* p,
        size_t length
    );

    size_t remove(
        size_t offset,
        size_t length = 1
    );

    size_t chop(size_t length = 1);
    size_t trimLeft();
    size_t trimRight();
    size_t trim();
    string_t detachString();
    string_t errorcode cloneString();
};