summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2006-05-13 00:19:58 +0000
committerDavid <david@xagasoft.com>2006-05-13 00:19:58 +0000
commit632e1d1dbe6ac35eba93523dd144129af1122ca2 (patch)
tree22f5ea2a8577c4e0a8d8e3febae9b05a8e744e37
parentde1aa6d66e11232edf2d7bbc729425003f6c3db5 (diff)
downloadlibbu++-632e1d1dbe6ac35eba93523dd144129af1122ca2.tar.gz
libbu++-632e1d1dbe6ac35eba93523dd144129af1122ca2.tar.bz2
libbu++-632e1d1dbe6ac35eba93523dd144129af1122ca2.tar.xz
libbu++-632e1d1dbe6ac35eba93523dd144129af1122ca2.zip
david - umm... yeah, made the generic write and read functions...
-rw-r--r--src/serializer.h3
-rw-r--r--src/serializerbinary.cpp10
-rw-r--r--src/serializerbinary.h3
3 files changed, 16 insertions, 0 deletions
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:
15 virtual ~Serializer(); 15 virtual ~Serializer();
16 virtual void close()=0; 16 virtual void close()=0;
17 17
18 virtual void write(void *, int32_t)=0;
19 virtual void read(void *, int32_t)=0;
20
18 virtual Serializer &operator<<(bool)=0; 21 virtual Serializer &operator<<(bool)=0;
19 virtual Serializer &operator<<(int8_t)=0; 22 virtual Serializer &operator<<(int8_t)=0;
20 virtual Serializer &operator<<(int16_t)=0; 23 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()
35 } 35 }
36} 36}
37 37
38void SerializerBinary::write(void * pData, int32_t nSize)
39{
40 fwrite(pData, nSize, 1, fhFile);
41}
42
43void SerializerBinary::read(void * pData, int32_t nSize)
44{
45 fread(pData, nSize, 1, fhFile);
46}
47
38Serializer &SerializerBinary::operator<<(bool p) 48Serializer &SerializerBinary::operator<<(bool p)
39{ 49{
40 fwrite(&p, sizeof(p), 1, fhFile); 50 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:
13 13
14 virtual void close(); 14 virtual void close();
15 15
16 virtual void write(void *, int32_t);
17 virtual void read(void *, int32_t);
18
16 virtual Serializer &operator<<(bool); 19 virtual Serializer &operator<<(bool);
17 virtual Serializer &operator<<(int8_t); 20 virtual Serializer &operator<<(int8_t);
18 virtual Serializer &operator<<(int16_t); 21 virtual Serializer &operator<<(int16_t);