YARP  2.3.70
Yet Another Robot Platform
yarp::os::StringInputStream Class Reference

An InputStream that reads from a string. More...

#include <yarp/os/StringInputStream.h>

+ Inheritance diagram for yarp::os::StringInputStream:

Public Member Functions

 StringInputStream ()
 
void reset ()
 
void reset (const ConstString &str)
 
void add (const ConstString &txt)
 
void add (const Bytes &b)
 
virtual YARP_SSIZE_T read (const Bytes &b) YARP_OVERRIDE
 Read a block of data from the stream. More...
 
virtual void close () YARP_OVERRIDE
 Terminate the stream. More...
 
virtual ConstString toString ()
 
virtual bool isOk () YARP_OVERRIDE
 Check if the stream is ok or in an error state. More...
 
- Public Member Functions inherited from yarp::os::InputStream
 InputStream ()
 Constructor. More...
 
virtual ~InputStream ()
 Destructor. More...
 
virtual void check ()
 Perform maintenance actions, if needed. More...
 
virtual int read ()
 Read and return a single byte. More...
 
virtual YARP_SSIZE_T read (const Bytes &b, size_t offset, YARP_SSIZE_T len)
 Read a block of data from the stream. More...
 
virtual YARP_SSIZE_T partialRead (const yarp::os::Bytes &b)
 Like read, but solicit partial responses. More...
 
virtual void interrupt ()
 Interrupt the stream. More...
 
virtual bool setReadTimeout (double timeout)
 Set activity timeout. More...
 
ConstString readLine (int terminal='\n', bool *success=YARP_NULLPTR)
 Read a block of text terminated with a specific marker (or EOF). More...
 
YARP_SSIZE_T readFull (const Bytes &b)
 Keep reading until buffer is full. More...
 
YARP_SSIZE_T readDiscard (size_t len)
 Read and discard a fixed number of bytes. More...
 
virtual bool setReadEnvelopeCallback (readEnvelopeCallbackType callback, void *data)
 Install a callback that the InputStream will have to call when the envelope is read from a message in carriers that cannot be escaped. More...
 

Private Attributes

ConstString data
 
unsigned int at
 

Additional Inherited Members

- Public Types inherited from yarp::os::InputStream
typedef void(* readEnvelopeCallbackType) (void *, const yarp::os::Bytes &envelope)
 Callback type for setting the envelope from a message in carriers that cannot be escaped. More...
 

Detailed Description

An InputStream that reads from a string.

Handy For testing purposes.

Definition at line 22 of file StringInputStream.h.

Constructor & Destructor Documentation

◆ StringInputStream()

yarp::os::StringInputStream::StringInputStream ( )
inline

Definition at line 26 of file StringInputStream.h.

Member Function Documentation

◆ add() [1/2]

void yarp::os::StringInputStream::add ( const ConstString txt)
inline

Definition at line 41 of file StringInputStream.h.

◆ add() [2/2]

void yarp::os::StringInputStream::add ( const Bytes b)
inline

Definition at line 45 of file StringInputStream.h.

◆ close()

virtual void yarp::os::StringInputStream::close ( )
inlinevirtual

Terminate the stream.

Implements yarp::os::InputStream.

Definition at line 65 of file StringInputStream.h.

◆ isOk()

virtual bool yarp::os::StringInputStream::isOk ( )
inlinevirtual

Check if the stream is ok or in an error state.

Returns
true iff the stream is ok

Implements yarp::os::InputStream.

Definition at line 72 of file StringInputStream.h.

◆ read()

virtual YARP_SSIZE_T yarp::os::StringInputStream::read ( const Bytes b)
inlinevirtual

Read a block of data from the stream.

Should block and wait for data.

Parameters
bthe block of data to read to
Returns
the number of bytes read, or -1 upon error

Implements yarp::os::InputStream.

Definition at line 51 of file StringInputStream.h.

◆ reset() [1/2]

void yarp::os::StringInputStream::reset ( )
inline

Definition at line 31 of file StringInputStream.h.

◆ reset() [2/2]

void yarp::os::StringInputStream::reset ( const ConstString str)
inline

Definition at line 36 of file StringInputStream.h.

◆ toString()

virtual ConstString yarp::os::StringInputStream::toString ( )
inlinevirtual

Definition at line 68 of file StringInputStream.h.

Member Data Documentation

◆ at

unsigned int yarp::os::StringInputStream::at
private

Definition at line 78 of file StringInputStream.h.

◆ data

ConstString yarp::os::StringInputStream::data
private

Definition at line 77 of file StringInputStream.h.


The documentation for this class was generated from the following file: