class std.Buffer

import "std_Buffer.jnc"

class Buffer {
    // fields

    char cmut* readonly m_p;
    size_t readonly m_size;
    size_t readonly m_maxSize;

    // methods

    void clear();
    char* detach();
    bool errorcode setSize(size_t size);
    bool errorcode reserve(size_t size);

    size_t errorcode copy(
        void const* p,
        size_t size
    );

    size_t errorcode copy(string_t string);
    size_t errorcode copy(char c);

    size_t errorcode append(
        void const* p,
        size_t size
    );

    size_t errorcode append(string_t string);
    size_t errorcode append(char c);

    size_t errorcode insert(
        size_t offset,
        void const* p,
        size_t size
    );

    size_t errorcode insert(
        size_t offset,
        string_t string
    );

    size_t errorcode insert(
        size_t offset,
        char c
    );

    size_t errorcode remove(
        size_t offset,
        size_t size = 1
    );
};