PoDoFo  0.9.4
Public Member Functions | Protected Member Functions | List of all members
PoDoFo::PdfInputDevice Class Reference

#include <PdfInputDevice.h>

Public Member Functions

 PdfInputDevice (const char *pszFilename)
 
 PdfInputDevice (const char *pBuffer, size_t lLen)
 
 PdfInputDevice (const std::istream *pInStream)
 
virtual ~PdfInputDevice ()
 
virtual void Close ()
 
virtual std::streamoff Tell () const
 
virtual int GetChar () const
 
virtual int Look () const
 
virtual void Seek (std::streamoff off, std::ios_base::seekdir dir=std::ios_base::beg)
 
virtual std::streamoff Read (char *pBuffer, std::streamsize lLen)
 
virtual PODOFO_NOTHROW bool Eof () const
 
virtual PODOFO_NOTHROW bool Bad () const
 
virtual PODOFO_NOTHROW void Clear (std::ios_base::iostate state=std::ios_base::goodbit) const
 
PODOFO_NOTHROW bool IsSeekable () const
 

Protected Member Functions

PODOFO_NOTHROW void SetSeekable (bool bIsSeekable)
 
 PdfInputDevice ()
 

Detailed Description

This class provides an Input device which operates either on a file, a buffer in memory or any arbitrary std::istream

This class is suitable for inheritance to provide input devices of your own for PoDoFo. Just overide the required virtual methods.

Constructor & Destructor Documentation

PoDoFo::PdfInputDevice::PdfInputDevice ( const char *  pszFilename)

Construct a new PdfInputDevice that reads all data from a file.

Parameters
pszFilenamepath to a file that will be opened and all data is read from this file.
PoDoFo::PdfInputDevice::PdfInputDevice ( const char *  pBuffer,
size_t  lLen 
)

Construct a new PdfInputDevice that reads all data from a memory buffer. The buffer will not be owned by this object - it is COPIED.

Parameters
pBuffera buffer in memory
lLenthe length of the buffer in memory
PoDoFo::PdfInputDevice::PdfInputDevice ( const std::istream *  pInStream)

Construct a new PdfInputDevice that reads all data from a std::istream.

Parameters
pInStreamread from this std::istream
PoDoFo::PdfInputDevice::~PdfInputDevice ( )
virtual

Destruct the PdfInputDevice object and close any open files.

PoDoFo::PdfInputDevice::PdfInputDevice ( )
protected

CAN NOT Construct a new PdfInputDevice without an input source. However subclasses may well need to do just that.

Member Function Documentation

bool PoDoFo::PdfInputDevice::Bad ( ) const
inlinevirtual
Returns
True if there was an error in an I/O operation
void PoDoFo::PdfInputDevice::Clear ( std::ios_base::iostate  state = std::ios_base::goodbit) const
inlinevirtual

Set the stream error state. By default, clears badbit, eofbit and failbit.

void PoDoFo::PdfInputDevice::Close ( )
virtual

Close the input device. No further operations may be performed on this device after calling this function.

bool PoDoFo::PdfInputDevice::Eof ( ) const
inlinevirtual
Returns
True if the stream is at EOF
int PoDoFo::PdfInputDevice::GetChar ( ) const
virtual

Get next char from stream.

Returns
the next character from the stream
bool PoDoFo::PdfInputDevice::IsSeekable ( ) const
inline
Returns
True if the stream is seekable. Subclasses can control this value with SetIsSeekable(bool) .
int PoDoFo::PdfInputDevice::Look ( ) const
virtual

Peek at next char in stream. /returns the next char in the stream

std::streamoff PoDoFo::PdfInputDevice::Read ( char *  pBuffer,
std::streamsize  lLen 
)
virtual

Read a certain number of bytes from the input device.

Parameters
pBufferstore bytes in this buffer. The buffer has to be large enough.
lLennumber of bytes to read.
Returns
the number of bytes that have been read. If reading was successfull the number of read bytes is equal to lLen.
void PoDoFo::PdfInputDevice::Seek ( std::streamoff  off,
std::ios_base::seekdir  dir = std::ios_base::beg 
)
virtual

Seek the device to the position offset from the begining

Parameters
offfrom the beginning of the file
dirwhere to start (start, cur, end)

A non-seekable input device will throw an InvalidDeviceOperation.

void PoDoFo::PdfInputDevice::SetSeekable ( bool  bIsSeekable)
inlineprotected

Control whether or or not this stream is flagged seekable.

std::streamoff PoDoFo::PdfInputDevice::Tell ( ) const
virtual

Get the current position in file. /returns the current position in the file