HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TempFile.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2012-2018 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
29 ///////////////////////////////////////////////////////////////////////////
30 
31 /// @file TempFile.h
32 
33 #ifndef OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
34 #define OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
35 
36 #include <openvdb/version.h>
37 #include <memory>
38 #include <ostream>
39 
40 
41 namespace openvdb {
43 namespace OPENVDB_VERSION_NAME {
44 namespace io {
45 
46 /// Output stream to a unique temporary file
47 class OPENVDB_API TempFile: public std::ostream
48 {
49 public:
50  /// @brief Create and open a unique file.
51  /// @details On UNIX systems, the file is created in the directory specified by
52  /// the environment variable @c OPENVDB_TEMP_DIR, if that variable is defined,
53  /// or else in the directory specified by @c TMPDIR, if that variable is defined.
54  /// Otherwise (and on non-UNIX systems), the file is created in the system default
55  /// temporary directory.
56  TempFile();
57  ~TempFile();
58 
59  /// Return the path to the temporary file.
60  const std::string& filename() const;
61 
62  /// Return @c true if the file is open for writing.
63  bool is_open() const;
64 
65  /// Close the file.
66  void close();
67 
68 private:
69  struct TempFileImpl;
70  std::unique_ptr<TempFileImpl> mImpl;
71 };
72 
73 } // namespace io
74 } // namespace OPENVDB_VERSION_NAME
75 } // namespace openvdb
76 
77 #endif // OPENVDB_IO_TEMPFILE_HAS_BEEN_INCLUDED
78 
79 // Copyright (c) 2012-2018 DreamWorks Animation LLC
80 // All rights reserved. This software is distributed under the
81 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
GT_API const UT_StringHolder filename
Output stream to a unique temporary file.
Definition: TempFile.h:47
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:189
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:194
virtual void close()
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:135