CBMC
Loading...
Searching...
No Matches
output_filet Class Referencefinal

RAII container for an output stream that is either stdout or a file. More...

#include <output_file.h>

+ Collaboration diagram for output_filet:

Public Member Functions

 output_filet (std::string file_name)
 Create a stream to the given file name, or stdout if "-".
 
 ~output_filet ()
 
std::ostream & stream ()
 
const std::string & name () const
 The name of the file, or "stdout".
 
bool is_file () const
 True if the output is a file (not stdout).
 

Private Attributes

std::string _name
 
std::unique_ptr< std::ofstream > _ofstream
 
std::ostream * _stream = nullptr
 

Detailed Description

RAII container for an output stream that is either stdout or a file.

Pass "-" as the file name to write to stdout.

Definition at line 21 of file output_file.h.

Constructor & Destructor Documentation

◆ output_filet()

output_filet::output_filet ( std::string  file_name)
explicit

Create a stream to the given file name, or stdout if "-".

Throws system_exceptiont if the file cannot be opened.

Definition at line 20 of file output_file.cpp.

◆ ~output_filet()

output_filet::~output_filet ( )
default

Member Function Documentation

◆ is_file()

bool output_filet::is_file ( ) const
inline

True if the output is a file (not stdout).

Definition at line 41 of file output_file.h.

◆ name()

const std::string & output_filet::name ( ) const
inline

The name of the file, or "stdout".

Definition at line 35 of file output_file.h.

◆ stream()

std::ostream & output_filet::stream ( )
inline

Definition at line 29 of file output_file.h.

Member Data Documentation

◆ _name

std::string output_filet::_name
private

Definition at line 47 of file output_file.h.

◆ _ofstream

std::unique_ptr<std::ofstream> output_filet::_ofstream
private

Definition at line 48 of file output_file.h.

◆ _stream

std::ostream* output_filet::_stream = nullptr
private

Definition at line 49 of file output_file.h.


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