Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

Non-refcounted RAII wrapper for FILE*. More...

#include <streams.h>

Public Member Functions

 CAutoFile (FILE *filenew, int nTypeIn, int nVersionIn)
 
 ~CAutoFile ()
 
 CAutoFile (const CAutoFile &)=delete
 
CAutoFileoperator= (const CAutoFile &)=delete
 
void fclose ()
 
FILE * release ()
 Get wrapped FILE* with transfer of ownership. More...
 
FILE * Get () const
 Get wrapped FILE* without transfer of ownership. More...
 
bool IsNull () const
 Return true if the wrapped FILE* is nullptr, false otherwise. More...
 
int GetType () const
 
int GetVersion () const
 
void read (char *pch, size_t nSize)
 
void ignore (size_t nSize)
 
void write (const char *pch, size_t nSize)
 
template<typename T >
CAutoFileoperator<< (const T &obj)
 
template<typename T >
CAutoFileoperator>> (T &obj)
 

Private Attributes

const int nType
 
const int nVersion
 
FILE * file
 

Detailed Description

Non-refcounted RAII wrapper for FILE*.

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

Definition at line 410 of file streams.h.

Constructor & Destructor Documentation

◆ CAutoFile() [1/2]

CAutoFile::CAutoFile ( FILE *  filenew,
int  nTypeIn,
int  nVersionIn 
)
inline

Definition at line 419 of file streams.h.

References file.

◆ ~CAutoFile()

CAutoFile::~CAutoFile ( )
inline

Definition at line 424 of file streams.h.

References fclose().

◆ CAutoFile() [2/2]

CAutoFile::CAutoFile ( const CAutoFile )
delete

Member Function Documentation

◆ fclose()

void CAutoFile::fclose ( )
inline

Definition at line 433 of file streams.h.

References file.

Referenced by DumpMempool(), and ~CAutoFile().

◆ Get()

FILE* CAutoFile::Get ( ) const
inline

Get wrapped FILE* without transfer of ownership.

Note
Ownership of the FILE* will remain with this class. Use this only if the scope of the CAutoFile outlives use of the passed pointer.

Definition at line 451 of file streams.h.

References file.

Referenced by DumpMempool(), and GetTransaction().

◆ GetType()

int CAutoFile::GetType ( ) const
inline

Definition at line 460 of file streams.h.

References nType.

◆ GetVersion()

int CAutoFile::GetVersion ( ) const
inline

Definition at line 461 of file streams.h.

References nVersion.

◆ ignore()

void CAutoFile::ignore ( size_t  nSize)
inline

Definition at line 471 of file streams.h.

References file.

◆ IsNull()

bool CAutoFile::IsNull ( ) const
inline

Return true if the wrapped FILE* is nullptr, false otherwise.

Definition at line 455 of file streams.h.

References file.

Referenced by AppInitMain(), GetTransaction(), LoadMempool(), PrepareShutdown(), and ReadBlockFromDisk().

◆ operator<<()

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

Definition at line 493 of file streams.h.

References file, and Serialize().

◆ operator=()

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

◆ operator>>()

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

Definition at line 503 of file streams.h.

References file, and Unserialize().

◆ read()

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

Definition at line 463 of file streams.h.

References file.

◆ release()

FILE* CAutoFile::release ( )
inline

Get wrapped FILE* with transfer of ownership.

Note
This will invalidate the CAutoFile object, and makes it the responsibility of the caller of this function to clean up the returned FILE*.

Definition at line 445 of file streams.h.

References file.

◆ write()

void CAutoFile::write ( const char *  pch,
size_t  nSize 
)
inline

Definition at line 484 of file streams.h.

References file.

Member Data Documentation

◆ file

FILE* CAutoFile::file
private

Definition at line 416 of file streams.h.

Referenced by CAutoFile(), fclose(), Get(), ignore(), IsNull(), operator<<(), operator>>(), read(), release(), and write().

◆ nType

const int CAutoFile::nType
private

Definition at line 413 of file streams.h.

Referenced by GetType().

◆ nVersion

const int CAutoFile::nVersion
private

Definition at line 414 of file streams.h.

Referenced by GetVersion().


The documentation for this class was generated from the following file:
Released under the MIT license