- Main Page
- Namespaces
- Classes
- Files
- Examples

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exiv2::BasicIo Class Reference

An interface for simple binary IO. More...

`#include <basicio.hpp>`

Inheritance diagram for Exiv2::BasicIo:

[legend]
List of all members.

## Public Types
typedef std::auto_ptr< BasicIo > | AutoPtr
| BasicIo auto_ptr type.
enum | Position { beg, cur, end }
| Seek starting positions.
## Public Member Functions
Creators
virtual | ~BasicIo ()
| Destructor.
Manipulators
virtual int | open ()=0
| Open the IO source using the default access mode. The default mode should allow for reading and writing.
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.
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.
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.
virtual int | putb (byte data)=0
| Write one byte to the IO source. Current IO position is advanced by one byte.
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.
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.
virtual int | getb ()=0
| Read one byte from the IO source. Current IO position is advanced by one byte.
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.
virtual int | seek (long offset, Position pos)=0
| Move the current IO position.
Accessors
virtual long | tell () const =0
| Get the current IO position.
virtual long | size () const =0
| Get the current size of the IO source in bytes.
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 reach 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 BasicIo::AutoPtr | temporary () const =0
| Returns a temporary data storage location. This is often needed to rewrite an IO source.
## Protected Member Functions
Creators
| BasicIo ()
| Default Constructor.

## Detailed Description

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.

## Member Function Documentation

virtual int Exiv2::BasicIo::close | ( |  | ) | `[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. Returns: 0 if successful; Nonzero if failure. Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual int Exiv2::BasicIo::getb | ( |  | ) | `[pure virtual]`

| Read one byte from the IO source. Current IO position is advanced by one byte. Returns: The byte read from the IO source if successful; EOF if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual int Exiv2::BasicIo::open | ( |  | ) | `[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. Returns: 0 if successful; Nonzero if failure. Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual int Exiv2::BasicIo::putb | ( | byte | data | ) | `[pure virtual]`

  | Write one byte to the IO source. Current IO position is advanced by one byte. Parameters:
  | data | The single byte to be written.
Returns: The value of the byte written if successful; EOF if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual long Exiv2::BasicIo::read | ( | byte * | buf,
|  | long | rcount
| ) | `[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. 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 IO source successfully; 0 if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual DataBuf Exiv2::BasicIo::read | ( | long | rcount | ) | `[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. 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. Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual int Exiv2::BasicIo::seek | ( | long | offset,
|  | Position | pos
| ) | `[pure 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;

virtual long Exiv2::BasicIo::size | ( |  | ) | const`[pure virtual]`

| Get the current size of the IO source in bytes. Returns: Size of the IO source in bytes; -1 if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual long Exiv2::BasicIo::tell | ( |  | ) | const`[pure virtual]`

| Get the current IO position. Returns: Offset from the start of IO if successful; -1 if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual BasicIo::AutoPtr Exiv2::BasicIo::temporary | ( |  | ) | const`[pure virtual]`

  | Returns a temporary data storage location. This is often needed to rewrite an IO source. For example, data may be read from the original IO source, modified in some way, and then saved to the temporary instance. After the operation is complete, the BasicIo::transfer method can be used to replace the original IO source with the modified version. Subclasses are free to return any class that derives from BasicIo. Returns: An instance of BasicIo on success Exceptions:
  | Error | In case of failure
Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual void Exiv2::BasicIo::transfer | ( | BasicIo & | src | ) | `[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. 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
Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual long Exiv2::BasicIo::write | ( | BasicIo & | src | ) | `[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. Parameters:
  | src | Reference to another BasicIo instance. Reading start at the source's current IO position
Returns: Number of bytes written to IO source successfully; 0 if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

virtual long Exiv2::BasicIo::write | ( | const byte * | data,
|  | long | wcount
| ) | `[pure virtual]`

  | Write data to the IO source. Current IO position is advanced by the number of bytes written. Parameters:
  | data | Pointer to data. Data must be at least wcount bytes long
  | wcount | Number of bytes to be written.
Returns: Number of bytes written to IO source successfully; 0 if failure; Implemented in Exiv2::FileIo, and Exiv2::MemIo.

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

- basicio.hpp