From 509d136e9adb60c56369565b9545e613cac3678e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 12 Nov 2009 17:05:30 +0000 Subject: I've started my campaign to clean up all of the header files in libbu++ as far as includes go. This required a little bit of reworking as far as archive goes, but I've been planning on changing it aronud for a bit anyway. The final result here is that you may need to add some more includes in your own code, libbu++ doesn't include as many random things you didn't ask for anymore, most of these seem to be bu/hash.h, unistd.h, and time.h. Also, any Archive functions and operators should use ArchiveBase when they can instead of Archive, archivebase.h is a much lighterweight include that will be used everywhere in core that it can be, there are a few classes that actually want a specific archiver to be used, they will use it (such as the nids storage class). So far, except for adding header files, nothing has changed in functionality, and no other code changes should be required, although the above mentioned archive changeover is reccomended. --- src/array.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/array.h') diff --git a/src/array.h b/src/array.h index ca4ec21..6279382 100644 --- a/src/array.h +++ b/src/array.h @@ -10,6 +10,7 @@ #include #include "bu/exceptionbase.h" +#include "bu/archivebase.h" namespace Bu { @@ -442,6 +443,38 @@ namespace Bu return f; } + + template + ArchiveBase &operator<<( ArchiveBase &ar, + const Array &h ) + { + ar << h.getSize(); + for( typename Array::const_iterator i = + h.begin(); i != h.end(); i++ ) + { + ar << (*i); + } + + return ar; + } + + template + ArchiveBase &operator>>(ArchiveBase &ar, Array &h ) + { + h.clear(); + long nSize; + ar >> nSize; + + h.setCapacity( nSize ); + for( long j = 0; j < nSize; j++ ) + { + value v; + ar >> v; + h.append( v ); + } + return ar; + } + } #endif -- cgit v1.2.3