#ifndef _PBQTIO_H #define _PBQTIO_H #include class PbQtInputStream : public google::protobuf::io::CopyingInputStream { public: PbQtInputStream(QIODevice *dev) : dev_(dev) {}; int Read(void *buffer, int size) { if (dev_->bytesAvailable()) return dev_->read(static_cast(buffer), size); else return 0; } private: QIODevice *dev_; }; class PbQtOutputStream : public google::protobuf::io::CopyingOutputStream { public: PbQtOutputStream(QIODevice *dev) : dev_(dev) {}; bool Write(const void *buffer, int size) { if (dev_->write(static_cast(buffer), size) == size) return true; else return false; } private: QIODevice *dev_; }; #endif