CBMC
Loading...
Searching...
No Matches
output_file.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Output File Container
4
5Author: Daniel Kroening, dkr@amazon.com
6
7\*******************************************************************/
8
9#ifndef CPROVER_UTIL_OUTPUT_FILE_H
10#define CPROVER_UTIL_OUTPUT_FILE_H
11
14
15#include <iosfwd>
16#include <memory>
17#include <string>
18
21class output_filet final
22{
23public:
26 explicit output_filet(std::string file_name);
28
29 std::ostream &stream()
30 {
31 return *_stream;
32 }
33
35 const std::string &name() const
36 {
37 return _name;
38 }
39
41 bool is_file() const
42 {
43 return _ofstream != nullptr;
44 }
45
46private:
47 std::string _name;
48 std::unique_ptr<std::ofstream> _ofstream;
49 std::ostream *_stream = nullptr;
50};
51
52#endif // CPROVER_UTIL_OUTPUT_FILE_H
RAII container for an output stream that is either stdout or a file.
Definition output_file.h:22
std::unique_ptr< std::ofstream > _ofstream
Definition output_file.h:48
const std::string & name() const
The name of the file, or "stdout".
Definition output_file.h:35
bool is_file() const
True if the output is a file (not stdout).
Definition output_file.h:41
std::string _name
Definition output_file.h:47
std::ostream & stream()
Definition output_file.h:29
std::ostream * _stream
Definition output_file.h:49