summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-06-07 06:15:07 +0000
committerMike Buland <eichlan@xagasoft.com>2008-06-07 06:15:07 +0000
commit3ac57795fe8e28915523de6dd95e336a3eaa8064 (patch)
tree5e06f65c451bdef412968c6631bcccfe2b15b2a3 /src
parent555ba77568b6faf18ebaed06cd08615deab2d8e3 (diff)
downloadlibbu++-3ac57795fe8e28915523de6dd95e336a3eaa8064.tar.gz
libbu++-3ac57795fe8e28915523de6dd95e336a3eaa8064.tar.bz2
libbu++-3ac57795fe8e28915523de6dd95e336a3eaa8064.tar.xz
libbu++-3ac57795fe8e28915523de6dd95e336a3eaa8064.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/archive.cpp133
-rw-r--r--src/archive.h28
-rw-r--r--src/unit/archive.cpp2
3 files changed, 157 insertions, 6 deletions
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()
45{ 45{
46 return bLoading; 46 return bLoading;
47} 47}
48
49Bu::Archive &Bu::Archive::operator<<(bool p)
50{
51 write( &p, sizeof(p) );
52 return *this;
53}
54Bu::Archive &Bu::Archive::operator<<(char p)
55{
56 write( &p, sizeof(p) );
57 return *this;
58}
59Bu::Archive &Bu::Archive::operator<<(signed char p)
60{
61 write( &p, sizeof(p) );
62 return *this;
63}
64Bu::Archive &Bu::Archive::operator<<(unsigned char p)
65{
66 write( &p, sizeof(p) );
67 return *this;
68}
69Bu::Archive &Bu::Archive::operator<<(signed short p)
70{
71 write( &p, sizeof(p) );
72 return *this;
73}
74Bu::Archive &Bu::Archive::operator<<(unsigned short p)
75{
76 write( &p, sizeof(p) );
77 return *this;
78}
79Bu::Archive &Bu::Archive::operator<<(signed int p)
80{
81 write( &p, sizeof(p) );
82 return *this;
83}
84Bu::Archive &Bu::Archive::operator<<(unsigned int p)
85{
86 write( &p, sizeof(p) );
87 return *this;
88}
89Bu::Archive &Bu::Archive::operator<<(signed long p)
90{
91 write( &p, sizeof(p) );
92 return *this;
93}
94Bu::Archive &Bu::Archive::operator<<(unsigned long p)
95{
96 write( &p, sizeof(p) );
97 return *this;
98}
99Bu::Archive &Bu::Archive::operator<<(signed long long p)
100{
101 write( &p, sizeof(p) );
102 return *this;
103}
104Bu::Archive &Bu::Archive::operator<<(unsigned long long p)
105{
106 write( &p, sizeof(p) );
107 return *this;
108}
109
110Bu::Archive &Bu::Archive::operator>>(bool &p)
111{
112 read( &p, sizeof(p) );
113 return *this;
114}
115Bu::Archive &Bu::Archive::operator>>(char &p)
116{
117 read( &p, sizeof(p) );
118 return *this;
119}
120Bu::Archive &Bu::Archive::operator>>(signed char &p)
121{
122 read( &p, sizeof(p) );
123 return *this;
124}
125Bu::Archive &Bu::Archive::operator>>(unsigned char &p)
126{
127 read( &p, sizeof(p) );
128 return *this;
129}
130Bu::Archive &Bu::Archive::operator>>(signed short &p)
131{
132 read( &p, sizeof(p) );
133 return *this;
134}
135Bu::Archive &Bu::Archive::operator>>(unsigned short &p)
136{
137 read( &p, sizeof(p) );
138 return *this;
139}
140Bu::Archive &Bu::Archive::operator>>(signed int &p)
141{
142 read( &p, sizeof(p) );
143 return *this;
144}
145Bu::Archive &Bu::Archive::operator>>(unsigned int &p)
146{
147 read( &p, sizeof(p) );
148 return *this;
149}
150Bu::Archive &Bu::Archive::operator>>(signed long &p)
151{
152 read( &p, sizeof(p) );
153 return *this;
154}
155Bu::Archive &Bu::Archive::operator>>(unsigned long &p)
156{
157 read( &p, sizeof(p) );
158 return *this;
159}
160Bu::Archive &Bu::Archive::operator>>(signed long long &p)
161{
162 read( &p, sizeof(p) );
163 return *this;
164}
165Bu::Archive &Bu::Archive::operator>>(unsigned long long &p)
166{
167 read( &p, sizeof(p) );
168 return *this;
169}
170/*
48Bu::Archive &Bu::Archive::operator<<(bool p) 171Bu::Archive &Bu::Archive::operator<<(bool p)
49{ 172{
50 write( &p, sizeof(p) ); 173 write( &p, sizeof(p) );
@@ -89,12 +212,12 @@ Bu::Archive &Bu::Archive::operator<<(uint64_t p)
89{ 212{
90 write( &p, sizeof(p) ); 213 write( &p, sizeof(p) );
91 return *this; 214 return *this;
92}/* 215}
93Bu::Archive &Bu::Archive::operator<<(long p) 216Bu::Archive &Bu::Archive::operator<<(long p)
94{ 217{
95 write( &p, sizeof(p) ); 218 write( &p, sizeof(p) );
96 return *this; 219 return *this;
97}*/ 220}
98Bu::Archive &Bu::Archive::operator<<(float p) 221Bu::Archive &Bu::Archive::operator<<(float p)
99{ 222{
100 write( &p, sizeof(p) ); 223 write( &p, sizeof(p) );
@@ -155,12 +278,12 @@ Bu::Archive &Bu::Archive::operator>>(uint64_t &p)
155{ 278{
156 read( &p, sizeof(p) ); 279 read( &p, sizeof(p) );
157 return *this; 280 return *this;
158}/* 281}
159Bu::Archive &Bu::Archive::operator>>(long &p) 282Bu::Archive &Bu::Archive::operator>>(long &p)
160{ 283{
161 read( &p, sizeof(p) ); 284 read( &p, sizeof(p) );
162 return *this; 285 return *this;
163}*/ 286}
164Bu::Archive &Bu::Archive::operator>>(float &p) 287Bu::Archive &Bu::Archive::operator>>(float &p)
165{ 288{
166 read( &p, sizeof(p) ); 289 read( &p, sizeof(p) );
@@ -320,7 +443,7 @@ Bu::Archive &Bu::Archive::operator&&(long double &p)
320 return *this << p; 443 return *this << p;
321 } 444 }
322} 445}
323 446*/
324 447
325Bu::Archive &Bu::operator<<(Bu::Archive &s, Bu::Archival &p) 448Bu::Archive &Bu::operator<<(Bu::Archive &s, Bu::Archival &p)
326{ 449{
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
88 virtual void write(const void *, int32_t); 88 virtual void write(const void *, int32_t);
89 virtual void read(void *, int32_t); 89 virtual void read(void *, int32_t);
90 90
91 virtual Archive &operator<<(bool p);
92 virtual Archive &operator<<(char p);
93 virtual Archive &operator<<(signed char p);
94 virtual Archive &operator<<(unsigned char p);
95 virtual Archive &operator<<(signed short p);
96 virtual Archive &operator<<(unsigned short p);
97 virtual Archive &operator<<(signed int p);
98 virtual Archive &operator<<(unsigned int p);
99 virtual Archive &operator<<(signed long p);
100 virtual Archive &operator<<(unsigned long p);
101 virtual Archive &operator<<(signed long long p);
102 virtual Archive &operator<<(unsigned long long p);
103
104 virtual Archive &operator>>(bool &p);
105 virtual Archive &operator>>(char &p);
106 virtual Archive &operator>>(signed char &p);
107 virtual Archive &operator>>(unsigned char &p);
108 virtual Archive &operator>>(signed short &p);
109 virtual Archive &operator>>(unsigned short &p);
110 virtual Archive &operator>>(signed int &p);
111 virtual Archive &operator>>(unsigned int &p);
112 virtual Archive &operator>>(signed long &p);
113 virtual Archive &operator>>(unsigned long &p);
114 virtual Archive &operator>>(signed long long &p);
115 virtual Archive &operator>>(unsigned long long &p);
116
117 /*
91 virtual Archive &operator<<(bool); 118 virtual Archive &operator<<(bool);
92 virtual Archive &operator<<(int8_t); 119 virtual Archive &operator<<(int8_t);
93 virtual Archive &operator<<(int16_t); 120 virtual Archive &operator<<(int16_t);
@@ -128,6 +155,7 @@ namespace Bu
128 virtual Archive &operator&&(float &); 155 virtual Archive &operator&&(float &);
129 virtual Archive &operator&&(double &); 156 virtual Archive &operator&&(double &);
130 virtual Archive &operator&&(long double &); 157 virtual Archive &operator&&(long double &);
158 */
131 159
132 /** 160 /**
133 * For storage, get an ID for the pointer to the object you're going to 161 * 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:
57 uint32_t p6; 57 uint32_t p6;
58 int64_t p7; 58 int64_t p7;
59 uint64_t p8; 59 uint64_t p8;
60 signed char p9; 60 char p9;
61 unsigned char p10; 61 unsigned char p10;
62 short p11; 62 short p11;
63 unsigned short p12; 63 unsigned short p12;