yast2-core
|
Bidirectional stream to external data. More...
#include <ExternalDataSource.h>
Public Member Functions | |
ExternalDataSource (FILE *inputfile=0, FILE *outputfile=0) | |
virtual | ~ExternalDataSource () |
bool | send (const char *buffer, size_t length) |
bool | send (std::string s) |
size_t | receive (char *buffer, size_t length) |
std::string | receiveLine () |
std::string | receiveUpto (char c) |
void | setBlocking (bool mode) |
virtual int | close () |
FILE * | inputFile () const |
FILE * | outputFile () const |
Protected Attributes | |
FILE * | inputfile |
FILE * | outputfile |
Private Attributes | |
char * | linebuffer |
size_t | linebuffer_size |
Bidirectional stream to external data.
ExternalDataSource::ExternalDataSource | ( | FILE * | inputfile = 0 , |
FILE * | outputfile = 0 |
||
) |
Create a new instance.
inputfile | The stream for reading |
outputfile | The stream for writing Either can be NULL if no reading/writing is allowed. |
|
virtual |
Implicitly close the connection.
References close(), and linebuffer.
|
virtual |
Close the input and output streams.
Reimplemented in ExternalProgram.
References inputfile, and outputfile.
Referenced by ExternalProgram::close(), and ~ExternalDataSource().
|
inline |
Return the input stream.
References inputfile.
|
inline |
size_t ExternalDataSource::receive | ( | char * | buffer, |
size_t | length | ||
) |
Read some data from the input stream.
buffer | Where to put the data |
length | How much to read at most Returns the amount actually received |
References inputfile.
Referenced by Process::readStdoutToBuffer().
string ExternalDataSource::receiveLine | ( | ) |
Read one line from the input stream. Returns the line read, including the terminator.
References stringutil::getline(), inputfile, linebuffer, and linebuffer_size.
Referenced by PathInfo::clean_dir(), PathInfo::copy(), PathInfo::copy_dir(), PathInfo::copy_file2dir(), and PathInfo::recursive_rmdir().
string ExternalDataSource::receiveUpto | ( | char | c | ) |
Read characters into a string until character c is read. C is put at the end of the string.
References inputfile, and result().
Referenced by Process::BufferNewStdoutLines().
bool ExternalDataSource::send | ( | const char * | buffer, |
size_t | length | ||
) |
Send some data to the output stream.
buffer | The data to send |
length | The size of it |
References outputfile.
bool ExternalDataSource::send | ( | std::string | s | ) |
void ExternalDataSource::setBlocking | ( | bool | mode | ) |
Set the blocking mode of the input stream.
mode | True if the reader should be blocked waiting for input. This is the initial default. |
References ERR, and inputfile.
Referenced by main(), and ProcessAgent::ProcessOutput().
|
protected |
Referenced by close(), inputFile(), receive(), receiveLine(), receiveUpto(), setBlocking(), and ExternalProgram::start_program().
|
private |
Referenced by receiveLine(), and ~ExternalDataSource().
|
private |
Referenced by receiveLine().
|
protected |
Referenced by close(), outputFile(), send(), and ExternalProgram::start_program().