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::OutputStream Class Referenceabstract

An interface for writing blocks of data to a data source. More...

#include <OutputStream.h>

Inheritance diagram for PoDoFo::OutputStream:
PoDoFo::PdfStringStream

Public Member Functions

void Write (char ch)
 Write the character in the device.
 
void Write (const std::string_view &view)
 Write the view to the OutputStream.
 
void Write (const char *buffer, size_t size)
 Write data to the output stream.
 
void Flush ()
 

Protected Member Functions

virtual void writeBuffer (const char *buffer, size_t size)=0
 
virtual void flush ()
 
virtual void checkWrite () const
 Optional checks before writing By default does nothing.
 
void enableWriteWindow (char *cur, char *end)
 Enable the inline write window over the supplied memory region.
 
void disableWriteWindow ()
 Disarm the window, once its pending bytes have been handed to the sink.
 

Static Protected Member Functions

static void WriteBuffer (OutputStream &stream, const char *buffer, size_t size)
 Write to another stream, skipping its checkWrite() but still serving its inline write window.
 
static void Flush (OutputStream &stream)
 

Protected Attributes

char * m_wcur
 Inline write window over memory owned by the implementation, mirroring InputStream's read window.
 
char * m_wend
 

Detailed Description

An interface for writing blocks of data to a data source.

Member Function Documentation

◆ disableWriteWindow()

void OutputStream::disableWriteWindow ( )
protected

Disarm the window, once its pending bytes have been handed to the sink.

Remarks
An arming implementation must call this from its own destructor, after the final drain, as ~OutputStream() asserts the window is disarmed

◆ enableWriteWindow()

void OutputStream::enableWriteWindow ( char *  cur,
char *  end 
)
protected

Enable the inline write window over the supplied memory region.

Remarks
Must be armed only once write access is granted, since the fast paths skip checkWrite()

◆ Write() [1/3]

PODOFO_INLINE void OutputStream::Write ( char  ch)

Write the character in the device.

Parameters
chthe character to write

◆ Write() [2/3]

PODOFO_INLINE void OutputStream::Write ( const char *  buffer,
size_t  size 
)

Write data to the output stream.

Parameters
bufferthe data is read from this buffer
sizethe size of the buffer

◆ Write() [3/3]

void PoDoFo::OutputStream::Write ( const std::string_view &  view)

Write the view to the OutputStream.

Parameters
viewthe view to be written

Member Data Documentation

◆ m_wcur

char* PoDoFo::OutputStream::m_wcur
protected

Inline write window over memory owned by the implementation, mirroring InputStream's read window.

It has three states:

  • unarmed: m_wend == nullptr, every write takes the virtual slow path
  • armed, full: m_wend != nullptr && m_wcur == m_wend, no room left
  • armed, with room: m_wcur < m_wend, writes are served by the window Unlike the read window, which can be dropped at any time, the bytes before m_wcur are pending output: an arming implementation must keep them ahead of what writeBuffer() receives, and hand them to its sink in flush() and in its own destructor While armed, writes served by the window never reach writeBuffer(), so an implementation that counts or inspects bytes there must derive the count from m_wcur instead, or not arm at all

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