mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-10-28 21:55:41 +00:00
* Inspired by how IW4x identifies x64 zones Co-authored-by: William Roy <[email protected]>
28 lines
537 B
C++
28 lines
537 B
C++
#pragma once
|
|
|
|
#include <cstring>
|
|
#include <functional>
|
|
#include <istream>
|
|
#include <vector>
|
|
|
|
class ZoneDataPeeking
|
|
{
|
|
public:
|
|
explicit ZoneDataPeeking(std::istream& stream);
|
|
|
|
template<typename T> const T& PeekStruct()
|
|
{
|
|
EnsureHasEnoughData(sizeof(T));
|
|
|
|
return *reinterpret_cast<const T*>(m_data.data());
|
|
}
|
|
|
|
void PeekWithStream(const std::function<void(std::istream& stream)>& cb) const;
|
|
|
|
private:
|
|
void EnsureHasEnoughData(size_t size);
|
|
|
|
std::istream& m_stream;
|
|
std::vector<char> m_data;
|
|
};
|