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

#include <Puma/StringSource.h>

+ Inheritance diagram for Puma::StringSource:

Description

String input source implementation implementing the Source interface.

Public Member Functions

 StringSource ()
 Construct an empty string input source.
 
 StringSource (const char *string)
 Construct an input source for the given string.
 
virtual int read (char *dest, int n)
 Read n bytes from the input string into the given string.
 
void string (const char *string)
 Set the input string to read from.
 
const char * string ()
 Get the input string.
 
int size ()
 Get the size of the input string.
 
- Public Member Functions inherited from Puma::Source
 Source ()
 Constructs an empty source object.
 
virtual ~Source ()
 Destroys the source object.
 

Constructor & Destructor Documentation

◆ StringSource() [1/2]

Puma::StringSource::StringSource ( )
inline

Construct an empty string input source.

◆ StringSource() [2/2]

Puma::StringSource::StringSource ( const char * string)
inline

Construct an input source for the given string.

Parameters
stringThe string from which to read.

Member Function Documentation

◆ read()

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

Read n bytes from the input string 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.

◆ size()

int Puma::StringSource::size ( )
inlinevirtual

Get the size of the input string.

Returns
The size of the input string, or -1 if no input string set.

Reimplemented from Puma::Source.

◆ string() [1/2]

const char * Puma::StringSource::string ( )
inline

Get the input string.

Returns
The input string, or null if no input string set.

◆ string() [2/2]

void Puma::StringSource::string ( const char * string)
inline

Set the input string to read from.

Parameters
stringThe input string.