21 #ifndef BINARYSTOREHELPER_H
22 #define BINARYSTOREHELPER_H
25 #include "AliHLTTPCCADef.h"
30 template<
typename T>
static inline void BinaryStoreWrite(
const T *mem,
int count, FILE *f )
32 const int written = std::fwrite( mem,
sizeof( T ), count, f );
33 assert( written == count ); UNUSED_PARAM1( written );
36 template<
typename T>
static inline void BinaryStoreWrite(
const T &mem, FILE *f )
38 const size_t written = std::fwrite( &mem,
sizeof( T ), 1, f );
39 assert( written == 1 ); UNUSED_PARAM1( written );
42 static inline void BinaryStoreWrite(
const void *offsetPtr,
const void *mem, FILE *f )
44 const int offset =
static_cast<const char *
>( offsetPtr ) - static_cast<const char *>( mem );
45 const size_t written = std::fwrite( &offset,
sizeof(
int ), 1, f );
46 assert( written == 1 ); UNUSED_PARAM1( written );
51 template<
typename T>
static inline void BinaryStoreRead( T *mem,
int count, FILE *f )
53 const int read = std::fread( mem,
sizeof( T ), count, f );
54 assert( read == count ); UNUSED_PARAM1( read );
57 template<
typename T>
static inline void BinaryStoreRead( T &mem, FILE *f )
59 const size_t read = std::fread( &mem,
sizeof( T ), 1, f );
60 assert( read == 1 ); UNUSED_PARAM1( read );
64 static inline void BinaryStoreRead( T *&offsetPtr,
char *mem, FILE *f )
67 const size_t read = std::fread( &offset,
sizeof(
int ), 1, f );
68 assert( read == 1 ); UNUSED_PARAM1( read );
69 offsetPtr =
reinterpret_cast<T *
>( mem + offset );
72 #endif // BINARYSTOREHELPER_H