PoDoFo 1.2.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
PoDoFo::InputStream Class Referenceabstract

An interface for reading blocks of data from a data source. More...

#include <InputStream.h>

Inheritance diagram for PoDoFo::InputStream:
PoDoFo::InputStreamDevice PoDoFo::PdfCanvasInputDevice PoDoFo::StreamDevice PoDoFo::NullStreamDevice

Public Member Functions

void Read (char *buffer, size_t size)
 Read data from the device.
 
size_t Read (char *buffer, size_t size, bool &eof)
 Read data from the device.
 
char ReadChar ()
 Get next char from stream.
 
bool Read (char &ch)
 Get next char from stream.
 
void CopyTo (OutputStream &stream)
 Copy this stream to another.
 
void CopyTo (OutputStream &stream, size_t size)
 Copy this stream to another.
 

Protected Member Functions

virtual size_t readBuffer (char *buffer, size_t size, bool &eof)=0
 Read a buffer from the stream.
 
virtual bool readChar (char &ch)
 Read the next char in stream.
 
virtual void checkRead () const
 Optional checks before reading By default does nothing.
 

Static Protected Member Functions

static size_t ReadBuffer (InputStream &stream, char *buffer, size_t size, bool &eof)
 Read from another stream, to be used by decorator streams on their source.
 
static bool ReadChar (InputStream &stream, char &ch)
 

Protected Attributes

const char * m_head
 Inline read window over memory that already holds the bytes at the current logical position.
 
const char * m_tail
 

Detailed Description

An interface for reading blocks of data from a data source.

It supports non-blocking read operations

Member Function Documentation

◆ checkRead()

void InputStream::checkRead ( ) const
protectedvirtual

Optional checks before reading By default does nothing.

Reimplemented in PoDoFo::InputStreamDevice.

◆ CopyTo() [1/2]

void InputStream::CopyTo ( OutputStream &  stream)

Copy this stream to another.

Remarks
The copy begins from the current position and it's not reset after the operation is completed

◆ CopyTo() [2/2]

void InputStream::CopyTo ( OutputStream &  stream,
size_t  size 
)

Copy this stream to another.

Remarks
The copy begins from the current position and it's not reset after the operation is completed

◆ Read() [1/3]

PODOFO_INLINE bool InputStream::Read ( char &  ch)

Get next char from stream.

Parameters
chthe read character
Returns
true if success, false if EOF is encountered before reading the character

◆ Read() [2/3]

PODOFO_INLINE void InputStream::Read ( char *  buffer,
size_t  size 
)

Read data from the device.

Parameters
buffera pointer to the data buffer
sizelength of the output buffer
Remarks
throws if EOF is encountered before reading the required size

◆ Read() [3/3]

PODOFO_INLINE size_t InputStream::Read ( char *  buffer,
size_t  size,
bool &  eof 
)

Read data from the device.

Parameters
buffera pointer to the data buffer
sizelength of the output buffer
eofstream encountered EOF during the read
Returns
Number of read bytes

◆ readBuffer()

virtual size_t PoDoFo::InputStream::readBuffer ( char *  buffer,
size_t  size,
bool &  eof 
)
protectedpure virtual

Read a buffer from the stream.

Parameters
eoftrue if the stream reached eof during read
Returns
number of read bytes

Implemented in PoDoFo::NullStreamDevice, and PoDoFo::PdfCanvasInputDevice.

◆ ReadBuffer()

PODOFO_INLINE size_t InputStream::ReadBuffer ( InputStream &  stream,
char *  buffer,
size_t  size,
bool &  eof 
)
staticprotected

Read from another stream, to be used by decorator streams on their source.

Like the public frontends they serve the source read window first, when it can satisfy the request

◆ ReadChar()

PODOFO_INLINE char InputStream::ReadChar ( )

Get next char from stream.

Returns
the next character from the stream
Remarks
throws if EOF is encountered before reading the character

◆ readChar()

bool InputStream::readChar ( char &  ch)
protectedvirtual

Read the next char in stream.

Returns
true if success, false if EOF

Reimplemented in PoDoFo::NullStreamDevice, and PoDoFo::PdfCanvasInputDevice.

Member Data Documentation

◆ m_head

const char* PoDoFo::InputStream::m_head
protected

Inline read window over memory that already holds the bytes at the current logical position.

It has three states:

  • unarmed: m_tail == nullptr, the device counter owns the position
  • armed, empty: m_tail != nullptr && m_head == m_tail, the window is authoritative for the position but holds no bytes
  • armed, non empty: m_head < m_tail, reads are served from the window While armed m_head is authoritative for the logical position, so every readBuffer()/readChar()/peek() override of an arming device must drain or derive from it. The window is armed only when read access is granted, since the fast paths skip checkRead()

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