blob: 8ce7c782bdfa8d0556ed34f782aca52fbd91c43e [file] [log] [blame]
Roger Meier86e89862012-02-10 19:53:20 +00001#ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_
2#define _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_ 1
3
4#include <QIODevice>
5
6#include <boost/shared_ptr.hpp>
7
8#include <transport/TVirtualTransport.h>
9
10namespace apache { namespace thrift { namespace protocol {
11class TProtocol;
12}}} // apache::thrift::protocol
13
14namespace apache { namespace thrift { namespace transport {
15
16 class TQIODeviceTransport : public apache::thrift::transport::TVirtualTransport<TQIODeviceTransport> {
17 public:
18 explicit TQIODeviceTransport(boost::shared_ptr<QIODevice> dev);
19 ~TQIODeviceTransport();
20
21 void open();
22
23 bool isOpen();
24
25 bool peek();
26
27 void close();
28
29 uint32_t readAll(uint8_t *buf, uint32_t len);
30
31 uint32_t read(uint8_t* buf, uint32_t len);
32
33 void write(const uint8_t* buf, uint32_t len);
34
35 uint32_t write_partial(const uint8_t* buf, uint32_t len);
36
37 void flush();
38
39 uint8_t* borrow(uint8_t* buf, uint32_t* len);
40 void consume(uint32_t len);
41
42 private:
43 boost::shared_ptr<QIODevice> dev_;
44 };
45}}} // apache::thrift::transport
46
47#endif // #ifndef _THRIFT_ASYNC_TQIODEVICE_TRANSPORT_H_
48