libzypp  17.23.8
ExternalDataSource.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_EXTERNALDATASOURCE_H
13 #define ZYPP_EXTERNALDATASOURCE_H
14 
15 #include <stdio.h>
16 
17 #include <string>
18 
19 namespace zypp {
20  namespace externalprogram {
21 
26  {
27  protected:
28  FILE *inputfile;
29  FILE *outputfile;
30 
31  private:
32  char *linebuffer;
34 
35  public:
42  ExternalDataSource(FILE *inputfile = 0, FILE *outputfile = 0);
43 
47  virtual ~ExternalDataSource();
48 
54  bool send (const char *buffer, size_t length);
55 
60  bool send (std::string s);
61 
68  size_t receive(char *buffer, size_t length);
69 
74  std::string receiveLine();
75 
80  std::string receiveUpto(char c);
86  void setBlocking(bool mode);
87 
91  virtual int close();
92 
96  FILE *inputFile() const { return inputfile; }
97 
101  FILE *outputFile() const { return outputfile; }
102  };
103 
104  } // namespace externalprogram
105 } // namespace zypp
106 
107 #endif // ZYPP_EXTERNALDATASOURCE_H
108 
zypp::externalprogram::ExternalDataSource::close
virtual int close()
Close the input and output streams.
Definition: ExternalDataSource.cc:142
zypp::externalprogram::ExternalDataSource::receive
size_t receive(char *buffer, size_t length)
Read some data from the input stream.
Definition: ExternalDataSource.cc:92
zypp::externalprogram::ExternalDataSource::linebuffer_size
size_t linebuffer_size
Definition: ExternalDataSource.h:33
zypp::externalprogram::ExternalDataSource::~ExternalDataSource
virtual ~ExternalDataSource()
Implicitly close the connection.
Definition: ExternalDataSource.cc:43
zypp::externalprogram::ExternalDataSource::send
bool send(const char *buffer, size_t length)
Send some data to the output stream.
Definition: ExternalDataSource.cc:52
zypp::externalprogram::ExternalDataSource::receiveUpto
std::string receiveUpto(char c)
Read characters into a string until character c is read.
Definition: ExternalDataSource.cc:73
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::externalprogram::ExternalDataSource::outputFile
FILE * outputFile() const
Return the output stream.
Definition: ExternalDataSource.h:101
zypp::externalprogram::ExternalDataSource::inputfile
FILE * inputfile
Definition: ExternalDataSource.h:28
zypp::externalprogram::ExternalDataSource::setBlocking
void setBlocking(bool mode)
Set the blocking mode of the input stream.
Definition: ExternalDataSource.cc:100
zypp::externalprogram::ExternalDataSource::receiveLine
std::string receiveLine()
Read one line from the input stream.
Definition: ExternalDataSource.cc:126
zypp::externalprogram::ExternalDataSource::outputfile
FILE * outputfile
Definition: ExternalDataSource.h:29
zypp::externalprogram::ExternalDataSource::linebuffer
char * linebuffer
Definition: ExternalDataSource.h:32
zypp::externalprogram::ExternalDataSource
Bidirectional stream to external data.
Definition: ExternalDataSource.h:25
zypp::externalprogram::ExternalDataSource::ExternalDataSource
ExternalDataSource(FILE *inputfile=0, FILE *outputfile=0)
Create a new instance.
Definition: ExternalDataSource.cc:34
zypp::externalprogram::ExternalDataSource::inputFile
FILE * inputFile() const
Return the input stream.
Definition: ExternalDataSource.h:96