Dash Core  0.12.2.1
P2P Digital Currency
CAutoFile Class Reference

#include <streams.h>

Public Member Functions

 CAutoFile (FILE *filenew, int nTypeIn, int nVersionIn)
 
 ~CAutoFile ()
 
void fclose ()
 
FILE * release ()
 
FILE * Get () const
 
bool IsNull () const
 
void SetType (int n)
 
int GetType ()
 
void SetVersion (int n)
 
int GetVersion ()
 
void ReadVersion ()
 
void WriteVersion ()
 
CAutoFileread (char *pch, size_t nSize)
 
CAutoFilewrite (const char *pch, size_t nSize)
 
template<typename T >
unsigned int GetSerializeSize (const T &obj)
 
template<typename T >
CAutoFileoperator<< (const T &obj)
 
template<typename T >
CAutoFileoperator>> (T &obj)
 

Private Member Functions

 CAutoFile (const CAutoFile &)
 
CAutoFileoperator= (const CAutoFile &)
 

Private Attributes

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

Constructor & Destructor Documentation

◆ CAutoFile() [1/2]

CAutoFile::CAutoFile ( const CAutoFile )
private

◆ CAutoFile() [2/2]

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

Definition at line 359 of file streams.h.

◆ ~CAutoFile()

CAutoFile::~CAutoFile ( )
inline

Definition at line 366 of file streams.h.

Member Function Documentation

◆ fclose()

void CAutoFile::fclose ( )
inline

Definition at line 371 of file streams.h.

Referenced by ~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 389 of file streams.h.

◆ GetSerializeSize()

template<typename T >
unsigned int CAutoFile::GetSerializeSize ( const T &  obj)
inline

Definition at line 424 of file streams.h.

◆ GetType()

int CAutoFile::GetType ( )
inline

Definition at line 399 of file streams.h.

◆ GetVersion()

int CAutoFile::GetVersion ( )
inline

Definition at line 401 of file streams.h.

◆ IsNull()

bool CAutoFile::IsNull ( ) const
inline

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

Definition at line 393 of file streams.h.

Referenced by AppInit2(), PrepareShutdown(), and ReadBlockFromDisk().

◆ operator<<()

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

Definition at line 431 of file streams.h.

◆ operator=()

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

◆ operator>>()

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

Definition at line 441 of file streams.h.

◆ read()

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

Definition at line 405 of file streams.h.

◆ ReadVersion()

void CAutoFile::ReadVersion ( )
inline

Definition at line 402 of file streams.h.

◆ 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 383 of file streams.h.

◆ SetType()

void CAutoFile::SetType ( int  n)
inline

Definition at line 398 of file streams.h.

◆ SetVersion()

void CAutoFile::SetVersion ( int  n)
inline

Definition at line 400 of file streams.h.

◆ write()

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

Definition at line 414 of file streams.h.

◆ WriteVersion()

void CAutoFile::WriteVersion ( )
inline

Definition at line 403 of file streams.h.

Member Data Documentation

◆ file

FILE* CAutoFile::file
private

Definition at line 356 of file streams.h.

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

◆ nType

int CAutoFile::nType
private

Definition at line 353 of file streams.h.

Referenced by CAutoFile(), GetSerializeSize(), GetType(), operator<<(), operator>>(), and SetType().

◆ nVersion

int CAutoFile::nVersion
private

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