DWFCore::DWFTempFile Class Reference
[Platform-specific Class and Function Definitions]

#include "dwfcore/TempFile.h"

Inheritance diagram for DWFCore::DWFTempFile:

Inheritance graph
[legend]
Collaboration diagram for DWFCore::DWFTempFile:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class provides a simple, platform-independent mechanism for creating, using and managing temporary disk files.

Since:
1.0.1
Note:
This class has platform-specific implementations.
Examples:

Files/Files.cpp.

Definition at line 51 of file TempFile.h.

Public Member Functions

virtual _DWFCORE_API ~DWFTempFile () throw ()
_DWFCORE_API DWFFileOutputStreamgetOutputStream () throw ( DWFException )
_DWFCORE_API DWFFileInputStreamgetInputStream () throw ( DWFException )

Static Public Member Functions

static _DWFCORE_API DWFTempFileCreate (DWFString &zTemplate, bool bDeleteOnDestroy) throw ( DWFException )


Constructor & Destructor Documentation

virtual _DWFCORE_API DWFCore::DWFTempFile::~DWFTempFile  )  throw () [virtual]
 

Destructor

This method will delete the disk file if the object was created with bDeleteOnDestroy set to true.

Exceptions:
None 


Member Function Documentation

static _DWFCORE_API DWFTempFile* DWFCore::DWFTempFile::Create DWFString zTemplate,
bool  bDeleteOnDestroy
throw ( DWFException ) [static]
 

Create and open a new temporary file.

Parameters:
zTemplate An optional string that wil be used in the temporary filename.
bDeleteOnDestroy If true, the disk file associated with the new object will be deleted when it is deleted. If false, the temporary file will be left on disk. The filename can be obtained from the descriptor - see getOutputStream().
Returns:
A pointer to a new temporary file object. This pointer must be deleted by the caller using the DWFCORE_FREE_OBJECT macro.
Exceptions:
DWFException 

_DWFCORE_API DWFFileInputStream* DWFCore::DWFTempFile::getInputStream  )  throw ( DWFException )
 

Returns a stream that can be used to read data from the disk file. This stream will have shared read-access on the file and the caller is reponsible for deleting this stream pointer with the DWFCORE_FREE_OBJECT macro.

Note:
One of these streams can be used to obtain the actual disk filename - see getOutputStream().
Returns:
A pointer to a new read stream. Any number of this streams may exists simultaneously.
Exceptions:
DWFException 

_DWFCORE_API DWFFileOutputStream& DWFCore::DWFTempFile::getOutputStream  )  throw ( DWFException )
 

Returns a stream that can be used to write data into the disk file. In some cases (the file is not deleted from disk) it may be necessary to obtain the disk file information. This data is stored in the DWFFile object associated with the DWFFileDescriptor to which this stream is bound.

Example - Recover the filename of the temporary file on disk:

                    //
                    // Acquire the stream from the object.
                    // The descriptor is available from this stream.
                    //
                    // NOTE: We could use an input stream here as well!
                    //       It just depends on the state of the DWFTempFile object
                    //       and what we have access to when we need to obtain this info.
                    //
                    DWFFileOutputStream& rTempStream = pTempFile->getOutputStream();
       
                    //
                    // the file descriptor has the DWFFile object we need
                    //
                    DWFFileDescriptor* pTempDescriptor = rTempStream.descriptor();
       
                    //
                    // the file object has the useful information
                    //
                    const DWFFile& rTempFileObj = pTempDescriptor->file();
       
                    //
                    // copy the filename down for later...
                    //
                    DWFString zTempFilename = rTempFileObj.name();

Returns:
A reference to the only stream available for writing data into the temporary file.
Exceptions:
DWFException 
Examples:
Files/Files.cpp.


The documentation for this class was generated from the following file:
Generated on Tue Jan 6 22:39:42 2009 for Autodesk DWF Core Library by  doxygen 1.4.5