Loading...
Searching...
No Matches
Exiv2::RemoteIo Class Reference

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>`

Inheritance diagram for Exiv2::RemoteIo:
[legend]

## 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.
Public Member Functions inherited from Exiv2::BasicIo
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

Public Types inherited from Exiv2::BasicIo
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()

## Detailed Description

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.

## Member Function Documentation

## close()

int Exiv2::RemoteIo::close | ( |  | ) |

override virtual

Reset the IO position to the start. It does not release the data.

Returns
  0 if successful;
  Nonzero if failure.

Implements Exiv2::BasicIo.

References Exiv2::BasicIo::bigBlock_, and p_.

Referenced by open(), and RemoteIo().

## eof()

bool Exiv2::RemoteIo::eof | ( |  | ) | const

nodiscard override virtual

Returns true if the IO position has reached the end, otherwise false.

Implements Exiv2::BasicIo.

References p_.

Referenced by RemoteIo().

## error()

int Exiv2::RemoteIo::error | ( |  | ) | const

nodiscard override virtual

Always returns 0.

Implements Exiv2::BasicIo.

Referenced by RemoteIo().

## getb()

int Exiv2::RemoteIo::getb | ( |  | ) |

override virtual

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.

References p_.

Referenced by RemoteIo().

## isopen()

bool Exiv2::RemoteIo::isopen | ( |  | ) | const

nodiscard override virtual

Returns true if the memory area is allocated.

Implements Exiv2::BasicIo.

References p_.

Referenced by RemoteIo().

## mmap()

byte * Exiv2::RemoteIo::mmap | ( | bool | = false | ) |

override virtual

Not support.

Returns
  NULL

Implements Exiv2::BasicIo.

References Exiv2::BasicIo::bigBlock_, and p_.

Referenced by RemoteIo().

## munmap()

int Exiv2::RemoteIo::munmap | ( |  | ) |

override virtual

Not support.

Returns
  0

Implements Exiv2::BasicIo.

Referenced by RemoteIo().

## open()

int Exiv2::RemoteIo::open | ( |  | ) |

override virtual

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.

References Exiv2::BasicIo::bigBlock_, close(), and p_.

Referenced by RemoteIo().

## path()

const std::string & Exiv2::RemoteIo::path | ( |  | ) | const

nodiscard override virtual noexcept

Returns the URL of the file.

Implements Exiv2::BasicIo.

References p_.

Referenced by RemoteIo().

## populateFakeData()

void Exiv2::RemoteIo::populateFakeData | ( |  | ) |

override virtual

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.

References p_.

Referenced by RemoteIo().

## putb()

int Exiv2::RemoteIo::putb | ( | byte | data | ) |

override virtual

Not support.

Returns
  0 means failure

Implements Exiv2::BasicIo.

Referenced by RemoteIo().

## read() [1/2]

size_t Exiv2::RemoteIo::read | ( | byte * | buf,
|  | size_t | rcount )

override virtual

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.

References p_.

## read() [2/2]

DataBuf Exiv2::RemoteIo::read | ( | size_t | rcount | ) |

override virtual

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.

References Exiv2::DataBuf::data(), read(), and Exiv2::DataBuf::resize().

Referenced by read(), and RemoteIo().

## seek()

int Exiv2::RemoteIo::seek | ( | int64_t | offset,
|  | Position | pos )

override virtual

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.

References p_.

Referenced by RemoteIo().

## size()

size_t Exiv2::RemoteIo::size | ( |  | ) | const

nodiscard override virtual

Get the current memory buffer size in bytes.

Returns
  Size of the in memory data in bytes;
  -1 if failure;

Implements Exiv2::BasicIo.

References p_.

Referenced by RemoteIo(), and Exiv2::RemoteIo::Impl::writeRemote().

## tell()

size_t Exiv2::RemoteIo::tell | ( |  | ) | const

nodiscard override virtual

Get the current IO position.

Returns
  Offset from the start of the memory block

Implements Exiv2::BasicIo.

References p_.

Referenced by RemoteIo().

## transfer()

void Exiv2::RemoteIo::transfer | ( | BasicIo & | src | ) |

override virtual

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

  Error | In case of failure

Note
  The write access is only supported by http, https, ssh.

Implements Exiv2::BasicIo.

References Exiv2::BasicIo::close(), Exiv2::BasicIo::open(), and write().

Referenced by RemoteIo().

## write() [1/2]

size_t Exiv2::RemoteIo::write | ( | BasicIo & | src | ) |

override virtual

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

  Error | In case of failure

Note
  The write access is only supported by http, https, ssh.

Implements Exiv2::BasicIo.

References Exiv2::BasicIo::eof(), Exiv2::BasicIo::isopen(), p_, Exiv2::BasicIo::read(), Exiv2::BasicIo::seek(), and Exiv2::BasicIo::size().

## write() [2/2]

size_t Exiv2::RemoteIo::write | ( | const byte * | data,
|  | size_t | wcount )

override virtual

Not support this method.

Returns
  0 means failure

Implements Exiv2::BasicIo.

Referenced by RemoteIo(), and transfer().

The documentation for this class was generated from the following files:

- basicio.hpp
- basicio.cpp