TPIE

2362a60
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 202 of file tempname.h.

Constructor & Destructor Documentation

tpie::temp_file::temp_file ( )
inline

Create a temp_file associated with a temporary file.

Definition at line 207 of file tempname.h.

207  {
208  m_inner = new bits::temp_file_inner();
209  }
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 214 of file tempname.h.

214  {
215  m_inner = new bits::temp_file_inner(path, persist);
216  }
const std::string & path()
Get the path of the associated file.
Definition: tempname.h:244

Member Function Documentation

void tpie::temp_file::free ( )
inline

Clears the current object reference.

Definition at line 251 of file tempname.h.

251  {
252  m_inner = new bits::temp_file_inner();
253  }
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 222 of file tempname.h.

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

222  {
223  return m_inner->is_persistent();
224  }
const std::string& tpie::temp_file::path ( )
inline

Get the path of the associated file.

Definition at line 244 of file tempname.h.

Referenced by tpie::file_base_crtp< file_stream_base >::open(), and tpie::ami::stream_old< T >::stream_old().

244  {
245  return m_inner->path();
246  }
void tpie::temp_file::set_path ( const std::string &  path,
bool  persist = false 
)
inline

Associate with a specific file.

Definition at line 237 of file tempname.h.

237  {
238  m_inner = new bits::temp_file_inner(path, persist);
239  }
const std::string & path()
Get the path of the associated file.
Definition: tempname.h:244
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 230 of file tempname.h.

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

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

The documentation for this class was generated from the following file: