diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/serializerbinary.cpp | |
parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/serializerbinary.cpp')
-rw-r--r-- | src/serializerbinary.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/serializerbinary.cpp b/src/serializerbinary.cpp deleted file mode 100644 index ea7ed93..0000000 --- a/src/serializerbinary.cpp +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | #include "serializerbinary.h" | ||
2 | #include "serializable.h" | ||
3 | #include "exceptions.h" | ||
4 | |||
5 | SerializerBinary::SerializerBinary(FILE *fhFile, bool bLoading): | ||
6 | Serializer(bLoading), | ||
7 | fhFile(fhFile), | ||
8 | bCloseFile(false) | ||
9 | { | ||
10 | } | ||
11 | |||
12 | SerializerBinary::SerializerBinary(const char *sFileName, bool bLoading): | ||
13 | Serializer(bLoading), | ||
14 | bCloseFile(true) | ||
15 | { | ||
16 | if (bLoading) | ||
17 | { | ||
18 | fhFile = fopen(sFileName, "rb"); | ||
19 | if( fhFile == NULL ) | ||
20 | throw FileException("Unable to open file: %s", sFileName ); | ||
21 | } | ||
22 | else | ||
23 | { | ||
24 | fhFile = fopen(sFileName, "wb"); | ||
25 | if( fhFile == NULL ) | ||
26 | throw FileException("Unable to open file: %s", sFileName ); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | SerializerBinary::~SerializerBinary() | ||
31 | { | ||
32 | close(); | ||
33 | } | ||
34 | |||
35 | void SerializerBinary::close() | ||
36 | { | ||
37 | if (fhFile != NULL && bCloseFile ) | ||
38 | { | ||
39 | fclose(fhFile); | ||
40 | fhFile = NULL; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | void SerializerBinary::write(const void * pData, int32_t nSize) | ||
45 | { | ||
46 | if( nSize == 0 ) | ||
47 | return; | ||
48 | |||
49 | fwrite(pData, nSize, 1, fhFile); | ||
50 | } | ||
51 | |||
52 | void SerializerBinary::read(void * pData, int32_t nSize) | ||
53 | { | ||
54 | if( nSize == 0 ) | ||
55 | return; | ||
56 | |||
57 | uint32_t nRead = fread(pData, nSize, 1, fhFile); | ||
58 | if( nRead < 1 ) | ||
59 | { | ||
60 | throw FileException( excodeEOF, "End of file read"); | ||
61 | } | ||
62 | } | ||
63 | |||