PUMA Library Reference Manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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

Puma::Source::Source ( )
inline

Constructs an empty source object.

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

Destroys the source object.

Member Function Documentation

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::StringSource, Puma::FdSource, Puma::FileSource, Puma::Pipe, and Puma::KeyboardSource.

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::StringSource, and Puma::FdSource.