pdfmm 0.9.20
Public Member Functions | List of all members
mm::PdfInputDevice Class Reference

#include <PdfInputDevice.h>

Inheritance diagram for mm::PdfInputDevice:
mm::PdfCanvasInputDevice

Public Member Functions

 PdfInputDevice (const std::string_view &filename)
 
 PdfInputDevice (const char *buffer, size_t len)
 
 PdfInputDevice (std::istream &stream)
 
virtual ~PdfInputDevice ()
 
virtual void Close ()
 
virtual size_t Tell ()
 
int GetChar ()
 
virtual bool TryGetChar (char &ch)
 
virtual int Look ()
 
void Seek (std::streamoff off, std::ios_base::seekdir dir=std::ios_base::beg)
 
virtual size_t Read (char *buffer, size_t size)
 
virtual bool Eof () const
 
virtual bool IsSeekable () const
 

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 pdfmm. Just override the required virtual methods.

Constructor & Destructor Documentation

◆ PdfInputDevice() [1/3]

mm::PdfInputDevice::PdfInputDevice ( const std::string_view &  filename)
explicit

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

Parameters
filenamepath to a file that will be opened and all data is read from this file.

◆ PdfInputDevice() [2/3]

PdfInputDevice::PdfInputDevice ( const char *  buffer,
size_t  len 
)

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
buffera buffer in memory
lenthe length of the buffer in memory

◆ PdfInputDevice() [3/3]

mm::PdfInputDevice::PdfInputDevice ( std::istream &  stream)
explicit

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

Parameters
pInStreamread from this std::istream

◆ ~PdfInputDevice()

PdfInputDevice::~PdfInputDevice ( )
virtual

Destruct the PdfInputDevice object and close any open files.

Member Function Documentation

◆ Close()

void PdfInputDevice::Close ( )
virtual

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

◆ Eof()

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

Reimplemented in mm::PdfCanvasInputDevice.

◆ GetChar()

int PdfInputDevice::GetChar ( )

Get next char from stream.

Returns
the next character from the stream

◆ IsSeekable()

virtual bool mm::PdfInputDevice::IsSeekable ( ) const
inlinevirtual
Returns
True if the stream is seekable

Reimplemented in mm::PdfCanvasInputDevice.

◆ Look()

int PdfInputDevice::Look ( )
virtual

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

Reimplemented in mm::PdfCanvasInputDevice.

◆ Read()

size_t PdfInputDevice::Read ( char *  buffer,
size_t  size 
)
virtual

Read a certain number of bytes from the input device.

Parameters
bufferstore bytes in this buffer. The buffer has to be large enough.
sizenumber of bytes to read.
Returns
the number of bytes that have been read. 0 if the device reached eof

Reimplemented in mm::PdfCanvasInputDevice.

◆ Seek()

void PdfInputDevice::Seek ( std::streamoff  off,
std::ios_base::seekdir  dir = std::ios_base::beg 
)

Seek the device to the position offset from the beginning

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

A non-seekable input device will throw an InvalidDeviceOperation.

◆ Tell()

size_t PdfInputDevice::Tell ( )
virtual

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

Reimplemented in mm::PdfCanvasInputDevice.

◆ TryGetChar()

bool PdfInputDevice::TryGetChar ( char &  ch)
virtual

Get next char from stream.

Returns
the next character from the stream

Reimplemented in mm::PdfCanvasInputDevice.