|
cisst-saw
|
#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 noWindow=false) |
| bool | Open (const std::string &executable, const std::vector< std::string > ¶meters, const std::string &mode, bool noWindow=false) |
| 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, double timeoutSec=0.0) const |
| std::string | ReadUntil (int maxLength, char stopChar, double timeoutSec=0.0) const |
| std::string | ReadString (int maxLength, double timeoutSec=0.0) 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 |
| bool | IsProcessRunning (void) const |
| const std::string & | GetName (void) const |
Friends | |
| class | osaPipeExecTest |
| osaPipeExec::osaPipeExec | ( | const std::string & | name = "unnamed" | ) |
Constructor with name
| osaPipeExec::~osaPipeExec | ( | void | ) |
Destructor calls Close()
| bool osaPipeExec::Close | ( | bool | killProcess = true | ) |
Close the pipe and optionally kill the child process. Returns: true if killProcess is false and pipe successfully closed OR if killProcess is true and process successfully terminated (even if pipe not successfully closed); 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::IsProcessRunning | ( | void | ) | const |
Returns true if the child process is still running.
| bool osaPipeExec::Open | ( | const std::string & | executable, |
| const std::string & | mode, | ||
| bool | noWindow = false ) |
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. On Microsoft Windows, the optional parameter noWindow prevents a new console window from being displayed.
| bool osaPipeExec::Open | ( | const std::string & | executable, |
| const std::vector< std::string > & | parameters, | ||
| const std::string & | mode, | ||
| bool | noWindow = false ) |
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. On Microsoft Windows, the optional parameter noWindow prevents a new console window from being displayed.
| 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, |
| double | timeoutSec = 0.0 ) const |
Equivalent to ReadUntil(maxLength, '\0', timeoutSec)
| int osaPipeExec::ReadUntil | ( | char * | buffer, |
| int | maxLength, | ||
| char | stopChar, | ||
| double | timeoutSec = 0.0 ) const |
Read at most maxLength characters from the pipe, but stop reading if stopChar is read or if timeout expires (timeoutSec <= 0 means no timeout). Return the number of characters read.
| std::string osaPipeExec::ReadUntil | ( | int | maxLength, |
| char | stopChar, | ||
| double | timeoutSec = 0.0 ) const |
std::string version of ReadUntil. 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
|
friend |