TPIE

11a2c2d
tpie::temp_file Class Reference

Class representing a reference to a temporary file. More...

#include <tpie/tempname.h>

Public Member Functions

 temp_file ()
 Create a temp_file associated with a temporary file. More...
 
 temp_file (const std::string &path, bool persist=false)
 Create a temp_file associated with a specific file. More...
 
bool is_persistent () const
 
void set_persistent (bool p)
 Set persistence. More...
 
void set_path (const std::string &path, bool persist=false)
 Associate with a specific file. More...
 
const std::string & path ()
 Get the path of the associated file. More...
 
void free ()
 Clears the current object reference. More...
 
void update_recorded_size (stream_size_type size)
 

Detailed Description

Class representing a reference to a temporary file.

When all temp_file objects to a file go out of scope and are not set to persistent, the associated temporary file will be deleted.

Definition at line 201 of file tempname.h.

Constructor & Destructor Documentation

◆ temp_file() [1/2]

tpie::temp_file::temp_file ( )
inline

Create a temp_file associated with a temporary file.

Definition at line 206 of file tempname.h.

206  {
207  m_inner = new bits::temp_file_inner();
208  }

◆ temp_file() [2/2]

tpie::temp_file::temp_file ( const std::string &  path,
bool  persist = false 
)
inline

Create a temp_file associated with a specific file.

Definition at line 213 of file tempname.h.

213  {
214  m_inner = new bits::temp_file_inner(path, persist);
215  }

References path().

Member Function Documentation

◆ free()

void tpie::temp_file::free ( )
inline

Clears the current object reference.

Definition at line 250 of file tempname.h.

250  {
251  m_inner = new bits::temp_file_inner();
252  }

◆ is_persistent()

bool tpie::temp_file::is_persistent ( ) const
inline
Returns
Whether this file should not be deleted when this object goes out of scope.

Definition at line 221 of file tempname.h.

221  {
222  return m_inner->is_persistent();
223  }

Referenced by tpie::ami::stack< item_type >::persist(), and tpie::ami::stream_old< T >::persist().

◆ path()

const std::string& tpie::temp_file::path ( )
inline

Get the path of the associated file.

Definition at line 243 of file tempname.h.

243  {
244  return m_inner->path();
245  }

Referenced by tpie::file_base_crtp< file_stream_base >::open(), set_path(), and temp_file().

◆ set_path()

void tpie::temp_file::set_path ( const std::string &  path,
bool  persist = false 
)
inline

Associate with a specific file.

Definition at line 236 of file tempname.h.

236  {
237  m_inner = new bits::temp_file_inner(path, persist);
238  }

References path().

◆ set_persistent()

void tpie::temp_file::set_persistent ( bool  p)
inline

Set persistence.

When true, the file will not be deleted when this goes out of scope.

Definition at line 229 of file tempname.h.

229  {
230  m_inner->set_persistent(p);
231  }

Referenced by tpie::ami::stack< item_type >::persist(), and tpie::ami::stream_old< T >::persist().


The documentation for this class was generated from the following file:
tpie::temp_file::path
const std::string & path()
Get the path of the associated file.
Definition: tempname.h:243