From: Christian P. <cp...@us...> - 2004-12-23 04:32:25
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14702/include/pclasses/IO Added Files: IODevice.h IOError.h Makefile.am Log Message: Moved IODevice, IOError into P::IO namespace. Moved Char, String, TextStream into P::Unicode namespace. --- NEW FILE: IODevice.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_IO_IODevice_h #define P_IO_IODevice_h #include <pclasses/BasicTypes.h> #include <pclasses/IO/IOError.h> namespace P { namespace IO { class IOListener; //! I/O Device base class class IODevice { public: friend class IOListener; enum OpenMode { OpenCreate, CreateFail, OpenFail }; enum AccessMode { None = 0x00, Read = 0x01, Write = 0x02, ReadWrite = 0x03 }; enum ShareMode { AllowNone = 0x00, AllowRead = 0x01, AllowWrite = 0x02, AllowReadWrite = 0x03 }; enum SeekMode { SeekSet, SeekCurrent, SeekEnd }; IODevice() throw(); virtual ~IODevice() throw(); virtual void close() throw(LogicError, IOError) = 0; virtual size_t read(char* buffer, size_t count) throw(IOError) = 0; virtual size_t peek(char* buffer, size_t count) throw(IOError); virtual size_t write(const char* buffer, size_t count) throw(IOError) = 0; virtual bool isSeekable() const throw(); virtual offset_t seek(offset_t offset, SeekMode mode) throw(IOError); virtual offset_t getPos() throw(IOError); virtual void commit() const throw(IOError); virtual offset_t size() const throw(IOError); bool valid() const throw(); AccessMode access() const throw(); bool eof() const throw(); protected: IODevice(const IODevice& dev) throw(); IODevice& operator=(const IODevice& dev) throw(); void setValid(bool v) throw(); void setAccess(AccessMode mode) throw(); void setEof(bool eof) throw(); virtual void addListener(IOListener& l); virtual void updateListener(IOListener& l); virtual void removeListener(IOListener& l); private: bool _valid; AccessMode _access; bool _eof; }; class IOListener { public: enum EventFlags { None = 0x0, Read = 0x1, Write = 0x2, ReadWrite = 0x03 }; IOListener(IODevice& dev, int eventMask) throw(); virtual ~IOListener() throw(); IODevice& device() const throw(); void setDevice(IODevice& dev) throw(); int eventMask() const throw(); void setEventMask(int eventMask) throw(); virtual void onRead() = 0; virtual void onWrite() = 0; private: IODevice* _dev; int _eventMask; }; } // !namespace IO } // !namespace P #endif --- NEW FILE: Makefile.am --- INCLUDES = METASOURCES = AUTO pkginclude_HEADERS = IOError.h IODevice.h --- NEW FILE: IOError.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_IO_IOError_h #define P_IO_IOError_h #include <pclasses/Exception.h> #include <pclasses/Unicode/String.h> namespace P { namespace IO { //! I/O Error class class IOError: public RuntimeError { public: IOError(long errorNo, const char* what, const SourceInfo& si) throw(); IOError(const IOError& err) throw(); ~IOError() throw(); long errorNo() const throw(); virtual Unicode::String text() const throw(); private: long _errorNo; }; } // !namespace IO } // !namespace P #endif |