XMP Toolkit SDK  6.0.0
XMP_IO.hpp
Go to the documentation of this file.
1 #ifndef __XMP_IO_hpp__
2 #define __XMP_IO_hpp__ 1
3 
4 // =================================================================================================
5 // Copyright Adobe
6 // Copyright 2010 Adobe
7 // All Rights Reserved
8 //
9 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
10 // of the Adobe license agreement accompanying it. If you have received this file from a source other
11 // than Adobe, then your use, modification, or distribution of it requires the prior written permission
12 // of Adobe.
13 // =================================================================================================
14 
15 #include "XMP_Environment.h" // ! XMP_Environment.h must be the first included header.
16 
17 #include "XMP_Const.h"
18 
19 // =================================================================================================
42 // =================================================================================================
43 
44 class XMP_IO {
45 public:
46  enum { kReadAll = true };
47  // ---------------------------------------------------------------------------------------------
60 
61  virtual XMP_Uns32 Read ( void* buffer, XMP_Uns32 count, bool readAll = false ) = 0;
62 
63  inline XMP_Uns32 ReadAll ( void* buffer, XMP_Uns32 bytes )
64  { return this->Read ( buffer, bytes, kReadAll ); };
65 
66  // ---------------------------------------------------------------------------------------------
74 
75  virtual void Write ( const void* buffer, XMP_Uns32 count ) = 0;
76 
77  // ---------------------------------------------------------------------------------------------
89 
90  virtual XMP_Int64 Seek ( XMP_Int64 offset, SeekMode mode ) = 0;
91 
92  inline XMP_Int64 Offset() { return this->Seek ( 0, kXMP_SeekFromCurrent ); };
93  inline XMP_Int64 Rewind() { return this->Seek ( 0, kXMP_SeekFromStart ); }; // Always returns 0.
94  inline XMP_Int64 ToEOF() { return this->Seek ( 0, kXMP_SeekFromEnd ); };
95 
96  // ---------------------------------------------------------------------------------------------
102 
103  virtual XMP_Int64 Length() = 0;
104 
105  // ---------------------------------------------------------------------------------------------
113 
114  virtual void Truncate ( XMP_Int64 length ) = 0;
115 
116  // ---------------------------------------------------------------------------------------------
133 
134  virtual XMP_IO* DeriveTemp() = 0;
135 
136  // ---------------------------------------------------------------------------------------------
143 
144  virtual void AbsorbTemp() = 0;
145 
146  // ---------------------------------------------------------------------------------------------
152 
153  virtual void DeleteTemp() = 0;
154 
155  // ---------------------------------------------------------------------------------------------
156 
157  XMP_IO() {};
158  virtual ~XMP_IO() {};
159 
160 private:
161 
162  // ---------------------------------------------------------------------------------------------
165 
166  XMP_IO ( const XMP_IO & original );
167  void operator= ( const XMP_IO& ) { /* Avoid Win compile warnings. */ };
168 
169 };
170 
171 #endif // __XMP_IO_hpp__
XMP_IO::ToEOF
XMP_Int64 ToEOF()
Definition: XMP_IO.hpp:94
XMP_IO::Length
virtual XMP_Int64 Length()=0
Return the length of the file in bytes.
XMP_IO::Rewind
XMP_Int64 Rewind()
Definition: XMP_IO.hpp:93
XMP_IO::ReadAll
XMP_Uns32 ReadAll(void *buffer, XMP_Uns32 bytes)
Definition: XMP_IO.hpp:63
kXMP_SeekFromEnd
@ kXMP_SeekFromEnd
Definition: XMP_Const.h:876
kXMP_SeekFromCurrent
@ kXMP_SeekFromCurrent
Definition: XMP_Const.h:876
XMP_Const.h
Common C/C++ types and constants for the XMP toolkit.
SeekMode
SeekMode
Seek mode constants for use with XMP_IO and inside XMPFiles library code.
Definition: XMP_Const.h:876
XMP_Environment.h
XMP_IO::operator=
void operator=(const XMP_IO &)
Definition: XMP_IO.hpp:167
XMP_IO::XMP_IO
XMP_IO()
Definition: XMP_IO.hpp:157
XMP_IO::~XMP_IO
virtual ~XMP_IO()
Definition: XMP_IO.hpp:158
XMP_IO::Truncate
virtual void Truncate(XMP_Int64 length)=0
Truncate the file to the given length.
XMP_IO::AbsorbTemp
virtual void AbsorbTemp()=0
Replace the owning file's content with that of the temp.
XMP_IO
Abstract base class for client-managed I/O with TXMPFiles.
Definition: XMP_IO.hpp:44
XMP_IO::DeleteTemp
virtual void DeleteTemp()=0
Delete a temp file, leaving the original alone.
XMP_IO::kReadAll
@ kReadAll
Definition: XMP_IO.hpp:46
XMP_IO::DeriveTemp
virtual XMP_IO * DeriveTemp()=0
Create an associated temp file for use in a safe-save style operation.
XMP_IO::Offset
XMP_Int64 Offset()
Definition: XMP_IO.hpp:92
XMP_IO::Write
virtual void Write(const void *buffer, XMP_Uns32 count)=0
Write from a buffer.
XMP_IO::Seek
virtual XMP_Int64 Seek(XMP_Int64 offset, SeekMode mode)=0
Set the I/O position, returning the new absolute offset in bytes.
kXMP_SeekFromStart
@ kXMP_SeekFromStart
Definition: XMP_Const.h:876
XMP_IO::Read
virtual XMP_Uns32 Read(void *buffer, XMP_Uns32 count, bool readAll=false)=0
Read into a buffer, returning the number of bytes read.