| 1 |
|
| 2 |
|
| 3 |
#ifndef ZTERP_BLORB_H |
| 4 |
#define ZTERP_BLORB_H |
| 5 |
|
| 6 |
#include <exception> |
| 7 |
#include <map> |
| 8 |
#include <memory> |
| 9 |
#include <utility> |
| 10 |
|
| 11 |
#include "iff.h" |
| 12 |
#include "io.h" |
| 13 |
#include "types.h" |
| 14 |
|
| 15 |
class Blorb { |
| 16 |
public: |
| 17 |
class InvalidFile : public std::exception { |
| 18 |
}; |
| 19 |
|
| 20 |
enum class Usage { |
| 21 |
Pict, |
| 22 |
Snd, |
| 23 |
Exec, |
| 24 |
Data, |
| 25 |
}; |
| 26 |
|
| 27 |
struct Chunk { |
| 28 |
Chunk(IFF::TypeID type_, uint32_t offset_, uint32_t size_) : |
| 29 |
type(type_), offset(offset_), size(size_) |
| 30 |
{ |
| 31 |
} |
| 32 |
|
| 33 |
const IFF::TypeID type; |
| 34 |
const uint32_t offset; |
| 35 |
const uint32_t size; |
| 36 |
}; |
| 37 |
|
| 38 |
explicit Blorb(const std::shared_ptr<IO> &io); |
| 39 |
const Chunk *find(Usage usage, uint32_t number); |
| 40 |
|
| 41 |
private: |
| 42 |
std::map<std::pair<Usage, uint32_t>, Chunk> m_chunks; |
| 43 |
}; |
| 44 |
|
| 45 |
#endif |