spot  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tmpfile.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2013 Laboratoire de Recherche et Développement
3 // 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 #ifndef SPOT_MISC_TMPFILE_HH
21 # define SPOT_MISC_TMPFILE_HH
22 
23 # include "common.hh"
24 # include <new>
25 # include <stdexcept>
26 # include <iostream>
27 # include <list>
28 # include "formater.hh"
29 
30 namespace spot
31 {
34 
50  class SPOT_API temporary_file: public printable
51  {
52  public:
53  typedef std::list<temporary_file*>::iterator cleanpos_t;
54 
55  SPOT_LOCAL temporary_file(char* name, cleanpos_t cp);
56  ~temporary_file();
57 
58  const char* name() const
59  {
60  return name_;
61  }
62 
63  friend std::ostream& operator<<(std::ostream& os, const temporary_file* f)
64  {
65  os << f->name();
66  return os;
67  }
68 
69  virtual void
70  print(std::ostream& os, const char*) const
71  {
72  os << this;
73  }
74 
75  protected:
76  char* name_;
77  cleanpos_t cleanpos_;
78  };
79 
87  class SPOT_API open_temporary_file: public temporary_file
88  {
89  public:
90  SPOT_LOCAL open_temporary_file(char* name, cleanpos_t cp, int fd);
91  ~open_temporary_file();
92 
93  void close();
94 
95  int fd() const
96  {
97  return fd_;
98  }
99 
100  protected:
101  int fd_;
102  };
103 
112  SPOT_API temporary_file*
113  create_tmpfile(const char* prefix, const char* suffix = 0)
114  throw(std::bad_alloc, std::runtime_error);
115 
120  SPOT_API open_temporary_file*
121  create_open_tmpfile(const char* prefix, const char* suffix = 0)
122  throw(std::bad_alloc, std::runtime_error);
123 
136  SPOT_API void
138 
140 }
141 
142 
143 #endif // SPOT_MISC_TMPFILE_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Thu May 15 2014 11:04:11 for spot by doxygen 1.8.4