From 632e1d1dbe6ac35eba93523dd144129af1122ca2 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 13 May 2006 00:19:58 +0000 Subject: david - umm... yeah, made the generic write and read functions... --- src/serializer.h | 3 +++ src/serializerbinary.cpp | 10 ++++++++++ src/serializerbinary.h | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/serializer.h b/src/serializer.h index 03e6820..f2648e3 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -15,6 +15,9 @@ public: virtual ~Serializer(); virtual void close()=0; + virtual void write(void *, int32_t)=0; + virtual void read(void *, int32_t)=0; + virtual Serializer &operator<<(bool)=0; virtual Serializer &operator<<(int8_t)=0; virtual Serializer &operator<<(int16_t)=0; diff --git a/src/serializerbinary.cpp b/src/serializerbinary.cpp index 1ea9f36..53e469f 100644 --- a/src/serializerbinary.cpp +++ b/src/serializerbinary.cpp @@ -35,6 +35,16 @@ void SerializerBinary::close() } } +void SerializerBinary::write(void * pData, int32_t nSize) +{ + fwrite(pData, nSize, 1, fhFile); +} + +void SerializerBinary::read(void * pData, int32_t nSize) +{ + fread(pData, nSize, 1, fhFile); +} + Serializer &SerializerBinary::operator<<(bool p) { fwrite(&p, sizeof(p), 1, fhFile); diff --git a/src/serializerbinary.h b/src/serializerbinary.h index 4a2f301..7323d3b 100644 --- a/src/serializerbinary.h +++ b/src/serializerbinary.h @@ -13,6 +13,9 @@ public: virtual void close(); + virtual void write(void *, int32_t); + virtual void read(void *, int32_t); + virtual Serializer &operator<<(bool); virtual Serializer &operator<<(int8_t); virtual Serializer &operator<<(int16_t); -- cgit v1.2.3