/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/SIO/SIOStrVecHandler.cc

Go to the documentation of this file.
00001 #include "SIO/SIOStrVecHandler.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "EVENT/LCStrVec.h"
00006 #include "SIO_functions.h"
00007 #include "SIO_block.h"
00008 #include "SIO/LCSIO.h"
00009 
00010 #include <iostream>
00011 #include <cstring>
00012 
00013 using namespace std ;
00014 using namespace EVENT ;
00015 
00016 
00017 namespace SIO{
00018     
00019   unsigned int SIOStrVecHandler::read(SIO_stream* stream,
00020                                       LCObject** objP){
00021     unsigned int status ; 
00022         
00023     // create a new object :
00024     LCStrVec* vec  = new LCStrVec ;
00025     *objP = vec ;
00026         
00027     int nElements ;
00028     SIO_DATA( stream ,  &(nElements) , 1  ) ;
00029 
00030     //    char* x = new char*[]( nElements ) ;
00031     for(int i=0;i<nElements;i++){
00032       char* x ;
00033       int len ;
00034       LCSIO_READ_LEN( stream , &x , &len) ;
00035 
00036       //      vec->push_back( x ) ;
00037       vec->resize( vec->size() + 1 ) ;
00038       vec->back().resize(len) ;
00039       memcpy( &(vec->back()[0]) , x , len ) ;
00040 
00041     }
00042 
00043     if( _vers > SIO_VERSION_ENCODE( 1, 2)   ) {
00044       SIO_PTAG( stream , vec ) ;
00045     }
00046     return ( SIO_BLOCK_SUCCESS ) ;
00047         
00048   }
00049     
00050     
00051   unsigned int SIOStrVecHandler::write(SIO_stream* stream,
00052                                        const LCObject* obj){
00053     
00054     unsigned int status ; 
00055 
00056     const LCStrVec* vec = dynamic_cast<const LCStrVec*>(obj)  ;
00057     
00058     int nElements = vec->size() ;
00059 
00060     LCSIO_WRITE( stream, nElements ) ;
00061     for(int i=0;i<nElements;i++){
00062 
00063       LCSIO_WRITE( stream, (*vec)[i] ) ;
00064 
00065 //      std::cout <<  (*vec)[i] <<   ", " ;
00066     }    
00067 //      std::cout << std::endl ;
00068 
00069 
00070     SIO_PTAG( stream , vec ) ;
00071     
00072     return ( SIO_BLOCK_SUCCESS ) ;
00073     
00074   }
00075   
00076 } // namespace

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7