CARMA C++
carma::ui::rtd::ReaderWithTimeout Class Reference

Read a series of bytes with a timeout and return a raw byte string with the contents of the read. More...

#include <carma/ui/rtd/common/ReaderWithTimeout.h>

Public Types

enum  {
  SUCCESS, BROKEN_CNX, TIMEOUT, IOCTL_ERROR,
  POLL_ERROR, READ_ERROR
}
 Error codes. More...
 

Public Member Functions

bool getBytes (std::string &bytes, struct::timeval tv)
 Read input from file and put into input string. More...
 
bool getBytes (std::string &bytes)
 
int getErrorCode () const
 Get error code of last IO. More...
 
 ReaderWithTimeout ()
 Constructor. More...
 
 ReaderWithTimeout (const struct::timeval tv)
 Constructor. More...
 
 ReaderWithTimeout (const int fd, const struct::timeval tv)
 Constructor. More...
 

Detailed Description

Read a series of bytes with a timeout and return a raw byte string with the contents of the read.

All byte strings begin with a 4-byte integer (in network byte order) which contains the number of bytes in the packet. The data follows immediately.

Works fine with sockets.

Definition at line 33 of file ReaderWithTimeout.h.

Member Enumeration Documentation

anonymous enum

Error codes.

Definition at line 59 of file ReaderWithTimeout.h.

Constructor & Destructor Documentation

carma::ui::rtd::ReaderWithTimeout::ReaderWithTimeout ( )

Constructor.

carma::ui::rtd::ReaderWithTimeout::ReaderWithTimeout ( const struct::timeval  tv)

Constructor.

carma::ui::rtd::ReaderWithTimeout::ReaderWithTimeout ( const int  fd,
const struct::timeval  tv 
)

Constructor.

Member Function Documentation

bool carma::ui::rtd::ReaderWithTimeout::getBytes ( std::string &  bytes,
struct::timeval  tv 
)

Read input from file and put into input string.

If an error is encountered, an error message is put in the string.

Parameters
inputstring in which to place input from stdin
timeoutSecondstimeout for receiving the input (seconds)
Returns
true for success, false for failure.
int carma::ui::rtd::ReaderWithTimeout::getErrorCode ( ) const

Get error code of last IO.

Returns
error code (see below)

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