aboutsummaryrefslogtreecommitdiff
path: root/src/common.hh
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-05-22 19:03:45 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-05-22 19:03:45 -0300
commit4e41f79a50b18b4e9b9fa00bbfa68ecb15fcb63e (patch)
tree7ca2a0f7c3977ba4e2e530a599fc5332a0ae9712 /src/common.hh
parentc595a2c2935b5bfcb2c08cc9ec4a22db55bd1ff7 (diff)
downloadgame-4e41f79a50b18b4e9b9fa00bbfa68ecb15fcb63e.tar.gz
game-4e41f79a50b18b4e9b9fa00bbfa68ecb15fcb63e.zip
implement TWriteStream, T(Dynamic)WriteBuffer, and TWriteBinaryFile
Diffstat (limited to 'src/common.hh')
-rw-r--r--src/common.hh50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/common.hh b/src/common.hh
index 204cf2a..124dd84 100644
--- a/src/common.hh
+++ b/src/common.hh
@@ -166,9 +166,59 @@ struct TReadBuffer: TReadStream {
// DATA
// =========================================================================
+ const uint8 *Data;
+ int Size;
+ int Position;
+};
+
+struct TWriteStream {
+ // VIRTUAL FUNCTIONS
+ // =========================================================================
+ virtual void writeFlag(bool Flag); // VTABLE[0]
+ virtual void writeByte(uint8 Byte) = 0; // VTABLE[1]
+ virtual void writeWord(uint16 Word); // VTABLE[2]
+ virtual void writeQuad(uint16 Quad); // VTABLE[3]
+ virtual void writeString(const char *String); // VTABLE[4]
+ virtual void writeBytes(const uint8 *Buffer, int Count); // VTABLE[5]
+};
+
+struct TWriteBuffer: TWriteStream {
+ // REGULAR FUNCTIONS
+ // =========================================================================
+ TWriteBuffer(uint8 *Data, int Size);
+
+ // VIRTUAL FUNCTIONS
+ // =========================================================================
+ void writeByte(uint8 Byte) override;
+ void writeWord(uint16 Word) override;
+ void writeQuad(uint32 Quad) override;
+ void writeBytes(uint8 *Buffer, int Count) override;
+
+ // DATA
+ // =========================================================================
uint8 *Data;
int Size;
int Position;
};
+struct TDynamicWriteBuffer: TWriteBuffer {
+ // REGULAR FUNCTIONS
+ // =========================================================================
+ TDynamicWriteBuffer(int InitialSize);
+ void resizeBuffer(void);
+
+ // VIRTUAL FUNCTIONS
+ // =========================================================================
+ void writeByte(uint8 Byte) override;
+ void writeWord(uint16 Word) override;
+ void writeQuad(uint32 Quad) override;
+ void writeBytes(uint8 *Buffer, int Count) override;
+
+ // TODO(fusion): Appended virtual functions. These are not in the base class
+ // VTABLE which can be problematic if we intend to use polymorphism, although
+ // that doesn't seem to be case.
+ virtual ~TDynamicWriteBuffer(void); // VTABLE[6]
+ // Duplicate destructor that also calls operator delete. // VTABLE[7]
+};
+
#endif //TIBIA_COMMON_HH_