3 modified files
lcio/src/cpp/include/SIO
diff -u -r1.16 -r1.17
--- LCSIO.h 6 Dec 2006 19:09:18 -0000 1.16
+++ LCSIO.h 2 Feb 2007 09:07:56 -0000 1.17
@@ -11,6 +11,7 @@
#define LCSIO_READ( rec, pnt ) status = LCSIO::read( (rec), (pnt) ); if( !(status & 1) ) return status;
+#define LCSIO_READ_LEN( rec, pnt , len ) status = LCSIO::read( (rec), (pnt) , (len) ); if( !(status & 1) ) return status;
#define LCSIO_WRITE( rec, pnt ) status = LCSIO::write( (rec), (pnt) ); if( !(status & 1) ) return status;
@@ -46,8 +47,9 @@
/** Read a string from the stream into a dummy buffer.
* Warning the same buffer is used for each call.
* So the return value needs to be copied to its final memory destination.
+ * len holds the length of the string (can contain '\0').
*/
- static unsigned int read( SIO_stream* stream ,char** c ) ;
+ static unsigned int read( SIO_stream* stream ,char** c , int* len=0) ;
// /** This version checks the versionId to be able to read 'old' files with
// * trailing '\00' (version <= 00-02).
lcio/src/cpp/src/SIO
diff -u -r1.14 -r1.15
--- LCSIO.cc 6 Dec 2006 19:09:19 -0000 1.14
+++ LCSIO.cc 2 Feb 2007 09:07:56 -0000 1.15
@@ -5,6 +5,8 @@
#include <cctype>
#include "Exceptions.h"
+#include <iostream>
+
using namespace EVENT ;
namespace SIO {
@@ -59,12 +61,12 @@
// }
- unsigned int LCSIO::read( SIO_stream* stream ,char** c){
+ unsigned int LCSIO::read( SIO_stream* stream ,char** c, int* len){
int status ;
int strLen ;
status = SIO_functions::data( stream , &strLen , 1 ) ;
-
+
if( !( status & 1 ) ) return status ;
// make sure our string buffer is large enough
@@ -80,9 +82,10 @@
dummy[ strLen ] = '\0' ; // still needed for char* ...
*c = dummy ;
-
+ if(len!=0)
+ *len = strLen ;
+
return status ;
-
}
unsigned int LCSIO::write( SIO_stream* stream , int i){
lcio/src/cpp/src/SIO
diff -u -r1.4 -r1.5
--- SIOStrVecHandler.cc 15 Apr 2005 08:37:50 -0000 1.4
+++ SIOStrVecHandler.cc 2 Feb 2007 09:07:56 -0000 1.5
@@ -29,8 +29,14 @@
// char* x = new char*[]( nElements ) ;
for(int i=0;i<nElements;i++){
char* x ;
- LCSIO_READ( stream , &x ) ;
- vec->push_back( x ) ;
+ int len ;
+ LCSIO_READ_LEN( stream , &x , &len) ;
+
+ // vec->push_back( x ) ;
+ vec->resize( vec->size() + 1 ) ;
+ vec->back().resize(len) ;
+ memcpy( &(vec->back()[0]) , x , len ) ;
+
}
if( _vers > SIO_VERSION_ENCODE( 1, 2) ) {
CVSspam 0.2.8