summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/Handle.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/includes/Handle.h b/includes/Handle.h
index f304086..d205925 100644
--- a/includes/Handle.h
+++ b/includes/Handle.h
@@ -2,6 +2,7 @@
#include <Exceptions.h>
#include <Printer.h>
+#include <BString.h>
namespace Balau {
@@ -50,6 +51,8 @@ class Handle {
virtual time_t getMTime();
ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException);
ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException);
+ ssize_t write(const String & str) { return write(str.to_charp(), str.strlen()); }
+ uint8_t readU8() { uint8_t r; read(&r, 1); return r; }
protected:
Handle() : m_refCount(0) { }
private:
@@ -68,6 +71,19 @@ class Handle {
int m_refCount;
};
+class HPrinter : public Handle {
+ public:
+ virtual void close() throw (GeneralException) { }
+ virtual bool isClosed() { return false; }
+ virtual bool isEOF() { return false; }
+ virtual bool canWrite() { return true; }
+ virtual const char * getName() { return "HPrinter"; }
+ virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) {
+ Printer::print("%s", (const char *) buf);
+ return count;
+ }
+};
+
class IOBase {
public:
IOBase() : m_h(NULL) { }