PUMA Library Reference Manual
Puma::FdSource Class Reference

#include <Puma/FdSource.h>

+ Inheritance diagram for Puma::FdSource:

Description

File descriptor wrapper implementing the Source interface.

Public Member Functions

 FdSource ()
 Construct a new file descriptor wrapper with invalid file descriptor. More...
 
 FdSource (int fdesc)
 Construct a new wrapper for the given file descriptor. More...
 
virtual ~FdSource ()
 Destroy the wrapper. More...
 
virtual int read (char *dest, int n)
 Read n bytes from the file into the given string. More...
 
void fd (int fdesc)
 Set the wrapped file descriptor. More...
 
int fd ()
 Get the wrapped file descriptor. More...
 
int size ()
 Get the size of the file. More...
 
- Public Member Functions inherited from Puma::Source
 Source ()
 Constructs an empty source object. More...
 
virtual ~Source ()
 Destroys the source object. More...
 

Constructor & Destructor Documentation

◆ FdSource() [1/2]

Puma::FdSource::FdSource ( )
inline

Construct a new file descriptor wrapper with invalid file descriptor.

◆ FdSource() [2/2]

Puma::FdSource::FdSource ( int  fdesc)
inline

Construct a new wrapper for the given file descriptor.

Parameters
fdescThe file descriptor.

◆ ~FdSource()

virtual Puma::FdSource::~FdSource ( )
inlinevirtual

Destroy the wrapper.

Does not close the file descriptor.

Member Function Documentation

◆ fd() [1/2]

int Puma::FdSource::fd ( )
inline

Get the wrapped file descriptor.

Returns
The file descriptor, or -1 if no file descriptor set.

◆ fd() [2/2]

void Puma::FdSource::fd ( int  fdesc)
inline

Set the wrapped file descriptor.

Parameters
fdescThe file descriptor.

◆ read()

virtual int Puma::FdSource::read ( char *  dest,
int  n 
)
inlinevirtual

Read n bytes from the file into the given string.

Parameters
destThe 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.

Implements Puma::Source.

Reimplemented in Puma::FileSource.

◆ size()

int Puma::FdSource::size ( )
inlinevirtual

Get the size of the file.

Returns
The size of the file, or -1 if size could not be determined.

Reimplemented from Puma::Source.