2023-07-07 12:20:51 -04:00
|
|
|
#ifndef LEGOSTREAM_H
|
|
|
|
#define LEGOSTREAM_H
|
|
|
|
|
2023-07-12 17:12:03 -04:00
|
|
|
#include "compat.h"
|
2023-07-07 12:20:51 -04:00
|
|
|
#include "decomp.h"
|
2023-10-17 18:05:31 -04:00
|
|
|
#include "mxstring.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxtypes.h"
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-12-15 17:09:34 -05:00
|
|
|
#pragma warning(disable : 4237)
|
2023-07-07 12:20:51 -04:00
|
|
|
#include <iosfwd>
|
|
|
|
|
|
|
|
#define LEGOSTREAM_MODE_READ 1
|
|
|
|
#define LEGOSTREAM_MODE_WRITE 2
|
|
|
|
|
2023-10-12 12:18:24 -04:00
|
|
|
class MxVariableTable;
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100d7d80
|
2023-10-24 19:38:27 -04:00
|
|
|
class LegoStream {
|
2023-07-07 12:20:51 -04:00
|
|
|
public:
|
2023-10-24 19:38:27 -04:00
|
|
|
LegoStream() : m_mode(0) {}
|
2024-01-14 16:28:46 -05:00
|
|
|
// FUNCTION: LEGO1 0x10045ad0
|
|
|
|
inline virtual ~LegoStream() {}
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual MxResult Read(void* p_buffer, MxU32 p_size) = 0;
|
|
|
|
virtual MxResult Write(const void* p_buffer, MxU32 p_size) = 0;
|
|
|
|
virtual MxResult Tell(MxU32* p_offset) = 0;
|
|
|
|
virtual MxResult Seek(MxU32 p_offset) = 0;
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
virtual MxBool IsWriteMode();
|
|
|
|
virtual MxBool IsReadMode();
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
enum OpenFlags {
|
2024-01-17 11:53:53 -05:00
|
|
|
c_readBit = 1,
|
|
|
|
c_writeBit = 2,
|
|
|
|
c_binaryBit = 4,
|
2023-10-24 19:38:27 -04:00
|
|
|
};
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
static MxResult __stdcall WriteVariable(LegoStream* p_stream, MxVariableTable* p_from, const char* p_variableName);
|
|
|
|
static MxS32 __stdcall ReadVariable(LegoStream* p_stream, MxVariableTable* p_to);
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2023-07-07 12:20:51 -04:00
|
|
|
protected:
|
2023-10-24 19:38:27 -04:00
|
|
|
MxU8 m_mode;
|
2023-07-07 12:20:51 -04:00
|
|
|
};
|
|
|
|
|
2024-01-14 16:28:46 -05:00
|
|
|
// SYNTHETIC: LEGO1 0x10045b00
|
|
|
|
// LegoStream::`scalar deleting destructor'
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100db730
|
2023-10-24 19:38:27 -04:00
|
|
|
class LegoFileStream : public LegoStream {
|
2023-07-07 12:20:51 -04:00
|
|
|
public:
|
2023-10-24 19:38:27 -04:00
|
|
|
LegoFileStream();
|
2024-01-14 16:28:46 -05:00
|
|
|
virtual ~LegoFileStream() override;
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult Read(void* p_buffer, MxU32 p_size) override;
|
|
|
|
MxResult Write(const void* p_buffer, MxU32 p_size) override;
|
|
|
|
MxResult Tell(MxU32* p_offset) override;
|
|
|
|
MxResult Seek(MxU32 p_offset) override;
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult Open(const char* p_filename, OpenFlags p_mode);
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
LegoFileStream* FUN_10006030(MxString p_str);
|
2023-10-17 18:05:31 -04:00
|
|
|
|
2023-07-07 12:20:51 -04:00
|
|
|
private:
|
2023-10-24 19:38:27 -04:00
|
|
|
FILE* m_hFile;
|
2023-07-07 12:20:51 -04:00
|
|
|
};
|
|
|
|
|
2024-01-14 16:28:46 -05:00
|
|
|
// SYNTHETIC: LEGO1 0x10099230
|
|
|
|
// LegoFileStream::`scalar deleting destructor'
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// VTABLE: LEGO1 0x100db710
|
2023-10-24 19:38:27 -04:00
|
|
|
class LegoMemoryStream : public LegoStream {
|
2023-07-07 12:20:51 -04:00
|
|
|
public:
|
2023-10-24 19:38:27 -04:00
|
|
|
LegoMemoryStream(char* p_buffer);
|
2023-07-07 12:20:51 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult Read(void* p_buffer, MxU32 p_size) override;
|
|
|
|
MxResult Write(const void* p_buffer, MxU32 p_size) override;
|
|
|
|
MxResult Tell(MxU32* p_offset) override;
|
|
|
|
MxResult Seek(MxU32 p_offset) override;
|
2023-07-07 12:20:51 -04:00
|
|
|
|
|
|
|
private:
|
2023-10-24 19:38:27 -04:00
|
|
|
char* m_buffer;
|
|
|
|
MxU32 m_offset;
|
2023-07-07 12:20:51 -04:00
|
|
|
};
|
|
|
|
|
2024-01-14 16:28:46 -05:00
|
|
|
// SYNTHETIC: LEGO1 0x10045a80
|
|
|
|
// LegoMemoryStream::~LegoMemoryStream
|
|
|
|
|
|
|
|
// SYNTHETIC: LEGO1 0x100990f0
|
|
|
|
// LegoMemoryStream::`scalar deleting destructor'
|
|
|
|
|
2023-07-12 17:12:03 -04:00
|
|
|
#endif // LEGOSTREAM_H
|