CFile Class Reference

A wrapper for the cstdio file type that closes the file automatically when the scope is left. More...

#include <mia/core/file.hh>

Inheritance diagram for CFile:
[legend]

Public Member Functions

 CFile (const std::string &filename, bool from_stdio, bool write)
 
 operator PFILE ()
 
bool operator! () const
 
virtual ~CFile () throw ()
 

Detailed Description

A wrapper for the cstdio file type that closes the file automatically when the scope is left.

This class implements a transparent wrapper around the C stdio FILE type to make it possible that the file is closed autmatically when the scope of the file variable is left. A variable of this type can be used with all the C-stdio functions that take a file pointer as argument.

Definition at line 46 of file file.hh.

Constructor & Destructor Documentation

◆ CFile()

CFile::CFile ( const std::string &  filename,
bool  from_stdio,
bool  write 
)

constructor

Parameters
filenameof the file to handle
from_stdiouse stdin or stdout
writeopen for writing or reading

◆ ~CFile()

virtual CFile::~CFile ( )
throw (
)
virtual

destructor, closes file if necessary

Member Function Documentation

◆ operator PFILE()

CFile::operator PFILE ( )
Returns
the stdio FILE pointer

◆ operator!()

bool CFile::operator! ( ) const
Returns
true if the file is not open (i.e. the FILE pointer is NULL

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