From 3ac57795fe8e28915523de6dd95e336a3eaa8064 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 7 Jun 2008 06:15:07 +0000 Subject: This seems to have done the trick, on the 32 bit platform, anyway. Turns out it's a bad idea to rely on the intNN_t typedefs. I enumerated all non-pointer primitives in c++ (except void, you can't store things in a void), and it works great. I also discovered C and C++ actually have unsigned char, signed char, and char, which are all distinct types. It supports all three now. In addition, I got rid of all of the specific && operators, the general one covers it all. Also, the unit tests all pass for now. Now to try it on the 64bit system. --- src/archive.cpp | 133 +++++++++++++++++++++++++++++++++++++++++++++++++-- src/archive.h | 28 +++++++++++ src/unit/archive.cpp | 2 +- 3 files changed, 157 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/archive.cpp b/src/archive.cpp index d6ad18d..accdeb1 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -45,6 +45,129 @@ bool Bu::Archive::isLoading() { return bLoading; } + +Bu::Archive &Bu::Archive::operator<<(bool p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(char p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(signed char p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(unsigned char p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(signed short p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(unsigned short p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(signed int p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(unsigned int p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(signed long p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(unsigned long p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(signed long long p) +{ + write( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator<<(unsigned long long p) +{ + write( &p, sizeof(p) ); + return *this; +} + +Bu::Archive &Bu::Archive::operator>>(bool &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(char &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(signed char &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(unsigned char &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(signed short &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(unsigned short &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(signed int &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(unsigned int &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(signed long &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(unsigned long &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(signed long long &p) +{ + read( &p, sizeof(p) ); + return *this; +} +Bu::Archive &Bu::Archive::operator>>(unsigned long long &p) +{ + read( &p, sizeof(p) ); + return *this; +} +/* Bu::Archive &Bu::Archive::operator<<(bool p) { write( &p, sizeof(p) ); @@ -89,12 +212,12 @@ Bu::Archive &Bu::Archive::operator<<(uint64_t p) { write( &p, sizeof(p) ); return *this; -}/* +} Bu::Archive &Bu::Archive::operator<<(long p) { write( &p, sizeof(p) ); return *this; -}*/ +} Bu::Archive &Bu::Archive::operator<<(float p) { write( &p, sizeof(p) ); @@ -155,12 +278,12 @@ Bu::Archive &Bu::Archive::operator>>(uint64_t &p) { read( &p, sizeof(p) ); return *this; -}/* +} Bu::Archive &Bu::Archive::operator>>(long &p) { read( &p, sizeof(p) ); return *this; -}*/ +} Bu::Archive &Bu::Archive::operator>>(float &p) { read( &p, sizeof(p) ); @@ -320,7 +443,7 @@ Bu::Archive &Bu::Archive::operator&&(long double &p) return *this << p; } } - +*/ Bu::Archive &Bu::operator<<(Bu::Archive &s, Bu::Archival &p) { diff --git a/src/archive.h b/src/archive.h index 31683bb..95c8c0c 100644 --- a/src/archive.h +++ b/src/archive.h @@ -88,6 +88,33 @@ namespace Bu virtual void write(const void *, int32_t); virtual void read(void *, int32_t); + virtual Archive &operator<<(bool p); + virtual Archive &operator<<(char p); + virtual Archive &operator<<(signed char p); + virtual Archive &operator<<(unsigned char p); + virtual Archive &operator<<(signed short p); + virtual Archive &operator<<(unsigned short p); + virtual Archive &operator<<(signed int p); + virtual Archive &operator<<(unsigned int p); + virtual Archive &operator<<(signed long p); + virtual Archive &operator<<(unsigned long p); + virtual Archive &operator<<(signed long long p); + virtual Archive &operator<<(unsigned long long p); + + virtual Archive &operator>>(bool &p); + virtual Archive &operator>>(char &p); + virtual Archive &operator>>(signed char &p); + virtual Archive &operator>>(unsigned char &p); + virtual Archive &operator>>(signed short &p); + virtual Archive &operator>>(unsigned short &p); + virtual Archive &operator>>(signed int &p); + virtual Archive &operator>>(unsigned int &p); + virtual Archive &operator>>(signed long &p); + virtual Archive &operator>>(unsigned long &p); + virtual Archive &operator>>(signed long long &p); + virtual Archive &operator>>(unsigned long long &p); + + /* virtual Archive &operator<<(bool); virtual Archive &operator<<(int8_t); virtual Archive &operator<<(int16_t); @@ -128,6 +155,7 @@ namespace Bu virtual Archive &operator&&(float &); virtual Archive &operator&&(double &); virtual Archive &operator&&(long double &); + */ /** * For storage, get an ID for the pointer to the object you're going to diff --git a/src/unit/archive.cpp b/src/unit/archive.cpp index 61e3567..531ece1 100644 --- a/src/unit/archive.cpp +++ b/src/unit/archive.cpp @@ -57,7 +57,7 @@ public: uint32_t p6; int64_t p7; uint64_t p8; - signed char p9; + char p9; unsigned char p10; short p11; unsigned short p12; -- cgit v1.2.3