libzypp: zypp::externalprogram::ExternalDataSource Class Reference

libzypp 17.38.6

zypp::externalprogram::ExternalDataSource Class Reference

Bidirectional stream to external data. More...

`#include <zypp-core/base/ExternalDataSource.h>`

Inheritance diagram for zypp::externalprogram::ExternalDataSource:

## Public Member Functions
| ExternalDataSource (FILE *inputfile=0, FILE *outputfile=0)
| Create a new instance.
virtual | ~ExternalDataSource ()
| Implicitly close the connection.
bool | send (const char *buffer, size_t length)
| Send some data to the output stream.
bool | send (std::string s)
| Send some data down the stream.
size_t | receive (char *buffer, size_t length)
| Read some data from the input stream.
std::string | receiveLine ()
| Read one line from the input stream.
std::string | receiveLine (io::timeout_type timeout)
| Read one line from the input stream.
std::string | receiveUpto (char c)
| Read characters into a string until delimiter c or EOF is read.
std::string | receiveUpto (char c, io::timeout_type timeout)
| Read characters into a string until delimiter c or EOF is read or the timeout is reached.
void | setBlocking (bool mode)
| Set the blocking mode of the input stream.
virtual int | close ()
| Close the input and output streams.
FILE * | inputFile () const
| Return the input stream.
FILE * | outputFile () const
| Return the output stream.

## Protected Attributes
FILE * | inputfile
FILE * | outputfile

## Private Attributes
char * | linebuffer
size_t | linebuffer_size

## Detailed Description

Bidirectional stream to external data.

Definition at line 27 of file ExternalDataSource.h.

## Constructor & Destructor Documentation

## ◆ ExternalDataSource()

zypp::externalprogram::ExternalDataSource::ExternalDataSource | ( | FILE * | inputfile = 0,
|  | FILE * | outputfile = 0 )

Create a new instance.

Parameters

  inputfile | The stream for reading
  outputfile | The stream for writing Either can be NULL if no reading/writing is allowed.

Definition at line 35 of file ExternalDataSource.cc.

## ◆ ~ExternalDataSource()

zypp::externalprogram::ExternalDataSource::~ExternalDataSource | ( |  | ) |
| virtual

Implicitly close the connection.

Definition at line 44 of file ExternalDataSource.cc.

## Member Function Documentation

## ◆ send() [1/2]

bool zypp::externalprogram::ExternalDataSource::send | ( | const char * | buffer,
|  | size_t | length )

Send some data to the output stream.

Parameters

  buffer | The data to send
  length | The size of it

Definition at line 53 of file ExternalDataSource.cc.

## ◆ send() [2/2]

bool zypp::externalprogram::ExternalDataSource::send | ( | std::string | s | ) |

Send some data down the stream.

Parameters

  string | The data to send

Definition at line 66 of file ExternalDataSource.cc.

## ◆ receive()

size_t zypp::externalprogram::ExternalDataSource::receive | ( | char * | buffer,
|  | size_t | length )

Read some data from the input stream.

Parameters

  buffer | Where to put the data
  length | How much to read at most Returns the amount actually received

Definition at line 102 of file ExternalDataSource.cc.

## ◆ receiveLine() [1/2]

std::string zypp::externalprogram::ExternalDataSource::receiveLine | ( |  | ) |

Read one line from the input stream.

Returns the line read, including the terminator.

Definition at line 115 of file ExternalDataSource.cc.

## ◆ receiveLine() [2/2]

std::string zypp::externalprogram::ExternalDataSource::receiveLine | ( | io::timeout_type | timeout | ) |

Read one line from the input stream.

Returns the line read, including the terminator.

Note
  The delimiter is not removed from the string.
  The timeout value is to be specified in milliseconds.

Exceptions

  io::TimeoutException | if the timeout is reached

Definition at line 128 of file ExternalDataSource.cc.

## ◆ receiveUpto() [1/2]

std::string zypp::externalprogram::ExternalDataSource::receiveUpto | ( | char | c | ) |

Read characters into a string until delimiter c or EOF is read.

Note
  The delimiter is not removed from the string.

Definition at line 74 of file ExternalDataSource.cc.

## ◆ receiveUpto() [2/2]

std::string zypp::externalprogram::ExternalDataSource::receiveUpto | ( | char | c,
|  | io::timeout_type | timeout )

Read characters into a string until delimiter c or EOF is read or the timeout is reached.

Note
  The delimiter is not removed from the string.
  The timeout value is to be specified in milliseconds.

Exceptions

  io::TimeoutException | if the timeout is reached

Definition at line 91 of file ExternalDataSource.cc.

## ◆ setBlocking()

void zypp::externalprogram::ExternalDataSource::setBlocking | ( | bool | mode | ) |

Set the blocking mode of the input stream.

Parameters

  mode | True if the reader should be blocked waiting for input. This is the initial default.

Definition at line 110 of file ExternalDataSource.cc.

## ◆ close()

int zypp::externalprogram::ExternalDataSource::close | ( |  | ) |
| virtual

Close the input and output streams.

Reimplemented in zypp::ExternalProgram.

Definition at line 134 of file ExternalDataSource.cc.

## ◆ inputFile()

FILE * zypp::externalprogram::ExternalDataSource::inputFile | ( |  | ) | const
| inline

Return the input stream.

Definition at line 118 of file ExternalDataSource.h.

## ◆ outputFile()

FILE * zypp::externalprogram::ExternalDataSource::outputFile | ( |  | ) | const
| inline

Return the output stream.

Definition at line 123 of file ExternalDataSource.h.

## Member Data Documentation

## ◆ inputfile

FILE* zypp::externalprogram::ExternalDataSource::inputfile
| protected

Definition at line 30 of file ExternalDataSource.h.

## ◆ outputfile

FILE* zypp::externalprogram::ExternalDataSource::outputfile
| protected

Definition at line 31 of file ExternalDataSource.h.

## ◆ linebuffer

char* zypp::externalprogram::ExternalDataSource::linebuffer
| private

Definition at line 34 of file ExternalDataSource.h.

## ◆ linebuffer_size

size_t zypp::externalprogram::ExternalDataSource::linebuffer_size
| private

Definition at line 35 of file ExternalDataSource.h.

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

- zypp-core/base/ExternalDataSource.h
- zypp-core/base/ExternalDataSource.cc