dlvhex
2.5.0
|
A std::streambuf interface for creating child processes and writing/reading data via stdin/stdout. More...
#include <include/dlvhex2/ProcessBuf.h>
Public Member Functions | |
ProcessBuf () | |
Constructor. | |
ProcessBuf (const ProcessBuf &b) | |
Copy-constructor. | |
virtual | ~ProcessBuf () |
Destructor. | |
virtual void | endoffile () |
Send EOF to the process. | |
virtual pid_t | open (const std::vector< std::string > &c) |
Open a commandline in a seprate process. | |
virtual int | close (bool kill=false) |
Wait for end of process. | |
Protected Member Functions | |
virtual std::streambuf::int_type | overflow (std::streambuf::int_type c) |
Called when an overflow occurred. | |
virtual std::streambuf::int_type | underflow () |
Called when an underflow occurred. | |
virtual std::streambuf::int_type | sync () |
Synchronization. | |
Private Member Functions | |
void | initBuffers () |
Initializes obuf and ibuf. | |
Private Attributes | |
int | status |
Status of the child process. | |
unsigned | bufsize |
Buffer size. | |
std::streambuf::char_type * | obuf |
Data of the output buffer. | |
std::streambuf::char_type * | ibuf |
Data of the input buffer. |
A std::streambuf interface for creating child processes and writing/reading data via stdin/stdout.
Definition at line 63 of file ProcessBuf.h.
ProcessBuf::ProcessBuf | ( | const ProcessBuf & | b | ) |
Copy-constructor.
b | Other ProcessBuf. |
Definition at line 84 of file ProcessBuf.cpp.
References initBuffers().
ProcessBuf::~ProcessBuf | ( | ) | [virtual] |
int ProcessBuf::close | ( | bool | kill = false | ) | [virtual] |
Wait for end of process.
If | true the process will be killed, otherwise the method waits. |
Definition at line 338 of file ProcessBuf.cpp.
References endoffile(), ibuf, LOG, and status.
Referenced by DLVProcess::close(), endoffile(), open(), DLVProcess::~DLVProcess(), and ~ProcessBuf().
void ProcessBuf::endoffile | ( | ) | [virtual] |
Send EOF to the process.
Definition at line 300 of file ProcessBuf.cpp.
References bufsize, close(), and obuf.
Referenced by close(), and DLVProcess::endoffile().
void ProcessBuf::initBuffers | ( | ) | [private] |
Initializes obuf and ibuf.
Definition at line 121 of file ProcessBuf.cpp.
References bufsize, ibuf, and obuf.
Referenced by ProcessBuf().
pid_t ProcessBuf::open | ( | const std::vector< std::string > & | c | ) | [virtual] |
Open a commandline in a seprate process.
c | Commandline to open. |
Definition at line 131 of file ProcessBuf.cpp.
References close(), LOG, printvector(), and WARNING().
Referenced by DLVProcess::spawn().
std::streambuf::int_type ProcessBuf::overflow | ( | std::streambuf::int_type | c | ) | [protected, virtual] |
Called when an overflow occurred.
c | See std::streambuf. |
Definition at line 416 of file ProcessBuf.cpp.
References sync().
std::streambuf::int_type ProcessBuf::sync | ( | ) | [protected, virtual] |
Synchronization.
c | See std::streambuf. |
Definition at line 477 of file ProcessBuf.cpp.
References bufsize, ibuf, and obuf.
Referenced by overflow().
std::streambuf::int_type ProcessBuf::underflow | ( | ) | [protected, virtual] |
Called when an underflow occurred.
c | See std::streambuf. |
Definition at line 436 of file ProcessBuf.cpp.
unsigned ProcessBuf::bufsize [private] |
Buffer size.
Definition at line 119 of file ProcessBuf.h.
Referenced by endoffile(), initBuffers(), sync(), and underflow().
std::streambuf::char_type* ProcessBuf::ibuf [private] |
Data of the input buffer.
Definition at line 124 of file ProcessBuf.h.
Referenced by close(), initBuffers(), sync(), underflow(), and ~ProcessBuf().
std::streambuf::char_type* ProcessBuf::obuf [private] |
Data of the output buffer.
Definition at line 122 of file ProcessBuf.h.
Referenced by endoffile(), initBuffers(), sync(), and ~ProcessBuf().
int ProcessBuf::status [private] |