![]() |
Exiv2
|
Provides remote binary file IO by implementing the BasicIo interface. This is an abstract class. The logics for remote access are implemented in HttpIo, CurlIo, SshIo which are the derived classes of RemoteIo. More...
#include <basicio.hpp>
Classes | |
class | Impl |
Internal Pimpl abstract structure of class RemoteIo. More... | |
Public Member Functions | |
RemoteIo () | |
Destructor. Releases all managed memory. | |
RemoteIo (const RemoteIo &)=delete | |
RemoteIo & | operator= (const RemoteIo &)=delete |
Manipulators | |
int | open () override |
Connect to the remote server, get the size of the remote file and allocate the array of blocksMap. | |
int | close () override |
Reset the IO position to the start. It does not release the data. | |
size_t | write (const byte *data, size_t wcount) override |
Not support this method. | |
size_t | write (BasicIo &src) override |
Write data that is read from another BasicIo instance to the remote file. | |
int | putb (byte data) override |
Not support. | |
DataBuf | read (size_t rcount) override |
Read data from the memory blocks. Reading starts at the current IO position and the position is advanced by the number of bytes read. If the memory blocks are not populated (False), it will connect to server and populate the data to memory blocks. | |
size_t | read (byte *buf, size_t rcount) override |
Read data from the memory blocks. Reading starts at the current IO position and the position is advanced by the number of bytes read. If the memory blocks are not populated (!= bMemory), it will connect to server and populate the data to memory blocks. | |
int | getb () override |
Read one byte from the memory blocks. The IO position is advanced by one byte. If the memory block is not populated (!= bMemory), it will connect to server and populate the data to the memory block. | |
void | transfer (BasicIo &src) override |
Remove the contents of the file and then transfer data from the src BasicIo object into the empty file. | |
int | seek (int64_t offset, Position pos) override |
Move the current IO position. | |
byte * | mmap (bool=false) override |
Not support. | |
int | munmap () override |
Not support. | |
![]() | |
virtual | ~BasicIo ()=default |
Destructor. | |
void | readOrThrow (byte *buf, size_t rcount, ErrorCode err=ErrorCode::kerCorruptedMetadata) |
Safe version of read() that checks for errors and throws an exception if the read was unsuccessful. | |
void | seekOrThrow (int64_t offset, Position pos, ErrorCode err) |
Safe version of seek() that checks for errors and throws an exception if the seek was unsuccessful. | |
Accessors | |
std::unique_ptr< Impl > | p_ |
Pointer to implementation. | |
size_t | tell () const override |
Get the current IO position. | |
size_t | size () const override |
Get the current memory buffer size in bytes. | |
bool | isopen () const override |
Returns true if the memory area is allocated. | |
int | error () const override |
Always returns 0. | |
bool | eof () const override |
Returns true if the IO position has reached the end, otherwise false. | |
const std::string & | path () const noexcept override |
Returns the URL of the file. | |
void | populateFakeData () override |
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain image-date (non-metadata/pixel data) | |
Additional Inherited Members | |
![]() | |
enum | Position { beg , cur , end } |
Seek starting positions. | |
using | UniquePtr = std::unique_ptr< BasicIo > |
BasicIo auto_ptr type. | |
![]() | |
byte * | bigBlock_ {} |
this is allocated and populated by mmap() | |
Provides remote binary file IO by implementing the BasicIo interface. This is an abstract class. The logics for remote access are implemented in HttpIo, CurlIo, SshIo which are the derived classes of RemoteIo.
|
overridevirtual |
Reset the IO position to the start. It does not release the data.
Implements Exiv2::BasicIo.
References Exiv2::BasicIo::bigBlock_, and p_.
Referenced by open().
|
overridevirtual |
Returns true if the IO position has reached the end, otherwise false.
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
Always returns 0.
Implements Exiv2::BasicIo.
|
overridevirtual |
Read one byte from the memory blocks. The IO position is advanced by one byte. If the memory block is not populated (!= bMemory), it will connect to server and populate the data to the memory block.
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Connect to the remote server, get the size of the remote file and allocate the array of blocksMap.
If the blocksMap is already allocated (this method has been called before), it just reset IO position to the start and does not flush the old data.
Implements Exiv2::BasicIo.
References Exiv2::BasicIo::bigBlock_, close(), and p_.
|
overridevirtualnoexcept |
|
overridevirtual |
Mark all the bNone blocks to bKnow. This avoids allocating memory for parts of the file that contain image-date (non-metadata/pixel data)
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
|
overridevirtual |
Read data from the memory blocks. Reading starts at the current IO position and the position is advanced by the number of bytes read. If the memory blocks are not populated (!= bMemory), it will connect to server and populate the data to memory blocks.
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. |
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
Read data from the memory blocks. Reading starts at the current IO position and the position is advanced by the number of bytes read. If the memory blocks are not populated (False), it will connect to server and populate the data to memory blocks.
rcount | Maximum number of bytes to read. Fewer bytes may be read if rcount bytes are not available. |
Implements Exiv2::BasicIo.
References Exiv2::DataBuf::data(), read(), and Exiv2::DataBuf::resize().
Referenced by read().
|
overridevirtual |
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 |
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
Get the current memory buffer size in bytes.
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
Get the current IO position.
Implements Exiv2::BasicIo.
References p_.
|
overridevirtual |
Remove the contents of the file and then transfer data from the src BasicIo object into the empty file.
The write access is done in an efficient way. It only sends the range of different bytes between the current data and BasicIo instance to the remote machine.
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 |
Implements Exiv2::BasicIo.
References Exiv2::BasicIo::close(), Exiv2::BasicIo::open(), and write().
|
overridevirtual |
Write data that is read from another BasicIo instance to the remote file.
The write access is done in an efficient way. It only sends the range of different bytes between the current data and BasicIo instance to the remote machine.
src | Reference to another BasicIo instance. Reading start at the source's current IO position |
Error | In case of failure |
Implements Exiv2::BasicIo.
References Exiv2::BasicIo::eof(), Exiv2::BasicIo::isopen(), p_, Exiv2::BasicIo::read(), Exiv2::BasicIo::seek(), and Exiv2::BasicIo::size().
|
overridevirtual |
Not support this method.
Implements Exiv2::BasicIo.
Referenced by transfer().