PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::Source Class Referenceabstract

#include <Puma/Source.h>

+ Inheritance diagram for Puma::Source:

Description

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 ( )
inline

Constructs an empty source object.

◆ ~Source()

virtual Puma::Source::~Source ( )
inlinevirtual

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.

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

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

◆ size()

virtual int Puma::Source::size ( )
inlinevirtual

Get the size of the source.

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

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

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