49#ifndef DVD_CORE_BYTE_BUFFER_H_
50#define DVD_CORE_BYTE_BUFFER_H_
82 void clear() noexcept;
85 template<class T,
size_t N>
89 template<class T,
size_t N>
94 void put(
size_t pos, const T& value);
101 template <typename T>
105 template <typename U>
109 template <typename T>
113 void readSkip(
size_t skip) noexcept;
116 template <typename T>
120 template <typename T>
124 template <typename T>
144 template <typename T>
145 void append(const T* src, const
size_t cnt);
148 [[nodiscard]]
Byte operator[](
size_t pos) const;
151 [[nodiscard]]
size_t rpos() const noexcept;
154 [[nodiscard]]
size_t rpos(
size_t rpos_) noexcept;
156 [[nodiscard]]
size_t wpos() const noexcept;
158 [[nodiscard]]
size_t wpos(
size_t wpos_) noexcept;
160 [[nodiscard]]
size_t bufferSize() const noexcept;
169 void resize(
size_t newsize);
177 void put(
size_t pos, const
Byte *src,
size_t cnt);
188 template <typename T>
189 void append(const T& value);
void printPosError() const
size_t storageSize() const noexcept
Returns the total size (in bytes) of the underlying storage, regardles of wpos and rpos.
void readNoSkip(T &value)
Reads sizeof(T) data from the buffer and saves it into 'value' but does NOT move the read head forwar...
void readSkipToMarker(const T(&pattern)[N])
Skip (consume) everything in the buffer until we find the specified list of items....
U64 readPackGUID()
Reads a packed U64 from the buffer and returns it. Reading moves the read head forward!
const Byte * contents() const noexcept
Returns a raw pointer to the underlying storage data. Does NOT depend on the read head position!...
size_t rpos() const noexcept
Returns the current read head position.
void readNoSkipFrom(size_t pos, T &out) const
Reads sizeof(T) data from the buffer and returns it but does NOT move the read head forward!
void resize(size_t newsize)
Resizes the underlying storage to 'newsize' bytes and resets the read and write head positions.
void append(const Byte *src, size_t cnt)
Appends 'cnt' bytes from 'src' to the buffer.
static const U8 BUFFER_FORMAT_VERSION
void read(T &out)
Reads sizeof(T) data from the buffer and returns it. Reading moves the read head forward!
size_t wpos() const noexcept
Returns the current write head position.
bool loadFromFile(const ResourcePath &path, std::string_view fileName, const U8 version=BUFFER_FORMAT_VERSION)
void clear() noexcept
Resets the entire storage and the read and write positions.
bool storageEmpty() const noexcept
Returns true if the underlying storage is empty, regardless of wpos and rpos.
static const size_t DEFAULT_SIZE
void appendPackXYZ(F32 x, F32 y, F32 z)
Packes x,y and z into a single U32 and appends it to the buffer.
ByteBuffer() noexcept=default
void addMarker(const T(&pattern)[N])
Add a specific list of items in order to mark a special point in the buffer. Can be used for skipping...
size_t bufferSize() const noexcept
Returns the size (in bytes) of the data inside of the buffer (wpos - rpos)
void readSkip()
Moves the read head sizeof(T) units forward.
void put(size_t pos, const T &value)
Inserts 'value' at the specified position overriding any existing data at that location....
void appendPackGUID(U64 guid)
Packes guid into a multiple I32s and appends them to the buffer.
bool dumpToFile(const ResourcePath &path, std::string_view fileName, const U8 version=BUFFER_FORMAT_VERSION)
Saves the entire buffer contents to file. Always appends the version at the end of the file.
void reserve(size_t resize)
Reserves 'resize' bytes of additional storage in the underlying storage structure without changing th...
void readPackXYZ(F32 &x, F32 &y, F32 &z)
Reads a packed U32 from the buffer and unpackes it into x,y,z. Reading moves the read head forward!
bool bufferEmpty() const noexcept
Returns true if the read position and the write position are identical.
Handle console commands that start with a forward slash.
constexpr resolve_uac< A, B >::return_type add(const A &a, const B &b) noexcept
eastl::vector< Type > vector
Helper for using >> instead of readSkip()