@ -1256,12 +1256,18 @@ public:
}
} ;
/** Wrapper around a FILE* that implements a ring buffer to
* deserialize from . It guarantees the ability to rewind
* a given number of bytes . */
/** Non-refcounted RAII wrapper around a FILE* that implements a ring buffer to
* deserialize from . It guarantees the ability to rewind a given number of bytes . */
class CBufferedFile
{
private :
// Disallow copies
CBufferedFile ( const CBufferedFile & ) ;
CBufferedFile & operator = ( const CBufferedFile & ) ;
int nType ;
int nVersion ;
FILE * src ; // source file
uint64_t nSrcPos ; // how many bytes have been read from source
uint64_t nReadPos ; // how many bytes have been read from this
@ -1289,12 +1295,18 @@ protected:
}
public :
int nType ;
int nVersion ;
CBufferedFile ( FILE * fileIn , uint64_t nBufSize , uint64_t nRewindIn , int nTypeIn , int nVersionIn ) :
src ( fileIn ) , nSrcPos ( 0 ) , nReadPos ( 0 ) , nReadLimit ( ( uint64_t ) ( - 1 ) ) , nRewind ( nRewindIn ) , vchBuf ( nBufSize , 0 ) ,
nType ( nTypeIn ) , nVersion ( nVersionIn ) {
nSrcPos ( 0 ) , nReadPos ( 0 ) , nReadLimit ( ( uint64_t ) ( - 1 ) ) , nRewind ( nRewindIn ) , vchBuf ( nBufSize , 0 )
{
src = fileIn ;
nType = nTypeIn ;
nVersion = nVersionIn ;
}
~ CBufferedFile ( )
{
if ( src )
fclose ( src ) ;
}
// check whether we're at the end of the source file