|
virtual XMP_Uns32 | Read (void *buffer, XMP_Uns32 count, bool readAll=false)=0 |
| Read into a buffer, returning the number of bytes read. More...
|
|
XMP_Uns32 | ReadAll (void *buffer, XMP_Uns32 bytes) |
|
virtual void | Write (const void *buffer, XMP_Uns32 count)=0 |
| Write from a buffer. More...
|
|
virtual XMP_Int64 | Seek (XMP_Int64 offset, SeekMode mode)=0 |
| Set the I/O position, returning the new absolute offset in bytes. More...
|
|
XMP_Int64 | Offset () |
|
XMP_Int64 | Rewind () |
|
XMP_Int64 | ToEOF () |
|
virtual XMP_Int64 | Length ()=0 |
| Return the length of the file in bytes. More...
|
|
virtual void | Truncate (XMP_Int64 length)=0 |
| Truncate the file to the given length. More...
|
|
virtual XMP_IO * | DeriveTemp ()=0 |
| Create an associated temp file for use in a safe-save style operation. More...
|
|
virtual void | AbsorbTemp ()=0 |
| Replace the owning file's content with that of the temp. More...
|
|
virtual void | DeleteTemp ()=0 |
| Delete a temp file, leaving the original alone. More...
|
|
| XMP_IO () |
|
virtual | ~XMP_IO () |
|
Abstract base class for client-managed I/O with TXMPFiles
.
XMP_IO
is an abstract base class for client-managed I/O with TXMPFiles
. This allows a client to use the embedded metadata processing logic of TXMPFiles
in cases where a string file path cannot be provided, or where it is impractical to allow TXMPFiles
to separately open the file and do its own I/O. Although described in terms of files, any form of storage may be used as long as the functions operate as defined.
This is not a general purpose I/O class. It contains only the necessary functions needed by the internals of TXMPFiles
. It is intended to be used as an adaptor for an existing I/O mechanism that the client wants TXMPFiles
to use.
To use XMP_IO
, a client creates a derived class then uses the form of TCMPFiles::OpenFile
that takes an XMP_IO
parameter instead of a string file path. The derived XMP_IO
object must be ready for use when TCMPFiles::OpenFile
is called.
There are no Open or Close functions in XMP_IO
, they are specific to each implementation. The derived XMP_IO
object must be open and ready for use before being passed to TXMP_Files::OpenFile
, and remain open and ready for use until TXMP_Files::CloseFile
returns, or some other fatal error occurs. The client has final responsibility for closing and terminating the derived XMP_IO
object.
Definition at line 44 of file XMP_IO.hpp.
virtual XMP_IO* XMP_IO::DeriveTemp |
( |
| ) |
|
|
pure virtual |
Create an associated temp file for use in a safe-save style operation.
Create an associated temp file, for example in the same directory and with a related name. Returns an already existing temp with no other action. The temp must be opened for read-write access. It will be used in a safe-save style operation, using some of the original file plus new portions to write the temp, then replacing the original from the temp when done. Throws an exception if the owning object is opened for read-only access, or if the temp file cannot be created. Throwing XMPError
is recommended.
The temp file is normally closed and deleted, and the temporary XMP_IO
object deleted, by a call to AbsorbTemp
or DeleteTemp
. It must be closed and deleted by the derived XMP_IO
object's destructor if necessary.
DeriveTemp
may be called on a temporary XMP_IO
object.
- Returns
- A pointer to the associated temporary
XMP_IO
object.
virtual XMP_Int64 XMP_IO::Seek |
( |
XMP_Int64 |
offset, |
|
|
SeekMode |
mode |
|
) |
| |
|
pure virtual |
Set the I/O position, returning the new absolute offset in bytes.
Set the I/O position, returning the new absolute offset in bytes. The offset parameter may be positive or negative. A seek beyond EOF is allowed when writing and extends the file, it is equivalent to seeking to EOF then writing the needed amount of undefined data. A read-only seek beyond EOF throws an exception. Throwing XMPError
is recommended.
- Parameters
-
offset | The offset relative to the mode. |
mode | The mode, or origin, of the seek. |
- Returns
- The new absolute offset in bytes.
Referenced by Offset(), Rewind(), and ToEOF().