PUMA Library Reference Manual
Puma::Source Class Referenceabstract

#include <Puma/Source.h>

+ Inheritance diagram for Puma::Source:


Interface for all input sources.

Public Member Functions

 Source ()
 Constructs an empty source object. More...
virtual ~Source ()
 Destroys the source object. More...
virtual int read (char *buffer, int n)=0
 Read n bytes from the source into the given string buffer. More...
virtual int size ()
 Get the size of the source. More...

Constructor & Destructor Documentation

◆ Source()

Puma::Source::Source ( )

Constructs an empty source object.

◆ ~Source()

virtual Puma::Source::~Source ( )

Destroys the source object.

Member Function Documentation

◆ read()

virtual int Puma::Source::read ( char *  buffer,
int  n 
pure virtual

Read n bytes from the source into the given string buffer.

bufferThe string used as buffer for the bytes read.
nThe number of bytes to read.
The number of bytes read, or -1 in case of errors.

Implemented in Puma::StringSource, Puma::FdSource, Puma::FileSource, Puma::KeyboardSource, and Puma::Pipe.

◆ size()

virtual int Puma::Source::size ( )

Get the size of the source.

To be implemented if a specific source supports asking for its size.

This default implementation always returns -1 to indicate that the size is unknown.

Reimplemented in Puma::StringSource, and Puma::FdSource.