OpenVDB: openvdb/io/TempFile.h Source File

OpenVDB 9.0.0

TempFile.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: MPL-2.0
3
4/// @file TempFile.h
5
6#ifndef OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
7#define OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
8
9#include <openvdb/version.h>
10#include <memory>
11#include <ostream>
12
13
14namespace openvdb {
15 OPENVDB_USE_VERSION_NAMESPACE
16namespace OPENVDB_VERSION_NAME {
17namespace io {
18
19/// Output stream to a unique temporary file
20 class OPENVDB_API TempFile: public std::ostream
21{
22public:
23 /// @brief Create and open a unique file.
24 /// @details On UNIX systems, the file is created in the directory specified by
25 /// the environment variable @c OPENVDB_TEMP_DIR, if that variable is defined,
26 /// or else in the directory specified by @c TMPDIR, if that variable is defined.
27 /// Otherwise (and on non-UNIX systems), the file is created in the system default
28 /// temporary directory.
29 TempFile();
30 ~TempFile();
31
32 /// Return the path to the temporary file.
33 const std::string& filename() const;
34
35 /// Return @c true if the file is open for writing.
36 bool is_open() const;
37
38 /// Close the file.
39 void close();
40
41private:
42 struct TempFileImpl;
43 std::unique_ptr<TempFileImpl> mImpl;
44};
45
46} // namespace io
47} // namespace OPENVDB_VERSION_NAME
48} // namespace openvdb
49
50#endif // OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
OPENVDB_API
#define OPENVDB_API
Definition: Platform.h:254
openvdb::v9_0::io::TempFile
Output stream to a unique temporary file.
Definition: TempFile.h:21
openvdb::v9_0::io::TempFile::is_open
bool is_open() const
Return true if the file is open for writing.
openvdb::v9_0::io::TempFile::filename
const std::string & filename() const
Return the path to the temporary file.
openvdb::v9_0::io::TempFile::close
void close()
Close the file.
openvdb::v9_0::io::TempFile::~TempFile
~TempFile()
openvdb::v9_0::io::TempFile::TempFile
TempFile()
Create and open a unique file.
openvdb
Definition: Exceptions.h:13
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202