Dash Core  0.12.2.1
P2P Digital Currency
CBufferedFile Class Reference

#include <streams.h>

Public Member Functions

 CBufferedFile (FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn)
 
 ~CBufferedFile ()
 
void fclose ()
 
bool eof () const
 
CBufferedFileread (char *pch, size_t nSize)
 
uint64_t GetPos ()
 
bool SetPos (uint64_t nPos)
 
bool Seek (uint64_t nPos)
 
bool SetLimit (uint64_t nPos=(uint64_t)(-1))
 
template<typename T >
CBufferedFileoperator>> (T &obj)
 
void FindByte (char ch)
 

Protected Member Functions

bool Fill ()
 

Private Member Functions

 CBufferedFile (const CBufferedFile &)
 
CBufferedFileoperator= (const CBufferedFile &)
 

Private Attributes

int nType
 
int nVersion
 
FILE * src
 
uint64_t nSrcPos
 
uint64_t nReadPos
 
uint64_t nReadLimit
 
uint64_t nRewind
 
std::vector< char > vchBuf
 

Detailed Description

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.

Will automatically close the file when it goes out of scope if not null. If you need to close the file early, use file.fclose() instead of fclose(file).

Definition at line 457 of file streams.h.

Constructor & Destructor Documentation

◆ CBufferedFile() [1/2]

CBufferedFile::CBufferedFile ( const CBufferedFile )
private

◆ CBufferedFile() [2/2]

CBufferedFile::CBufferedFile ( FILE *  fileIn,
uint64_t  nBufSize,
uint64_t  nRewindIn,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 494 of file streams.h.

◆ ~CBufferedFile()

CBufferedFile::~CBufferedFile ( )
inline

Definition at line 502 of file streams.h.

Member Function Documentation

◆ eof()

bool CBufferedFile::eof ( ) const
inline

Definition at line 516 of file streams.h.

Referenced by LoadExternalBlockFile().

◆ fclose()

void CBufferedFile::fclose ( )
inline

Definition at line 507 of file streams.h.

Referenced by ~CBufferedFile().

◆ Fill()

bool CBufferedFile::Fill ( )
inlineprotected

Definition at line 476 of file streams.h.

Referenced by FindByte(), and read().

◆ FindByte()

void CBufferedFile::FindByte ( char  ch)
inline

Definition at line 591 of file streams.h.

Referenced by LoadExternalBlockFile().

◆ GetPos()

uint64_t CBufferedFile::GetPos ( )
inline

Definition at line 544 of file streams.h.

Referenced by LoadExternalBlockFile().

◆ operator=()

CBufferedFile& CBufferedFile::operator= ( const CBufferedFile )
private

◆ operator>>()

template<typename T >
CBufferedFile& CBufferedFile::operator>> ( T &  obj)
inline

Definition at line 584 of file streams.h.

◆ read()

CBufferedFile& CBufferedFile::read ( char *  pch,
size_t  nSize 
)
inline

Definition at line 521 of file streams.h.

Referenced by Fill().

◆ Seek()

bool CBufferedFile::Seek ( uint64_t  nPos)
inline

Definition at line 562 of file streams.h.

◆ SetLimit()

bool CBufferedFile::SetLimit ( uint64_t  nPos = (uint64_t)(-1))
inline

Definition at line 576 of file streams.h.

Referenced by LoadExternalBlockFile().

◆ SetPos()

bool CBufferedFile::SetPos ( uint64_t  nPos)
inline

Definition at line 549 of file streams.h.

Referenced by LoadExternalBlockFile().

Member Data Documentation

◆ nReadLimit

uint64_t CBufferedFile::nReadLimit
private

Definition at line 470 of file streams.h.

Referenced by read(), and SetLimit().

◆ nReadPos

uint64_t CBufferedFile::nReadPos
private

Definition at line 469 of file streams.h.

Referenced by eof(), Fill(), FindByte(), GetPos(), read(), Seek(), SetLimit(), and SetPos().

◆ nRewind

uint64_t CBufferedFile::nRewind
private

Definition at line 471 of file streams.h.

Referenced by Fill(), read(), and SetPos().

◆ nSrcPos

uint64_t CBufferedFile::nSrcPos
private

Definition at line 468 of file streams.h.

Referenced by eof(), Fill(), FindByte(), read(), Seek(), and SetPos().

◆ nType

int CBufferedFile::nType
private

Definition at line 464 of file streams.h.

Referenced by CBufferedFile(), and operator>>().

◆ nVersion

int CBufferedFile::nVersion
private

Definition at line 465 of file streams.h.

Referenced by CBufferedFile(), and operator>>().

◆ src

FILE* CBufferedFile::src
private

Definition at line 467 of file streams.h.

Referenced by CBufferedFile(), eof(), fclose(), Fill(), and Seek().

◆ vchBuf

std::vector<char> CBufferedFile::vchBuf
private

Definition at line 472 of file streams.h.

Referenced by Fill(), FindByte(), and read().


The documentation for this class was generated from the following file: