spot 2.12.2
tmpfile.hh
1// -*- coding: utf-8 -*-
2// Copyright (C) by the Spot authors, see the AUTHORS file for details.
3//
4// This file is part of Spot, a model checking library.
5//
6// Spot is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 3 of the License, or
9// (at your option) any later version.
10//
11// Spot is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14// License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19#pragma once
20
21#include <spot/misc/common.hh>
22#include <new>
23#include <stdexcept>
24#include <iostream>
25#include <list>
26#include <spot/misc/formater.hh>
27
28namespace spot
29{
32
48 class SPOT_API temporary_file: public printable
49 {
50 public:
51 typedef std::list<temporary_file*>::iterator cleanpos_t;
52
53 SPOT_LOCAL temporary_file(char* name, cleanpos_t cp);
54
55 temporary_file(const temporary_file& other) = delete;
56
57 virtual ~temporary_file() override;
58
59 const char* name() const
60 {
61 return name_;
62 }
63
64 friend std::ostream& operator<<(std::ostream& os, const temporary_file* f)
65 {
66 os << f->name();
67 return os;
68 }
69
70 virtual void
71 print(std::ostream& os, const char*) const final override
72 {
73 os << this;
74 }
75
76 protected:
77 char* name_;
78 cleanpos_t cleanpos_;
79 };
80
88 class SPOT_API open_temporary_file final: public temporary_file
89 {
90 public:
91 SPOT_LOCAL open_temporary_file(char* name, cleanpos_t cp, int fd);
92 virtual ~open_temporary_file() override;
93
94 void close();
95
96 int fd() const
97 {
98 return fd_;
99 }
100
101 protected:
102 int fd_;
103 };
104
113 SPOT_API temporary_file*
114 create_tmpfile(const char* prefix, const char* suffix = nullptr);
115
120 SPOT_API open_temporary_file*
121 create_open_tmpfile(const char* prefix, const char* suffix = nullptr);
122
135 SPOT_API void
137
139}
Open temporary file.
Definition: tmpfile.hh:89
Definition: formater.hh:30
Temporary file name.
Definition: tmpfile.hh:49
Definition: automata.hh:26
void cleanup_tmpfiles()
Delete all temporary files.
temporary_file * create_tmpfile(const char *prefix, const char *suffix=nullptr)
Create a temporary file.
open_temporary_file * create_open_tmpfile(const char *prefix, const char *suffix=nullptr)
Create a temporary file and leave it open for writing.

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.4