cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
output_file.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Output File Container
4
5
Author: Daniel Kroening, dkr@amazon.com
6
7
\*******************************************************************/
8
11
12
#include "
output_file.h
"
13
14
#include "
exception_utils.h
"
15
#include "
unicode.h
"
16
17
#include <fstream>
18
#include <iostream>
19
20
output_filet::output_filet
(std::string file_name) :
_name
(
std
::move(file_name))
21
{
22
if
(
_name
==
"-"
)
23
{
24
_stream
= &std::cout;
25
_name
=
"stdout"
;
26
}
27
else
28
{
29
_ofstream
= std::make_unique<std::ofstream>(
widen_if_needed
(
_name
));
30
if
(!*
_ofstream
)
31
throw
system_exceptiont
(
"failed to open "
+
_name
);
32
_stream
=
_ofstream
.get();
33
}
34
}
35
36
output_filet::~output_filet
() =
default
;
output_filet::output_filet
output_filet(std::string file_name)
Create a stream to the given file name, or stdout if "-".
Definition
output_file.cpp:20
output_filet::_ofstream
std::unique_ptr< std::ofstream > _ofstream
Definition
output_file.h:48
output_filet::_name
std::string _name
Definition
output_file.h:47
output_filet::_stream
std::ostream * _stream
Definition
output_file.h:49
output_filet::~output_filet
~output_filet()
system_exceptiont
Thrown when some external system fails unexpectedly.
Definition
exception_utils.h:72
exception_utils.h
std
STL namespace.
output_file.h
Output file container that handles stdout ("-") and regular files.
unicode.h
widen_if_needed
#define widen_if_needed(s)
Definition
unicode.h:28
util
output_file.cpp
Generated by
1.17.0