--- nono/lib/memorystream.h 2026/04/29 17:04:37 1.1.1.3 +++ nono/lib/memorystream.h 2026/04/29 17:05:08 1.1.1.4 @@ -4,6 +4,10 @@ // Licensed under nono-license.txt // +// +// メモリストリーム +// + #pragma once #include "header.h" @@ -17,19 +21,34 @@ class MemoryStreamBE // コンストラクタ MemoryStreamBE() { } - MemoryStreamBE(void *p) { - SetPtr(p); + MemoryStreamBE(void *start_) { + Init(start_); } // デストラクタ不要 - // ポインタを設定する - void SetPtr(void *p) { - ptr = (uint8 *)p; + // 開始ポインタを設定する + // 現在のポインタ位置は開始ポインタ位置になる + void Init(void *start_) { + start = (uint8 *)start_; + ptr = start; + } + + // 開始ポインタを取得する + void *GetStartPtr() const + { + return (void *)start; + } + + // バイトオフセットを設定する + void SetOffset(uint32 ofs) + { + ptr = start + ofs; } - // ポインタを取得する - void *GetPtr() const { - return (void *)ptr; + // 現在のバイトオフセットを取得する + uint32 GetOffset() const + { + return (uint32)(ptr - start); } // 1バイト読み込んでポインタを進める @@ -69,4 +88,5 @@ class MemoryStreamBE private: uint8 *ptr {}; + uint8 *start {}; };