Public Types | Public Member Functions
file Class Reference

Public Types

using text_data = std::string
 
using binary_data = std::vector< char >
 
using filename_type = std::string
 

Public Member Functions

 file () noexcept=default
 
virtual ~file ()=default
 
virtual text_data read_text (const filename_type &filename) const
 
virtual binary_data read_binary (const filename_type &filename) const
 
virtual void write_text (const filename_type &filename, const text_data &data) const
 
virtual void write_binary (const filename_type &filename, const binary_data &data) const
 

Detailed Description

File

This class is responsible for working with a file. Specifically, this class wraps calls to ifstream and fstream to simplify their interface as well as provide an implementation for the rest of the Bareflank Manager, such that testing is easier.

Definition at line 35 of file file.h.

Member Typedef Documentation

◆ text_data

using file::text_data = std::string

Definition at line 39 of file file.h.

◆ binary_data

using file::binary_data = std::vector<char>

Definition at line 40 of file file.h.

◆ filename_type

using file::filename_type = std::string

Definition at line 41 of file file.h.

Constructor & Destructor Documentation

◆ file()

file::file ( )
defaultnoexcept

File Constructor

Precondition
expects: none
Postcondition
ensures: none

Creates a file class that can be used to working with files.

◆ ~file()

virtual file::~file ( )
virtualdefault

File Destructor

Precondition
expects: none
Postcondition
ensures: none

Member Function Documentation

◆ read_text()

file::text_data file::read_text ( const filename_type filename) const
virtual

Read

Reads the entire contents of a file, in text form

Precondition
expects: filename.empty() == false
Postcondition
ensures: none
Parameters
filenamename of the file to read.
Returns
the contents of filename

Definition at line 30 of file file.cpp.

◆ read_binary()

file::binary_data file::read_binary ( const filename_type filename) const
virtual

Read

Reads the entire contents of a file, in binary form

Precondition
expects: filename.empty() == false
Postcondition
ensures: none
Parameters
filenamename of the file to read.
Returns
the contents of filename

Definition at line 42 of file file.cpp.

◆ write_text()

void file::write_text ( const filename_type filename,
const text_data data 
) const
virtual

Write

Writes text data to the file provided

Precondition
expects: filename.empty() == false
expects: data.empty() == false
Postcondition
ensures: none
Parameters
filenamename of the file to write to.
datadata to write

Definition at line 54 of file file.cpp.

◆ write_binary()

void file::write_binary ( const filename_type filename,
const binary_data data 
) const
virtual

Write

Writes binary data to the file provided

Precondition
expects: filename.empty() == false
expects: data.empty() == false
Postcondition
ensures: none
Parameters
filenamename of the file to write to.
datadata to write

Definition at line 69 of file file.cpp.


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