trappervector.h File Reference

#include <qcstring.h>
#include <qvaluelist.h>
#include <qdom.h>
#include <qxml.h>
#include <vector>
#include <iostream>

Include dependency graph for trappervector.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TrapperVector< T >
 To store an array of values. It's a template class to be used in the serializing bytearray and import/export to dom tree. More...

Functions

template<class T>
QDataStreamoperator<< (QDataStream &stream, TrapperVector< T > &t)
template<class T>
QDataStreamoperator>> (QDataStream &stream, TrapperVector< T > &t)


Function Documentation

template<class T>
QDataStream& operator<< ( QDataStream stream,
TrapperVector< T > &  t 
)

Todo: But a problem with this approach might be that the endian awareness of QDataStream might be lost, when we don't serialize the types one by one. It might be a problem when moving berkeley dbs around archictures. But berkeley db probably doesn't allow this anyway?

Definition at line 234 of file trappervector.h.

References QString::data().

00235 {
00236   if ( t.size() > 0 ) {
00237     
00238     
00239     
00240     const char * dataPtr =  t.data() ;
00241     
00242 #if defined(QT_DEBUG)
00243     
00244     if ( t.size() != 0 ) {
00245       Q_CHECK_PTR( dataPtr );
00246     }
00247     int a = t.size();
00248     qDebug("stream.writeBytes , t.size()=%d",a);
00249 #endif
00250     
00251     stream.writeBytes( dataPtr, t.size() );
00252   }
00253   else {
00254     stream<<0;
00255   }
00256   
00257 
00258   return stream;
00259 }

template<class T>
QDataStream& operator>> ( QDataStream stream,
TrapperVector< T > &  t 
)

Todo: But a problem with this approach might be that the endian awareness of QDataStream might be lost, when we don't serialize the types one by one. It might be a problem when moving berkeley dbs around archictures. But berkeley db probably doesn't allow this anyway?

Definition at line 267 of file trappervector.h.

References TrapperVector< T >::data(), QDataStream::readRawBytes(), and TrapperVector< T >::resize().

00268 {
00269     Q_UINT32 len;
00270     stream >> len;
00271 
00272     if ( len > 0 ) {
00273       t.resize( len );
00274       char * dataPtr =  const_cast< char * >( t.data() );
00275       Q_CHECK_PTR( dataPtr );
00276       if ( !dataPtr ) {
00277         cerr<<"len: "<<len<<endl;
00278       }
00279       
00280       
00281 #if defined(QT_DEBUG)
00282       // wrapping macro around should not be a must ... fix this
00283       qDebug("stream.readRawBytes, len=%d",len);
00284 #endif
00285       //     if ( dataPtr ) {
00286       stream.readRawBytes( dataPtr, len );
00287       //     }
00288     }
00289     
00290     return stream;
00291 }


Generated on Fri Jul 17 20:19:42 2009 for ngsview by  doxygen 1.5.1