summaryrefslogtreecommitdiff
path: root/src/archive.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-04-10 17:37:46 +0000
committerMike Buland <eichlan@xagasoft.com>2007-04-10 17:37:46 +0000
commite7ab7cb1604c04763bbdcece5885e6ce5aa100b4 (patch)
treedb5bee7da9373f64508e243f24031bc35b1acee7 /src/archive.h
parent903e7a1e3d4fe99e9de7f4adc1e401ba871caec9 (diff)
downloadlibbu++-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.
Diffstat (limited to 'src/archive.h')
-rw-r--r--src/archive.h29
1 files changed, 29 insertions, 0 deletions
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
9namespace Bu 10namespace 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