mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-03-01 07:53:52 -05:00
64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
#ifndef CHUNK_H
|
|
#define CHUNK_H
|
|
|
|
#include <fstream>
|
|
#include <memory>
|
|
|
|
#include "data/data.h"
|
|
#include "types.h"
|
|
|
|
class Chunk
|
|
{
|
|
public:
|
|
enum Type
|
|
{
|
|
RIFF = 0x46464952,
|
|
LIST = 0x5453494c,
|
|
MxSt = 0x7453784d
|
|
};
|
|
|
|
Chunk();
|
|
virtual ~Chunk();
|
|
|
|
bool Read(const std::string &f);
|
|
bool Read(const char *f);
|
|
bool Read(std::ifstream &f);
|
|
void Clear();
|
|
|
|
typedef std::vector<Chunk*> Children;
|
|
|
|
Chunk *GetParent() const { return parent_; }
|
|
const Children &GetChildren() const { return children_; }
|
|
void AppendChild(Chunk *chunk);
|
|
bool RemoveChild(Chunk *chunk);
|
|
size_t IndexOfChild(Chunk *chunk);
|
|
void InsertChild(size_t index, Chunk *chunk);
|
|
Chunk *RemoveChild(size_t index);
|
|
Chunk *GetChildAt(size_t index) const { return children_.at(index); }
|
|
size_t GetChildCount() const { return children_.size(); }
|
|
|
|
Type type() const { return static_cast<Type>(id_); }
|
|
const u32 &id() const { return id_; }
|
|
|
|
static Data *CreateDataFromID(u32 id);
|
|
|
|
static const char *GetTypeDescription(Type type);
|
|
const char *GetTypeDescription() const
|
|
{
|
|
return GetTypeDescription(type());
|
|
}
|
|
|
|
private:
|
|
// Disable copy
|
|
Chunk(const Chunk& other);
|
|
Chunk& operator=(const Chunk& other);
|
|
|
|
u32 id_;
|
|
Data *data_;
|
|
|
|
Chunk *parent_;
|
|
Children children_;
|
|
|
|
};
|
|
|
|
#endif // CHUNK_H
|