summaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
committerMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
commit509d136e9adb60c56369565b9545e613cac3678e (patch)
treef118d676edeae2d5e17f48b32b180d4761b60520 /src/array.h
parent3166bd631a093f42ea44a4b0f4d914cf51518bd4 (diff)
downloadlibbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.gz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.bz2
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.xz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.zip
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.
Diffstat (limited to 'src/array.h')
-rw-r--r--src/array.h33
1 files changed, 33 insertions, 0 deletions
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 @@
10 10
11#include <memory> 11#include <memory>
12#include "bu/exceptionbase.h" 12#include "bu/exceptionbase.h"
13#include "bu/archivebase.h"
13 14
14namespace Bu 15namespace Bu
15{ 16{
@@ -442,6 +443,38 @@ namespace Bu
442 443
443 return f; 444 return f;
444 } 445 }
446
447 template<typename value, int inc, typename valuealloc>
448 ArchiveBase &operator<<( ArchiveBase &ar,
449 const Array<value, inc, valuealloc> &h )
450 {
451 ar << h.getSize();
452 for( typename Array<value, inc, valuealloc>::const_iterator i =
453 h.begin(); i != h.end(); i++ )
454 {
455 ar << (*i);
456 }
457
458 return ar;
459 }
460
461 template<typename value, int inc, typename valuealloc>
462 ArchiveBase &operator>>(ArchiveBase &ar, Array<value, inc, valuealloc> &h )
463 {
464 h.clear();
465 long nSize;
466 ar >> nSize;
467
468 h.setCapacity( nSize );
469 for( long j = 0; j < nSize; j++ )
470 {
471 value v;
472 ar >> v;
473 h.append( v );
474 }
475 return ar;
476 }
477
445} 478}
446 479
447#endif 480#endif