spot 2.3.3

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List

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

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.