libzypp  13.10.6
ExternalDataSource.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
15 #ifndef ZYPP_EXTERNALDATASOURCE_H
16 #define ZYPP_EXTERNALDATASOURCE_H
17 
18 #include <stdio.h>
19 
20 #include <string>
21 
22 namespace zypp {
23  namespace externalprogram {
24 
29  {
30  protected:
31  FILE *inputfile;
32  FILE *outputfile;
33 
34  private:
35  char *linebuffer;
37 
38  public:
45  ExternalDataSource(FILE *inputfile = 0, FILE *outputfile = 0);
46 
50  virtual ~ExternalDataSource();
51 
57  bool send (const char *buffer, size_t length);
58 
63  bool send (std::string s);
64 
71  size_t receive(char *buffer, size_t length);
72 
77  std::string receiveLine();
78 
83  std::string receiveUpto(char c);
89  void setBlocking(bool mode);
90 
94  virtual int close();
95 
99  FILE *inputFile() const { return inputfile; }
100 
104  FILE *outputFile() const { return outputfile; }
105  };
106 
107  } // namespace externalprogram
108 } // namespace zypp
109 
110 #endif // ZYPP_EXTERNALDATASOURCE_H
111 
Bidirectional stream to external data.
std::string receiveUpto(char c)
Read characters into a string until character c is read.
size_t receive(char *buffer, size_t length)
Read some data from the input stream.
ExternalDataSource(FILE *inputfile=0, FILE *outputfile=0)
Create a new instance.
virtual int close()
Close the input and output streams.
std::string receiveLine()
Read one line from the input stream.
FILE * inputFile() const
Return the input stream.
void setBlocking(bool mode)
Set the blocking mode of the input stream.
FILE * outputFile() const
Return the output stream.
virtual ~ExternalDataSource()
Implicitly close the connection.
bool send(const char *buffer, size_t length)
Send some data to the output stream.