An interface for simple binary IO. More...
#include <basicio.hpp>
Public Types | |
enum | Position { beg, cur, end } |
Seek starting positions. | |
typedef std::auto_ptr< BasicIo > | AutoPtr |
BasicIo auto_ptr type. | |
Public Member Functions | |
Manipulators | |
virtual int | open ()=0 |
Open the IO source using the default access mode. The default mode should allow for reading and writing. More... | |
virtual int | close ()=0 |
Close the IO source. After closing a BasicIo instance can not be read or written. Closing flushes any unwritten data. It is safe to call close on a closed instance. More... | |
virtual long | write (const byte *data, long wcount)=0 |
Write data to the IO source. Current IO position is advanced by the number of bytes written. More... | |
virtual long | write (BasicIo &src)=0 |
Write data that is read from another BasicIo instance to the IO source. Current IO position is advanced by the number of bytes written. More... | |
virtual int | putb (byte data)=0 |
Write one byte to the IO source. Current IO position is advanced by one byte. More... | |
virtual DataBuf | read (long rcount)=0 |
Read data from the IO source. Reading starts at the current IO position and the position is advanced by the number of bytes read. More... | |
virtual long | read (byte *buf, long rcount)=0 |
Read data from the IO source. Reading starts at the current IO position and the position is advanced by the number of bytes read. More... | |
virtual int | getb ()=0 |
Read one byte from the IO source. Current IO position is advanced by one byte. More... | |
virtual void | transfer (BasicIo &src)=0 |
Remove all data from this object's IO source and then transfer data from the src BasicIo object into this object. More... | |
virtual int | seek (long offset, Position pos)=0 |
Move the current IO position. More... | |
virtual byte * | mmap (bool isWriteable=false)=0 |
Direct access to the IO data. For files, this is done by mapping the file into the process's address space; for memory blocks, this allows direct access to the memory block. More... | |
virtual int | munmap ()=0 |
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes are written back. More... | |
Creators | |
virtual | ~BasicIo () |
Destructor. | |
BasicIo () | |
Default Constructor. | |
Accessors | |
byte * | bigBlock_ |
this is allocated and populated by mmap() | |
virtual long | tell () const =0 |
Get the current IO position. More... | |
virtual size_t | size () const =0 |
Get the current size of the IO source in bytes. More... | |
virtual bool | isopen () const =0 |
Returns true if the IO source is open, otherwise false. | |
virtual int | error () const =0 |
Returns 0 if the IO source is in a valid state, otherwise nonzero. | |
virtual bool | eof () const =0 |
Returns true if the IO position has reached the end, otherwise false. | |
virtual std::string | path () const =0 |
Return the path to the IO resource. Often used to form comprehensive error messages where only a BasicIo instance is available. | |
virtual void | populateFakeData () |
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain image-date (non-metadata/pixel data) More... | |
An interface for simple binary IO.
Designed to have semantics and names similar to those of C style FILE* operations. Subclasses should all behave the same so that they can be interchanged.
|
pure virtual |
Close the IO source. After closing a BasicIo instance can not be read or written. Closing flushes any unwritten data. It is safe to call close on a closed instance.
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Read one byte from the IO source. Current IO position is advanced by one byte.
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Direct access to the IO data. For files, this is done by mapping the file into the process's address space; for memory blocks, this allows direct access to the memory block.
isWriteable | Set to true if the mapped area should be writeable (default is false). |
Error | In case of failure. |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes are written back.
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Open the IO source using the default access mode. The default mode should allow for reading and writing.
This method can also be used to "reopen" an IO source which will flush any unwritten data and reset the IO position to the start. Subclasses may provide custom methods to allow for opening IO sources differently.
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
inlinevirtual |
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain image-date (non-metadata/pixel data)
Reimplemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Write one byte to the IO source. Current IO position is advanced by one byte.
data | The single byte to be written. |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Read data from the IO source. Reading starts at the current IO position and the position is advanced by the number of bytes read.
buf | Pointer to a block of memory into which the read data is stored. The memory block must be at least rcount bytes long. |
rcount | Maximum number of bytes to read. Fewer bytes may be read if rcount bytes are not available. |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Read data from the IO source. Reading starts at the current IO position and the position is advanced by the number of bytes read.
rcount | Maximum number of bytes to read. Fewer bytes may be read if rcount bytes are not available. |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Move the current IO position.
offset | Number of bytes to move the position relative to the starting position specified by pos |
pos | Position from which the seek should start |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Get the current size of the IO source in bytes.
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Get the current IO position.
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Remove all data from this object's IO source and then transfer data from the src BasicIo object into this object.
The source object is invalidated by this operation and should not be used after this method returns. This method exists primarily to be used with the BasicIo::temporary() method.
src | Reference to another BasicIo instance. The entire contents of src are transferred to this object. The src object is invalidated by the method. |
Error | In case of failure |
Implemented in Exiv2::RemoteIo, Exiv2::XPathIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Write data that is read from another BasicIo instance to the IO source. Current IO position is advanced by the number of bytes written.
src | Reference to another BasicIo instance. Reading start at the source's current IO position |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.
|
pure virtual |
Write data to the IO source. Current IO position is advanced by the number of bytes written.
data | Pointer to data. Data must be at least wcount bytes long |
wcount | Number of bytes to be written. |
Implemented in Exiv2::RemoteIo, Exiv2::MemIo, and Exiv2::FileIo.