dmlite  0.6
Public Types | Public Member Functions | List of all members
dmlite::IOHandler Class Reference

IO interface. More...

#include <io.h>

Public Types

enum  Whence { kSet = SEEK_SET, kCur = SEEK_CUR, kEnd = SEEK_END }
 

Public Member Functions

virtual ~IOHandler ()
 Virtual destructor. More...
 
std::string getImplId (void) const throw ()
 String ID of the implementation. More...
 
virtual void close (void)
 Close. More...
 
virtual int fileno (void)
 Return internal file descriptor, if any. More...
 
virtual struct ::stat fstat (void)
 
virtual size_t read (char *buffer, size_t count)
 
virtual size_t write (const char *buffer, size_t count)
 
virtual size_t readv (const struct iovec *vector, size_t count)
 
virtual size_t writev (const struct iovec *vector, size_t count)
 
virtual size_t pread (void *buffer, size_t count, off_t offset)
 
virtual size_t pwrite (const void *buffer, size_t count, off_t offset)
 
virtual void seek (off_t offset, Whence whence)
 
virtual off_t tell (void)
 Return the cursor position. More...
 
virtual void flush (void)
 Flush the buffer. More...
 
virtual bool eof (void)
 Return true if end of file. More...
 

Detailed Description

IO interface.

Member Enumeration Documentation

◆ Whence

Enumerator
kSet 

Beginning of the file.

kCur 

Current position.

kEnd 

End of file.

Constructor & Destructor Documentation

◆ ~IOHandler()

virtual dmlite::IOHandler::~IOHandler ( )
virtual

Virtual destructor.

Member Function Documentation

◆ close()

virtual void dmlite::IOHandler::close ( void  )
virtual

Close.

◆ eof()

virtual bool dmlite::IOHandler::eof ( void  )
virtual

Return true if end of file.

◆ fileno()

virtual int dmlite::IOHandler::fileno ( void  )
virtual

Return internal file descriptor, if any.

◆ flush()

virtual void dmlite::IOHandler::flush ( void  )
virtual

Flush the buffer.

◆ fstat()

virtual struct ::stat dmlite::IOHandler::fstat ( void  )
virtual

Gets information about a file descriptor.

Note
Not all plug-ins will fill all the fields, but st_size is a reasonable expectation.
Default implementation combining seek/tell is provided.

◆ getImplId()

std::string dmlite::IOHandler::getImplId ( void  ) const
throw (
)
inline

String ID of the implementation.

◆ pread()

virtual size_t dmlite::IOHandler::pread ( void *  buffer,
size_t  count,
off_t  offset 
)
virtual

Read from the given offset without changing the file offset.

Parameters
bufferWhere to put the data.
countNumber of bytes to read.
offsetThe operation offset.
Note
A default implementation using read/seek/tell is provided.

◆ pwrite()

virtual size_t dmlite::IOHandler::pwrite ( const void *  buffer,
size_t  count,
off_t  offset 
)
virtual

Write from the given offset without changing the file offset.

Parameters
bufferData to write.
countNumber of bytes to read.
offsetThe operation offset.
Note
A default implementation using read/seek/tell is provided.

◆ read()

virtual size_t dmlite::IOHandler::read ( char *  buffer,
size_t  count 
)
virtual

Read.

Parameters
bufferWhere to store the data.
countNumber of bytes to read.
Returns
Number of bytes actually read.

◆ readv()

virtual size_t dmlite::IOHandler::readv ( const struct iovec *  vector,
size_t  count 
)
virtual

Read into multiple buffers.

Parameters
vectorAn array with 'count' iovec structs.
countNumber of elements in vector.
Returns
The total size read.
Note
See man readv.
A default implementation using read is provided.

◆ seek()

virtual void dmlite::IOHandler::seek ( off_t  offset,
Whence  whence 
)
virtual

Move the cursor.

Parameters
offsetThe offset.
whenceReference.

◆ tell()

virtual off_t dmlite::IOHandler::tell ( void  )
virtual

Return the cursor position.

◆ write()

virtual size_t dmlite::IOHandler::write ( const char *  buffer,
size_t  count 
)
virtual

Write.

Parameters
bufferData to write.
countNumber of bytes to write.
Returns
Number of bytes actually written.

◆ writev()

virtual size_t dmlite::IOHandler::writev ( const struct iovec *  vector,
size_t  count 
)
virtual

Write from multiple buffers.

Parameters
vectorAn array with 'count' iovec structs.
countNumber of elements in vector.
Returns
The total size written.
Note
See man writev.
A default implementation using write is provided.

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