cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
osaPipeExec Class Reference

#include <osaPipeExec.h>

Public Member Functions

 osaPipeExec (const std::string &name="unnamed")
 
 ~osaPipeExec (void)
 
bool Open (const std::string &executable, const std::string &mode)
 
bool Open (const std::string &executable, const std::vector< std::string > &parameters, const std::string &mode)
 
bool Close (bool killProcess=true)
 
int Read (char *buffer, int maxLength) const
 
std::string Read (int maxLength) const
 
int ReadUntil (char *buffer, int maxLength, char stopChar) const
 
std::string ReadUntil (int maxLength, char stopChar) const
 
std::string ReadString (int maxLength) const
 
int Write (const char *buffer)
 
int Write (const char *buffer, int n)
 
int Write (const std::string &s)
 
int Write (const std::string &s, int n)
 
bool IsConnected (void) const
 
const std::string & GetName (void) const
 

Friends

class osaPipeExecTest
 

Constructor & Destructor Documentation

osaPipeExec::osaPipeExec ( const std::string &  name = "unnamed")

Constructor with name

osaPipeExec::~osaPipeExec ( void  )

Destructor calls Close()

Member Function Documentation

bool osaPipeExec::Close ( bool  killProcess = true)

Close the pipe. Returns true if the Close succeeded, false otherwise.

const std::string& osaPipeExec::GetName ( void  ) const

Get name provided in constructor.

bool osaPipeExec::IsConnected ( void  ) const

Indicate if the pipe is opened (or at least supposed to be opened)

bool osaPipeExec::Open ( const std::string &  executable,
const std::string &  mode 
)

Open a pipe using an existing executable and specifying read/write mode. Mode can be "r", "w", or "rw" specifying which direction(s) the pipe should go. Returns true if the Open succeeded, false otherwise

bool osaPipeExec::Open ( const std::string &  executable,
const std::vector< std::string > &  parameters,
const std::string &  mode 
)

Open a pipe using an existing executable with a vector of arguments and specifying read/write mode. Mode can be "r", "w", or "rw" specifying which direction(s) the pipe should go. Returns true if the Open succeeded, false otherwise

int osaPipeExec::Read ( char *  buffer,
int  maxLength 
) const

Read at most maxLength characters from the pipe into buffer. Return number of characters read or -1 for an error

std::string osaPipeExec::Read ( int  maxLength) const

Read at most maxLength characters from the pipe, including '\0', and return an std::string containing those characters or empty string for an error

std::string osaPipeExec::ReadString ( int  maxLength) const

Equivalent to ReadUntil(maxLength, '\0')

int osaPipeExec::ReadUntil ( char *  buffer,
int  maxLength,
char  stopChar 
) const

Read at most maxLength characters from the pipe, but stop reading if stopChar is read. Return the number of characters read

std::string osaPipeExec::ReadUntil ( int  maxLength,
char  stopChar 
) const

std::string version of ReadUntil stopChar is read. Return the number of characters read

int osaPipeExec::Write ( const char *  buffer)

Write the null-terminated buffer to the pipe. Return the number of characters written or -1 for an error

int osaPipeExec::Write ( const char *  buffer,
int  n 
)

Write the first n characters of buffer to pipe. Return the number of characters written or -1 for an error

int osaPipeExec::Write ( const std::string &  s)

Write s to the pipe and return the number of characters read or -1 for an error

int osaPipeExec::Write ( const std::string &  s,
int  n 
)

Write the first n characters of s to pipe. Return the number of characters written or -1 for an error

Friends And Related Function Documentation

friend class osaPipeExecTest
friend

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