Provides binary IO for the data from stdin and data uri path.
More...
#include <basicio.hpp>
|
| RemoteIo () |
| Destructor. Releases all managed memory.
|
|
| RemoteIo (const RemoteIo &)=delete |
|
RemoteIo & | operator= (const RemoteIo &)=delete |
|
|
int | open () override |
| Connect to the remote server, get the size of the remote file and allocate the array of blocksMap. More...
|
|
int | close () override |
| Reset the IO position to the start. It does not release the data. More...
|
|
size_t | write (const byte *data, size_t wcount) override |
| Not support this method. More...
|
|
size_t | write (BasicIo &src) override |
| Write data that is read from another BasicIo instance to the remote file. More...
|
|
int | putb (byte data) override |
| Not support. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
void | transfer (BasicIo &src) override |
| Remove the contents of the file and then transfer data from the src BasicIo object into the empty file. More...
|
|
int | seek (int64_t offset, Position pos) override |
| Move the current IO position. More...
|
|
byte * | mmap (bool=false) override |
| Not support. More...
|
|
int | munmap () override |
| Not support. More...
|
|
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. More...
|
|
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. More...
|
|
|
std::unique_ptr< Impl > | p_ |
| Pointer to implementation.
|
|
size_t | tell () const override |
| Get the current IO position. More...
|
|
size_t | size () const override |
| Get the current memory buffer size in bytes. More...
|
|
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) More...
|
|
Provides binary IO for the data from stdin and data uri path.
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.
◆ close()
int Exiv2::RemoteIo::close |
( |
| ) |
|
|
overridevirtual |
Reset the IO position to the start. It does not release the data.
- Returns
- 0 if successful;
Nonzero if failure.
Implements Exiv2::BasicIo.
◆ getb()
int Exiv2::RemoteIo::getb |
( |
| ) |
|
|
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.
- Returns
- The byte read from the memory block if successful;
EOF if failure;
Implements Exiv2::BasicIo.
◆ mmap()
byte* Exiv2::RemoteIo::mmap |
( |
bool |
= false | ) |
|
|
overridevirtual |
◆ munmap()
int Exiv2::RemoteIo::munmap |
( |
| ) |
|
|
overridevirtual |
◆ open()
int Exiv2::RemoteIo::open |
( |
| ) |
|
|
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.
- Returns
- 0 if successful;
Nonzero if failure.
Implements Exiv2::BasicIo.
◆ populateFakeData()
void Exiv2::RemoteIo::populateFakeData |
( |
| ) |
|
|
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)
- Note
- This method should be only called after the concerned data (metadata) are all downloaded from the remote file to memory.
Implements Exiv2::BasicIo.
◆ putb()
int Exiv2::RemoteIo::putb |
( |
byte |
data | ) |
|
|
overridevirtual |
◆ read() [1/2]
size_t Exiv2::RemoteIo::read |
( |
byte * |
buf, |
|
|
size_t |
rcount |
|
) |
| |
|
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.
- Parameters
-
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. |
- Returns
- Number of bytes read from the memory block successfully;
0 if failure;
Implements Exiv2::BasicIo.
◆ read() [2/2]
DataBuf Exiv2::RemoteIo::read |
( |
size_t |
rcount | ) |
|
|
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.
- Parameters
-
rcount | Maximum number of bytes to read. Fewer bytes may be read if rcount bytes are not available. |
- Returns
- DataBuf instance containing the bytes read. Use the DataBuf::size_ member to find the number of bytes read. DataBuf::size_ will be 0 on failure.
Implements Exiv2::BasicIo.
◆ seek()
int Exiv2::RemoteIo::seek |
( |
int64_t |
offset, |
|
|
Position |
pos |
|
) |
| |
|
overridevirtual |
Move the current IO position.
- Parameters
-
offset | Number of bytes to move the position relative to the starting position specified by pos |
pos | Position from which the seek should start |
- Returns
- 0 if successful;
Nonzero if failure;
Implements Exiv2::BasicIo.
◆ size()
size_t Exiv2::RemoteIo::size |
( |
| ) |
const |
|
overridevirtual |
Get the current memory buffer size in bytes.
- Returns
- Size of the in memory data in bytes;
-1 if failure;
Implements Exiv2::BasicIo.
◆ tell()
size_t Exiv2::RemoteIo::tell |
( |
| ) |
const |
|
overridevirtual |
Get the current IO position.
- Returns
- Offset from the start of the memory block
Implements Exiv2::BasicIo.
◆ transfer()
void Exiv2::RemoteIo::transfer |
( |
BasicIo & |
src | ) |
|
|
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.
- Parameters
-
src | Reference to another BasicIo instance. The entire contents of src are transferred to this object. The src object is invalidated by the method. |
- Exceptions
-
- Note
- The write access is only supported by http, https, ssh.
Implements Exiv2::BasicIo.
◆ write() [1/2]
size_t Exiv2::RemoteIo::write |
( |
BasicIo & |
src | ) |
|
|
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.
- Parameters
-
src | Reference to another BasicIo instance. Reading start at the source's current IO position |
- Returns
- The size of BasicIo instance;
0 if failure;
- Exceptions
-
- Note
- The write access is only supported by http, https, ssh.
Implements Exiv2::BasicIo.
◆ write() [2/2]
size_t Exiv2::RemoteIo::write |
( |
const byte * |
data, |
|
|
size_t |
wcount |
|
) |
| |
|
overridevirtual |
Not support this method.
- Returns
- 0 means failure
Implements Exiv2::BasicIo.
The documentation for this class was generated from the following file: