From e7ab7cb1604c04763bbdcece5885e6ce5aa100b4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Apr 2007 17:37:46 +0000 Subject: 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. --- src/archive.cpp | 13 ------------- src/archive.h | 29 +++++++++++++++++++++++++++++ src/unit/sfile.cpp | 2 +- 3 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src') 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) return s; } -/* -Bu::Archive &Bu::operator&&(Bu::Archive &s, Bu::Archival &p) -{ - if (s.isLoading()) - { - return s >> p; - } - else - { - return s << p; - } -}*/ - Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) { 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 @@ #include #include "archival.h" #include "stream.h" +#include namespace Bu { @@ -92,6 +93,34 @@ namespace Bu return ar << dat; } } + + template Archive &operator<<( Archive &ar, std::list &l ) + { + typename std::list::size_type num = l.size(); + ar << num; + for( typename std::list::const_iterator i = l.begin(); i != l.end(); + i++ ) + { + ar << *i; + } + + return ar; + } + + template Archive &operator>>( Archive &ar, std::list &l ) + { + typename std::list::size_type num; + ar >> num; + + l.resize( num ); + for( typename std::list::const_iterator i = l.begin(); + i != l.end(); i++ ) + { + ar >> *i; + } + + return ar; + } } #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: unitTest( sf.isEOS() == false ); try { - int r = sf.read( buf, 5 ); + sf.read( buf, 5 ); unitFailed("No exception thrown"); } catch( Bu::FileException &e ) -- cgit v1.2.3