Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Raii::File Class Reference

A wrapper around the C FILE*-based IO API. More...

#include <file.h>

Collaboration diagram for Raii::File:
Collaboration graph

Public Member Functions

 File ()=delete
 
 File (const File &)=delete
 
Fileoperator= (const File &)=delete
 
 File (const char *path, const char *mode)
 Opens the file at the given path. More...
 
 File (File &&other) noexcept
 Creates a new file object from the file object's resources. More...
 
Fileoperator= (File &&other)
 Moves the given file object's resources to this file object. More...
 
 ~File ()
 Performs clean-up for this File instance. More...
 
void Close ()
 Closes this file resource. More...
 
bool IsOpen () const
 Checks if this file is still open. More...
 
int ReadChar ()
 Reads the next input character from this file. More...
 
void WriteChar (char Value)
 Writes a single character to the file. More...
 

Private Member Functions

bool CloseImpl ()
 Closes this file resource. More...
 

Private Attributes

std::FILE * m_file
 

Detailed Description

A wrapper around the C FILE*-based IO API.

Note: this is a header-only class.

Definition at line 47 of file file.h.

Constructor & Destructor Documentation

Raii::File::File ( )
delete
Raii::File::File ( const File )
delete
Raii::File::File ( const char *  path,
const char *  mode 
)
inline

Opens the file at the given path.

Definition at line 56 of file file.h.

References m_file.

Raii::File::File ( File &&  other)
inlinenoexcept

Creates a new file object from the file object's resources.

Definition at line 64 of file file.h.

Raii::File::~File ( )
inline

Performs clean-up for this File instance.

Definition at line 79 of file file.h.

References CloseImpl().

Here is the call graph for this function:

Member Function Documentation

File& Raii::File::operator= ( const File )
delete
File& Raii::File::operator= ( File &&  other)
inline

Moves the given file object's resources to this file object.

Definition at line 71 of file file.h.

References m_file.

void Raii::File::Close ( )
inline

Closes this file resource.

An exception is thrown if this file cannot be closed properly. Successfully closing a file more than once is a no-op.

Definition at line 89 of file file.h.

References CloseImpl().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Raii::File::IsOpen ( ) const
inline

Checks if this file is still open.

Definition at line 97 of file file.h.

References m_file.

Referenced by CloseImpl(), ReadChar(), and WriteChar().

Here is the caller graph for this function:

int Raii::File::ReadChar ( )
inline

Reads the next input character from this file.

'EOF' is returned when the end-of-file has been reached.

Definition at line 101 of file file.h.

References IsOpen(), and m_file.

Referenced by Raii::RandomReadFile::operator[](), and printFile().

Here is the call graph for this function:

Here is the caller graph for this function:

void Raii::File::WriteChar ( char  Value)
inline

Writes a single character to the file.

Definition at line 114 of file file.h.

References IsOpen(), and m_file.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Raii::File::CloseImpl ( )
inlineprivate

Closes this file resource.

A boolean is returned that tells if this resource has been closed properly. Closing a file more than once is OK and will return 'true' every time.

Definition at line 126 of file file.h.

References IsOpen(), and m_file.

Referenced by Close(), and ~File().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::FILE* Raii::File::m_file
private

Definition at line 139 of file file.h.

Referenced by CloseImpl(), File(), IsOpen(), operator=(), ReadChar(), and WriteChar().


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