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

#include <PdfOutputStream.h>

Inheritance diagram for mm::PdfMemoryOutputStream:
mm::PdfOutputStream

Public Member Functions

 PdfMemoryOutputStream (size_t initialSize=INITIAL_SIZE)
 
 PdfMemoryOutputStream (char *buffer, size_t len)
 
void Close () override
 
size_t GetLength () const
 
std::unique_ptr< char[]> TakeBuffer (size_t &length)
 
- Public Member Functions inherited from mm::PdfOutputStream
void Write (const char *buffer, size_t len)
 
void Write (const std::string_view &view)
 
virtual void Close ()=0
 

Detailed Description

An output stream that writes data to a memory buffer If the buffer is to small, it will be enlarged automatically.

Constructor & Destructor Documentation

◆ PdfMemoryOutputStream() [1/2]

PdfMemoryOutputStream::PdfMemoryOutputStream ( size_t  initialSize = INITIAL_SIZE)

Construct a new PdfMemoryOutputStream

Parameters
lInitialinitial size of the buffer

◆ PdfMemoryOutputStream() [2/2]

PdfMemoryOutputStream::PdfMemoryOutputStream ( char *  buffer,
size_t  len 
)

Construct a new PdfMemoryOutputStream that writes to an existing buffer

Parameters
bufferhandle to the buffer
lenlength of the buffer

Member Function Documentation

◆ Close()

void PdfMemoryOutputStream::Close ( )
overridevirtual

Close the PdfOutputStream. This method may throw exceptions and has to be called before the destructor to end writing.

No more data may be written to the output device after calling close.

Implements mm::PdfOutputStream.

◆ GetLength()

size_t mm::PdfMemoryOutputStream::GetLength ( ) const
inline
Returns
the length of the written data

◆ TakeBuffer()

unique_ptr< char[]> PdfMemoryOutputStream::TakeBuffer ( size_t &  length)
Returns
a handle to the internal buffer.

The internal buffer is now owned by the caller and will not be deleted by PdfMemoryOutputStream. Further calls to Write() are not allowed.

The caller has to free() the returned malloc()'ed buffer!