diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-10 17:37:46 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-10 17:37:46 +0000 |
commit | e7ab7cb1604c04763bbdcece5885e6ce5aa100b4 (patch) | |
tree | db5bee7da9373f64508e243f24031bc35b1acee7 | |
parent | 903e7a1e3d4fe99e9de7f4adc1e401ba871caec9 (diff) | |
download | libbu++-e7ab7cb1604c04763bbdcece5885e6ce5aa100b4.tar.gz libbu++-e7ab7cb1604c04763bbdcece5885e6ce5aa100b4.tar.bz2 libbu++-e7ab7cb1604c04763bbdcece5885e6ce5aa100b4.tar.xz libbu++-e7ab7cb1604c04763bbdcece5885e6ce5aa100b4.zip |
Fixed a warning in the SFile test, and added std::list support to the archive.
I guess I should write a test for it too...
I'm also thinking of removing the S from the front of the stream children.
-rw-r--r-- | src/archive.cpp | 13 | ||||
-rw-r--r-- | src/archive.h | 29 | ||||
-rw-r--r-- | src/unit/sfile.cpp | 2 |
3 files changed, 30 insertions, 14 deletions
diff --git a/src/archive.cpp b/src/archive.cpp index edc8625..c759477 100644 --- a/src/archive.cpp +++ b/src/archive.cpp | |||
@@ -324,19 +324,6 @@ Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archival &p) | |||
324 | return s; | 324 | return s; |
325 | } | 325 | } |
326 | 326 | ||
327 | /* | ||
328 | Bu::Archive &Bu::operator&&(Bu::Archive &s, Bu::Archival &p) | ||
329 | { | ||
330 | if (s.isLoading()) | ||
331 | { | ||
332 | return s >> p; | ||
333 | } | ||
334 | else | ||
335 | { | ||
336 | return s << p; | ||
337 | } | ||
338 | }*/ | ||
339 | |||
340 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) | 327 | Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) |
341 | { | 328 | { |
342 | ar << (uint32_t)s.length(); | 329 | ar << (uint32_t)s.length(); |
diff --git a/src/archive.h b/src/archive.h index a8ce53e..9ac3303 100644 --- a/src/archive.h +++ b/src/archive.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <string> | 5 | #include <string> |
6 | #include "archival.h" | 6 | #include "archival.h" |
7 | #include "stream.h" | 7 | #include "stream.h" |
8 | #include <list> | ||
8 | 9 | ||
9 | namespace Bu | 10 | namespace Bu |
10 | { | 11 | { |
@@ -92,6 +93,34 @@ namespace Bu | |||
92 | return ar << dat; | 93 | return ar << dat; |
93 | } | 94 | } |
94 | } | 95 | } |
96 | |||
97 | template<typename T> Archive &operator<<( Archive &ar, std::list<T> &l ) | ||
98 | { | ||
99 | typename std::list<T>::size_type num = l.size(); | ||
100 | ar << num; | ||
101 | for( typename std::list<T>::const_iterator i = l.begin(); i != l.end(); | ||
102 | i++ ) | ||
103 | { | ||
104 | ar << *i; | ||
105 | } | ||
106 | |||
107 | return ar; | ||
108 | } | ||
109 | |||
110 | template<typename T> Archive &operator>>( Archive &ar, std::list<T> &l ) | ||
111 | { | ||
112 | typename std::list<T>::size_type num; | ||
113 | ar >> num; | ||
114 | |||
115 | l.resize( num ); | ||
116 | for( typename std::list<T>::const_iterator i = l.begin(); | ||
117 | i != l.end(); i++ ) | ||
118 | { | ||
119 | ar >> *i; | ||
120 | } | ||
121 | |||
122 | return ar; | ||
123 | } | ||
95 | } | 124 | } |
96 | 125 | ||
97 | #endif | 126 | #endif |
diff --git a/src/unit/sfile.cpp b/src/unit/sfile.cpp index 3f52272..2aff312 100644 --- a/src/unit/sfile.cpp +++ b/src/unit/sfile.cpp | |||
@@ -87,7 +87,7 @@ public: | |||
87 | unitTest( sf.isEOS() == false ); | 87 | unitTest( sf.isEOS() == false ); |
88 | try | 88 | try |
89 | { | 89 | { |
90 | int r = sf.read( buf, 5 ); | 90 | sf.read( buf, 5 ); |
91 | unitFailed("No exception thrown"); | 91 | unitFailed("No exception thrown"); |
92 | } | 92 | } |
93 | catch( Bu::FileException &e ) | 93 | catch( Bu::FileException &e ) |