2022-07-11 00:16:20 -04:00
|
|
|
#ifndef INTERLEAF_H
|
|
|
|
#define INTERLEAF_H
|
|
|
|
|
2022-07-17 21:51:16 -04:00
|
|
|
#include <fstream>
|
|
|
|
|
2022-07-11 00:16:20 -04:00
|
|
|
#include "core.h"
|
2022-07-18 14:25:00 -04:00
|
|
|
#include "file.h"
|
2022-07-18 03:27:00 -04:00
|
|
|
#include "info.h"
|
2022-07-17 19:25:06 -04:00
|
|
|
#include "object.h"
|
2022-07-11 00:16:20 -04:00
|
|
|
|
|
|
|
namespace si {
|
|
|
|
|
|
|
|
class Interleaf : public Core
|
|
|
|
{
|
|
|
|
public:
|
2022-07-18 03:27:00 -04:00
|
|
|
enum Error
|
|
|
|
{
|
|
|
|
ERROR_SUCCESS,
|
|
|
|
ERROR_IO,
|
|
|
|
ERROR_INVALID_INPUT,
|
|
|
|
ERROR_INVALID_BUFFER_SIZE
|
|
|
|
};
|
|
|
|
|
2023-10-31 21:52:19 -04:00
|
|
|
enum Version
|
|
|
|
{
|
|
|
|
Version2_1 = 0x00010002,
|
|
|
|
Version2_2 = 0x00020002
|
|
|
|
};
|
|
|
|
|
2022-07-11 00:16:20 -04:00
|
|
|
LIBWEAVER_EXPORT Interleaf();
|
|
|
|
|
2022-07-17 21:51:16 -04:00
|
|
|
LIBWEAVER_EXPORT void Clear();
|
|
|
|
|
2022-07-18 03:27:00 -04:00
|
|
|
LIBWEAVER_EXPORT Error Read(const char *f);
|
|
|
|
LIBWEAVER_EXPORT Error Write(const char *f) const;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
LIBWEAVER_EXPORT Error Read(const wchar_t *f);
|
|
|
|
LIBWEAVER_EXPORT Error Write(const wchar_t *f) const;
|
|
|
|
#endif
|
|
|
|
|
2022-07-18 14:25:00 -04:00
|
|
|
Error Read(FileBase *is);
|
|
|
|
Error Write(FileBase *os) const;
|
2022-07-17 21:51:16 -04:00
|
|
|
|
2022-07-18 03:27:00 -04:00
|
|
|
Info *GetInformation() { return &m_Info; }
|
2022-07-11 00:16:20 -04:00
|
|
|
|
|
|
|
private:
|
2022-07-18 14:25:00 -04:00
|
|
|
Error ReadChunk(Core *parent, FileBase *f, Info *info);
|
2022-07-17 21:51:16 -04:00
|
|
|
|
2022-07-18 14:25:00 -04:00
|
|
|
Object *ReadObject(FileBase *f, Object *o, std::stringstream &desc);
|
|
|
|
void WriteObject(FileBase *f, const Object *o) const;
|
2022-07-17 21:51:16 -04:00
|
|
|
|
2022-07-18 14:25:00 -04:00
|
|
|
void InterleaveObjects(FileBase *f, const std::vector<Object*> &objects) const;
|
2022-07-18 03:27:00 -04:00
|
|
|
|
2022-07-18 14:25:00 -04:00
|
|
|
void WriteSubChunk(FileBase *f, uint16_t flags, uint32_t object, uint32_t time, const bytearray &data = bytearray()) const;
|
|
|
|
void WriteSubChunkInternal(FileBase *f, uint16_t flags, uint32_t object, uint32_t time, uint32_t data_sz, const bytearray &data) const;
|
2022-07-18 05:12:22 -04:00
|
|
|
|
2022-07-18 14:25:00 -04:00
|
|
|
void WritePadding(FileBase *f, uint32_t size) const;
|
2023-09-17 17:13:02 -04:00
|
|
|
void WritePaddingIfNecessary(FileBase *f, size_t projectedWrite) const;
|
2022-07-18 03:27:00 -04:00
|
|
|
|
|
|
|
Info m_Info;
|
2022-07-17 21:51:16 -04:00
|
|
|
|
|
|
|
uint32_t m_Version;
|
|
|
|
uint32_t m_BufferSize;
|
|
|
|
uint32_t m_BufferCount;
|
|
|
|
|
2022-07-18 03:27:00 -04:00
|
|
|
std::vector<uint32_t> m_ObjectList;
|
|
|
|
std::map<uint32_t, Object*> m_ObjectIDTable;
|
2022-07-11 00:16:20 -04:00
|
|
|
|
2022-07-18 05:12:22 -04:00
|
|
|
uint32_t m_JoiningProgress;
|
|
|
|
uint32_t m_JoiningSize;
|
|
|
|
|
2022-07-11 00:16:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INTERLEAF_H
|