#pragma once

#include <spider/runtime/common.hpp>

namespace spider {

    /**
     * A general purpose byte array
     * with RAII semantics.
     */
    class ByteArray {
    private:

        u8* _mem;
        isize _size;

    public:

        ByteArray(isize length);

        ByteArray(const ByteArray& other);

        ByteArray(ByteArray&& other) noexcept;

        ~ByteArray();

    public:

        ByteArray& operator=(const ByteArray& other);
        
        ByteArray& operator=(ByteArray&& other) noexcept;

    public:

        u8& operator[](isize index);

        u8 operator[](isize index) const;

    public:

        u8* data();

        const u8* data() const;

        isize size() const;

    };

}
