#include
#include
#include
#include
#include "base/FourCC.hpp"
namespace dmtools::dmbmx {
/// A input stream that reads a ZIFF stream and posts chunks.
struct ZiffInputStream {
/// A ZIFF chunk.
struct Chunk {
ZiffChunkHeader chunkHeader;
std::vector chunkData;
/// Casts the data to some other type.
template
T* As() {
return std::bit_cast(chunkData.data());
}
};
using ChunkCallback = std::function;
explicit ZiffInputStream(io::Stream& stream, FourCCT expectedFormCkId);
void SetChunkCallback(ChunkCallback&& chunkCallback);
void Process();
void Rewind();
private:
bool NextChunkImpl(bool isForm);
io::Stream& stream;
FourCCT expectedFormCkId {};
Chunk currentChunk {};
ChunkCallback callback {};
};
} // namespace dmtools::dmbmx