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

virtual | ~RemoteIo ()
| Destructor. Releases all managed memory.
Manipulators
virtual int | open ()
| Connect to the remote server, get the size of the remote file and allocate the array of blocksMap.
virtual int | close ()
| Reset the IO position to the start. It does not release the data.
virtual long | write (const byte *data, long wcount)
| Not support this method.
virtual long | write (BasicIo &src)
| Write data that is read from another BasicIo instance to the remote file.
virtual int | putb (byte data)
| Not support.
virtual DataBuf | read (long rcount)
| 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.
virtual long | read (byte *buf, long rcount)
| Read data from the 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.
virtual int | getb ()
| 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.
virtual void | transfer (BasicIo &src)
| Remove the contents of the file and then transfer data from the src BasicIo object into the empty file.
virtual int | seek (long offset, Position pos)
| Move the current IO position.
virtual byte * | mmap (bool=false)
| Not support.
virtual int | munmap ()
| Not support.
Accessors
virtual long | tell () const
| Get the current IO position.
virtual size_t | size () const
| Get the current memory buffer size in bytes.
virtual bool | isopen () const
| Returns true if the memory area is allocated.
virtual int | error () const
| Always returns 0.
virtual bool | eof () const
| Returns true if the IO position has reached the end, otherwise false.
virtual std::string | path () const
| Returns the URL of the file.
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)
Public Member Functions inherited from Exiv2::BasicIo
virtual | ~BasicIo ()
| Destructor.

## Creators

Impl * | p_
| Pointer to implementation.
| RemoteIo ()
| Default Constructor.

## Additional Inherited Members

Public Types inherited from Exiv2::BasicIo
enum | Position { beg , cur , end }
| Seek starting positions.
typedef std::auto_ptr< BasicIo > | AutoPtr
| BasicIo auto_ptr type.
Public Attributes inherited from Exiv2::BasicIo
byte * | bigBlock_
| this is allocated and populated by mmap()
Protected Member Functions inherited from Exiv2::BasicIo
| BasicIo ()
| Default Constructor.

## 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 | ( |  | ) |

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_, Exiv2::RemoteIo::Impl::eof_, Exiv2::RemoteIo::Impl::idx_, Exiv2::RemoteIo::Impl::isMalloced_, p_, and Exiv2::RemoteIo::Impl::totalRead_.

Referenced by open(), and ~RemoteIo().

## eof()

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

virtual

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

Implements Exiv2::BasicIo.

References Exiv2::RemoteIo::Impl::eof_, and p_.

## error()

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

virtual

Always returns 0.

Implements Exiv2::BasicIo.

## getb()

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

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 Exiv2::RemoteIo::Impl::blockSize_, Exiv2::RemoteIo::Impl::blocksMap_, Exiv2::RemoteIo::Impl::eof_, Exiv2::RemoteIo::Impl::idx_, Exiv2::RemoteIo::Impl::isMalloced_, p_, Exiv2::RemoteIo::Impl::populateBlocks(), and Exiv2::RemoteIo::Impl::size_.

## isopen()

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

virtual

Returns true if the memory area is allocated.

Implements Exiv2::BasicIo.

References Exiv2::RemoteIo::Impl::isMalloced_, and p_.

## mmap()

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

virtual

Not support.

Returns
  NULL

Implements Exiv2::BasicIo.

References Exiv2::BasicIo::bigBlock_, Exiv2::RemoteIo::Impl::blockSize_, Exiv2::RemoteIo::Impl::blocksMap_, p_, and Exiv2::RemoteIo::Impl::size_.

## munmap()

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

virtual

Not support.

Returns
  0

Implements Exiv2::BasicIo.

## open()

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

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_, Exiv2::RemoteIo::Impl::blockSize_, Exiv2::RemoteIo::Impl::blocksMap_, close(), Exiv2::RemoteIo::Impl::getDataByRange(), Exiv2::RemoteIo::Impl::getFileLength(), Exiv2::RemoteIo::Impl::isMalloced_, p_, Exiv2::BlockMap::populate(), and Exiv2::RemoteIo::Impl::size_.

## path()

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

virtual

Returns the URL of the file.

Implements Exiv2::BasicIo.

References p_, and Exiv2::RemoteIo::Impl::path_.

## populateFakeData()

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

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.

Reimplemented from Exiv2::BasicIo.

References Exiv2::RemoteIo::Impl::blockSize_, Exiv2::RemoteIo::Impl::blocksMap_, Exiv2::RemoteIo::Impl::isMalloced_, Exiv2::BlockMap::markKnown(), p_, and Exiv2::RemoteIo::Impl::size_.

## putb()

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

virtual

Not support.

Returns
  0 means failure

Implements Exiv2::BasicIo.

## read() [1/2]

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

virtual

Read data from the 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 Exiv2::RemoteIo::Impl::blockSize_, Exiv2::RemoteIo::Impl::blocksMap_, Exiv2::RemoteIo::Impl::eof_, Exiv2::RemoteIo::Impl::idx_, Exiv2::RemoteIo::Impl::isMalloced_, p_, Exiv2::RemoteIo::Impl::populateBlocks(), Exiv2::RemoteIo::Impl::size_, and Exiv2::RemoteIo::Impl::totalRead_.

## read() [2/2]

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

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::pData_, read(), and Exiv2::DataBuf::size_.

Referenced by read().

## seek()

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

virtual

Move the current IO position.

Parameters

  offset | Number of bytes to move the IO 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 Exiv2::RemoteIo::Impl::eof_, Exiv2::RemoteIo::Impl::idx_, Exiv2::RemoteIo::Impl::isMalloced_, p_, and Exiv2::RemoteIo::Impl::size_.

## size()

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

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_, and Exiv2::RemoteIo::Impl::size_.

Referenced by Exiv2::HttpIo::HttpImpl::writeRemote().

## tell()

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

virtual

Get the current IO position.

Returns
  Offset from the start of the memory block

Implements Exiv2::BasicIo.

References Exiv2::RemoteIo::Impl::idx_, and p_.

## transfer()

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

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().

## write() [1/2]

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

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::RemoteIo::Impl::blockSize_, Exiv2::RemoteIo::Impl::blocksMap_, Exiv2::BasicIo::eof(), Exiv2::RemoteIo::Impl::isMalloced_, Exiv2::BasicIo::isopen(), p_, Exiv2::BasicIo::read(), Exiv2::BasicIo::seek(), Exiv2::BasicIo::size(), Exiv2::RemoteIo::Impl::size_, and Exiv2::RemoteIo::Impl::writeRemote().

## write() [2/2]

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

virtual

Not support this method.

Returns
  0 means failure

Implements Exiv2::BasicIo.

Referenced by transfer().

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

- basicio.hpp
- basicio.cpp