Bitcoin Core  0.15.99
P2P Digital Currency
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CBufferedFile Class Reference

Non-refcounted RAII wrapper around a FILE* that implements a ring buffer to deserialize from. More...

#include <streams.h>

Public Member Functions

 CBufferedFile (FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn)
 
 ~CBufferedFile ()
 
 CBufferedFile (const CBufferedFile &)=delete
 
CBufferedFileoperator= (const CBufferedFile &)=delete
 
int GetVersion () const
 
int GetType () const
 
void fclose ()
 
bool eof () const
 
void read (char *pch, size_t nSize)
 
uint64_t GetPos () const
 
bool SetPos (uint64_t nPos)
 
bool Seek (uint64_t nPos)
 
bool SetLimit (uint64_t nPos=std::numeric_limits< uint64_t >::max())
 
template<typename T >
CBufferedFileoperator>> (T &&obj)
 
void FindByte (char ch)
 

Protected Member Functions

bool Fill ()
 

Private Attributes

const int nType
 
const 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 712 of file streams.h.

Constructor & Destructor Documentation

◆ CBufferedFile() [1/2]

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

Definition at line 745 of file streams.h.

◆ ~CBufferedFile()

CBufferedFile::~CBufferedFile ( )
inline

Definition at line 751 of file streams.h.

◆ CBufferedFile() [2/2]

CBufferedFile::CBufferedFile ( const CBufferedFile )
delete

Member Function Documentation

◆ eof()

bool CBufferedFile::eof ( ) const
inline

Definition at line 772 of file streams.h.

◆ fclose()

void CBufferedFile::fclose ( )
inline

Definition at line 763 of file streams.h.

◆ Fill()

bool CBufferedFile::Fill ( )
inlineprotected

Definition at line 727 of file streams.h.

◆ FindByte()

void CBufferedFile::FindByte ( char  ch)
inline

Definition at line 846 of file streams.h.

◆ GetPos()

uint64_t CBufferedFile::GetPos ( ) const
inline

Definition at line 799 of file streams.h.

◆ GetType()

int CBufferedFile::GetType ( ) const
inline

Definition at line 761 of file streams.h.

◆ GetVersion()

int CBufferedFile::GetVersion ( ) const
inline

Definition at line 760 of file streams.h.

◆ operator=()

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

◆ operator>>()

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

Definition at line 839 of file streams.h.

Here is the call graph for this function:

◆ read()

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

Definition at line 777 of file streams.h.

Here is the call graph for this function:

◆ Seek()

bool CBufferedFile::Seek ( uint64_t  nPos)
inline

Definition at line 817 of file streams.h.

◆ SetLimit()

bool CBufferedFile::SetLimit ( uint64_t  nPos = std::numeric_limits<uint64_t>::max())
inline

Definition at line 831 of file streams.h.

◆ SetPos()

bool CBufferedFile::SetPos ( uint64_t  nPos)
inline

Definition at line 804 of file streams.h.

Member Data Documentation

◆ nReadLimit

uint64_t CBufferedFile::nReadLimit
private

Definition at line 721 of file streams.h.

◆ nReadPos

uint64_t CBufferedFile::nReadPos
private

Definition at line 720 of file streams.h.

◆ nRewind

uint64_t CBufferedFile::nRewind
private

Definition at line 722 of file streams.h.

◆ nSrcPos

uint64_t CBufferedFile::nSrcPos
private

Definition at line 719 of file streams.h.

◆ nType

const int CBufferedFile::nType
private

Definition at line 715 of file streams.h.

◆ nVersion

const int CBufferedFile::nVersion
private

Definition at line 716 of file streams.h.

◆ src

FILE* CBufferedFile::src
private

Definition at line 718 of file streams.h.

◆ vchBuf

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

Definition at line 723 of file streams.h.


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