You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Christian P. <cp...@us...> - 2005-01-03 13:56:33
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20346/include/pclasses/IO Modified Files: Makefile.am Log Message: Added Zlib.[h|cpp], IOFilter.[h|cpp] Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 30 Dec 2004 17:17:41 -0000 1.2 +++ Makefile.am 3 Jan 2005 13:56:23 -0000 1.3 @@ -1,3 +1,3 @@ INCLUDES = METASOURCES = AUTO -pkginclude_HEADERS = IOError.h IODevice.h IOStream.h URL.h +pkginclude_HEADERS = IOError.h IODevice.h IOStream.h IOFilter.h URL.h ZLib.h |
From: Christian P. <cp...@us...> - 2005-01-03 13:50:59
|
Update of /cvsroot/pclasses/pclasses2/src/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/src/Net Modified Files: Socket.cpp Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. Index: Socket.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/Socket.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Socket.cpp 23 Dec 2004 06:23:46 -0000 1.3 +++ Socket.cpp 3 Jan 2005 13:50:45 -0000 1.4 @@ -199,72 +199,62 @@ void Socket::open(Domain domain, Type type, int proto) throw(LogicError, IO::IOError) { - if(!valid()) - { - int d; - switch(domain) - { - case Inet: - d = AF_INET; - break; - case Inet6: - d = AF_INET6; - break; - case IPX: - d = AF_IPX; - break; - case AppleTalk: - d = AF_APPLETALK; - break; - } + if(valid()) + close(); - int t; - switch(type) - { - case Stream: - t = SOCK_STREAM; - break; - case Datagram: - t = SOCK_DGRAM; - break; - } + int d; + switch(domain) + { + case Inet: + d = AF_INET; + break; + case Inet6: + d = AF_INET6; + break; + case IPX: + d = AF_IPX; + break; + case AppleTalk: + d = AF_APPLETALK; + break; + } - int ret = ::socket(d, t, proto); - if(ret == -1) - throw IO::IOError(errno, "Could not open socket", P_SOURCEINFO); + int t; + switch(type) + { + case Stream: + t = SOCK_STREAM; + break; + case Datagram: + t = SOCK_DGRAM; + break; + } - IODevice::setAccess(ReadWrite); - IODevice::setValid(true); - IODevice::setEof(false); + int ret = ::socket(d, t, proto); + if(ret == -1) + throw IO::IOError(errno, "Could not open socket", P_SOURCEINFO); - _handle = ret; - _domain = domain; - _type = type; - _proto = proto; + IODevice::setAccess(ReadWrite); + IODevice::setValid(true); + IODevice::setEof(false); - return; - } - - throw LogicError("Socket is already open", P_SOURCEINFO); + _handle = ret; + _domain = domain; + _type = type; + _proto = proto; } -void Socket::close() throw(LogicError, IO::IOError) +void Socket::_close() throw(IO::IOError) { - if(valid()) - { - int ret = ::close(_handle); - if(ret == -1) - throw IO::IOError(errno, "Could not close socket", P_SOURCEINFO); - - IODevice::setAccess(None); - IODevice::setValid(false); - return; - } + int ret = ::close(_handle); + if(ret == -1) + throw IO::IOError(errno, "Could not close socket", P_SOURCEINFO); - throw LogicError("Socket is not open", P_SOURCEINFO); + IODevice::setAccess(None); + IODevice::setValid(false); } -size_t Socket::read(char* buffer, size_t count) throw(IO::IOError) +size_t Socket::_read(char* buffer, size_t count) throw(IO::IOError) { ssize_t ret = ::recv(_handle, (void*)buffer, count, MSG_NOSIGNAL); if(ret == -1) @@ -277,7 +267,7 @@ return ret; } -size_t Socket::peek(char* buffer, size_t count) throw(IO::IOError) +size_t Socket::_peek(char* buffer, size_t count) throw(IO::IOError) { ssize_t ret = ::recv(_handle, (void*)buffer, count, MSG_PEEK|MSG_NOSIGNAL); @@ -287,7 +277,7 @@ return ret; } -size_t Socket::write(const char* buffer, size_t count) throw(IO::IOError) +size_t Socket::_write(const char* buffer, size_t count) throw(IO::IOError) { ssize_t ret = ::send(_handle, (const void*)buffer, count, MSG_NOSIGNAL); |
From: Christian P. <cp...@us...> - 2005-01-03 13:50:58
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/src/IO Modified Files: IODevice.cpp Added Files: IOFilter.cpp Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. Index: IODevice.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/IO/IODevice.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- IODevice.cpp 30 Dec 2004 19:36:48 -0000 1.3 +++ IODevice.cpp 3 Jan 2005 13:50:44 -0000 1.4 @@ -19,59 +19,145 @@ ***************************************************************************/ #include "pclasses/IO/IODevice.h" - +#include "pclasses/IO/IOFilter.h" + namespace P { namespace IO { IODevice::IODevice() throw() -: _valid(false), _access(None), _eof(true) +: _filter(0), _filterOwner(false), _valid(false), _access(None), _eof(true) { } IODevice::IODevice(const IODevice& dev) throw() -: _valid(dev._valid), _access(dev._access), _eof(dev._eof) +: _filter(0), _filterOwner(false), _valid(dev._valid), _access(dev._access), + _eof(dev._eof) { + if(dev._filter) + { + _filter = dev._filter->create(); + _filter->setDevice(this); + _filterOwner = true; + } } IODevice::~IODevice() throw() { + if(_filterOwner) + delete _filter; } -IODevice::AccessMode IODevice::access() const throw() +void IODevice::close() throw(IOError) { - return _access; + if(valid()) + { + if(_filter) + _filter->sync(); + + _close(); + } } -size_t IODevice::peek(char* buffer, size_t count) throw(IOError) +size_t IODevice::read(char* buffer, size_t count) throw(IOError) { - return 0; + return _filter ? _filter->read(buffer, count) : _read(buffer, count); +} + +size_t IODevice::write(const char* buffer, size_t count) throw(IOError) +{ + return _filter ? _filter->write(buffer, count) : _write(buffer, count); } bool IODevice::isSeekable() const throw() { - return false; + return _filter ? _filter->isSeekable() : _isSeekable(); } offset_t IODevice::seek(offset_t offset, SeekMode mode) throw(IOError) { - throw IOError(0, "Could not seek on device", P_SOURCEINFO); + return _filter ? _filter->seek(offset, mode) : _seek(offset, mode); } -offset_t IODevice::getPos() throw(IOError) +size_t IODevice::peek(char* buffer, size_t count) throw(IOError) { - return seek(0, SeekCurrent); + return _filter ? _filter->peek(buffer, count) : _peek(buffer, count); } void IODevice::sync() const throw(IOError) { + if(_filter) + _filter->sync(); + + _sync(); +} + +offset_t IODevice::getPos() throw(IOError) +{ + return seek(0, SeekCurrent); } offset_t IODevice::size() const throw(IOError) { + return _filter ? _filter->size() : _size(); +} + +void IODevice::setFilter(IOFilter* f) throw(LogicError) +{ + // it took me 1 hour to find out why the Pipe test crashed ... + // just to get sure no one else get's into this trap... cproch + if(f && f->device()) + throw LogicError("Filter is already in use", P_SOURCEINFO); + + if(_filter) + { + _filter->setDevice(0); + + if(_filterOwner) + delete _filter; + } + + _filter = f; + _filterOwner = false; + + if(_filter) + _filter->setDevice(this); +} + +IOFilter* IODevice::filter() const throw() +{ + return _filter; +} + +size_t IODevice::_peek(char* buffer, size_t count) throw(IOError) +{ + return 0; +} + +bool IODevice::_isSeekable() const throw() +{ + return false; +} + +offset_t IODevice::_seek(offset_t offset, SeekMode mode) throw(IOError) +{ + throw IOError(0, "Could not seek on device", P_SOURCEINFO); +} + +void IODevice::_sync() const throw(IOError) +{ +} + +offset_t IODevice::_size() const throw(IOError) +{ return 0; } +IODevice::AccessMode IODevice::access() const throw() +{ + return _access; +} + bool IODevice::valid() const throw() { return _valid; @@ -111,10 +197,25 @@ IODevice& IODevice::operator=(const IODevice& dev) throw() { + if(_filterOwner) + { + delete _filter; + _filter = 0; + } + + if(dev._filter) + { + _filter = dev._filter->create(); + _filter->setDevice(this); + _filterOwner = true; + } + else + _filterOwner = false; + _valid = dev._valid; _access = dev._access; _eof = dev._eof; - return *this; + return *this; } --- NEW FILE: IOFilter.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include <pclasses/IO/IOFilter.h> namespace P { namespace IO { IOFilter::IOFilter() : _dev(0) { } IOFilter::~IOFilter() { if(_dev) sync(); } void IOFilter::setDevice(IODevice* dev) { if(_dev) sync(); _dev = dev; } void IOFilter::sync() { _dev->_sync(); } IOFilter* IOFilter::create() { IOFilter* filter = new IOFilter(); return filter; } bool IOFilter::isSeekable() { return _dev->_isSeekable(); } size_t IOFilter::read(char* buffer, size_t count) throw(IO::IOError) { return _dev->_read(buffer, count); } size_t IOFilter::write(const char* buffer, size_t count) throw(IO::IOError) { return _dev->_write(buffer, count); } size_t IOFilter::peek(char* buffer, size_t count) throw(IOError) { return _dev->_peek(buffer, count); } offset_t IOFilter::seek(offset_t offset, IODevice::SeekMode mode) throw(IOError) { return _dev->_seek(offset, mode); } offset_t IOFilter::size() const throw(IOError) { return _dev->_size(); } IODevice* IOFilter::device() const throw() { return _dev; } } // !namespace IO } // !namespace P |
From: Christian P. <cp...@us...> - 2005-01-03 13:50:58
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/src/System Modified Files: File.posix.cpp Pipe.posix.cpp ProcessIO.cpp Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. Index: File.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/File.posix.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- File.posix.cpp 1 Jan 2005 19:00:08 -0000 1.10 +++ File.posix.cpp 3 Jan 2005 13:50:45 -0000 1.11 @@ -85,11 +85,14 @@ File::File(const File& f) throw(IO::IOError) : IODevice(f), _handle((unsigned long)-1) { - int handle = ::dup((int)f._handle); - if(handle == -1) - throw IO::IOError(errno, "Could not duplicate file handle", P_SOURCEINFO); - - _handle = (unsigned long)handle; + if(f.valid()) + { + int handle = ::dup((int)f._handle); + if(handle == -1) + throw IO::IOError(errno, "Could not duplicate file handle", P_SOURCEINFO); + + _handle = (unsigned long)handle; + } } File::File(const Unicode::String& name, AccessMode amode, OpenMode omode, @@ -125,20 +128,17 @@ IODevice::setEof(false); } -void File::close() throw(IO::IOError) +void File::_close() throw(IO::IOError) { - if(valid()) - { - if(::close((int)_handle) == -1) - throw IO::IOError(errno, "Could not close file", P_SOURCEINFO); - - _handle = (unsigned long)-1; - IODevice::setAccess(None); - IODevice::setValid(false); - } + if(::close((int)_handle) == -1) + throw IO::IOError(errno, "Could not close file", P_SOURCEINFO); + + _handle = (unsigned long)-1; + IODevice::setAccess(None); + IODevice::setValid(false); } -size_t File::read(char* buffer, size_t count) throw(IO::IOError) +size_t File::_read(char* buffer, size_t count) throw(IO::IOError) { if(count > SSIZE_MAX) count = SSIZE_MAX; @@ -158,7 +158,7 @@ return ret; } -size_t File::peek(char* buffer, size_t count) throw(IO::IOError) +size_t File::_peek(char* buffer, size_t count) throw(IO::IOError) { if(count > SSIZE_MAX) count = SSIZE_MAX; @@ -177,7 +177,7 @@ return ret; } -size_t File::write(const char* buffer, size_t count) throw(IO::IOError) +size_t File::_write(const char* buffer, size_t count) throw(IO::IOError) { if(count > SSIZE_MAX) count = SSIZE_MAX; @@ -195,7 +195,7 @@ return ret; } -offset_t File::seek(offset_t offset, SeekMode mode) throw(IO::IOError) +offset_t File::_seek(offset_t offset, SeekMode mode) throw(IO::IOError) { int whence; switch(mode) @@ -220,7 +220,7 @@ return ret; } -bool File::isSeekable() const throw() +bool File::_isSeekable() const throw() { struct stat buff; int ret = fstat((int)_handle, &buff); @@ -233,14 +233,14 @@ return false; } -void File::sync() const throw(IO::IOError) +void File::_sync() const throw(IO::IOError) { int ret = fsync((int)_handle); if(ret == -1) throw IO::IOError(errno, "Could not sync file to disk", P_SOURCEINFO); } -offset_t File::size() const throw(IO::IOError) +offset_t File::_size() const throw(IO::IOError) { struct stat buff; int ret = fstat((int)_handle, &buff); @@ -252,6 +252,8 @@ void File::resize(size_t sz) throw(IO::IOError) { + sync(); + int ret = ftruncate((int)_handle, sz); if(ret == -1) throw IO::IOError(errno, "Could not truncate file", P_SOURCEINFO); @@ -259,25 +261,37 @@ File& File::operator=(const File& f) throw(IO::IOError) { - int handle = ::dup((int)f._handle); - if(handle == -1) - throw IO::IOError(errno, "Could not duplicate file handle", P_SOURCEINFO); - - if(valid()) + if(f.valid()) { - try - { - close(); - } - catch(...) + int handle = ::dup((int)f._handle); + if(handle == -1) + throw IO::IOError(errno, "Could not duplicate file handle", P_SOURCEINFO); + + if(valid()) { - ::close(handle); - throw; + try + { + close(); + } + catch(...) + { + ::close(handle); + throw; + } } + + IODevice::operator=(f); + _handle = (unsigned long)handle; } + else + { + if(valid()) + close(); - IODevice::operator=(f); - _handle = (unsigned long)handle; + setValid(false); + setEof(true); + setAccess(None); + } return *this; } Index: ProcessIO.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/ProcessIO.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ProcessIO.cpp 31 Dec 2004 03:22:57 -0000 1.1 +++ ProcessIO.cpp 3 Jan 2005 13:50:45 -0000 1.2 @@ -28,14 +28,19 @@ throw(IO::IOError) : _in(in), _out(out), _err(err) { + setValid(true); + setAccess(ReadWrite); + setEof(false); } ProcessIO::~ProcessIO() throw() { } -void ProcessIO::close() throw(IO::IOError) +void ProcessIO::_close() throw(IO::IOError) { + setValid(false); + _in.close(); _out.close(); _err.close(); @@ -59,12 +64,12 @@ _err.close(); } -size_t ProcessIO::write(const char* buffer, size_t count) throw(IO::IOError) +size_t ProcessIO::_write(const char* buffer, size_t count) throw(IO::IOError) { return _in.write(buffer,count); } -size_t ProcessIO::read(char* buffer, size_t count) throw(IO::IOError) +size_t ProcessIO::_read(char* buffer, size_t count) throw(IO::IOError) { return _out.read(buffer,count); } Index: Pipe.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Pipe.posix.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Pipe.posix.cpp 1 Jan 2005 19:00:08 -0000 1.7 +++ Pipe.posix.cpp 3 Jan 2005 13:50:45 -0000 1.8 @@ -31,7 +31,7 @@ namespace System { Pipe::Pipe(unsigned long h, bool readEnd) throw() -: _handle(h) +: IODevice(), _handle(h) { IODevice::setAccess(readEnd ? Read : Write); IODevice::setValid(true); @@ -41,11 +41,14 @@ Pipe::Pipe(const Pipe& p) throw(IO::IOError) : IODevice(p), _handle((unsigned long)-1) { - int handle = ::dup((int)p._handle); - if(handle == -1) - throw IO::IOError(errno, "Could not duplicate pipe handle", P_SOURCEINFO); - - _handle = (unsigned long)handle; + if(p.valid()) + { + int handle = ::dup((int)p._handle); + if(handle == -1) + throw IO::IOError(errno, "Could not duplicate pipe handle", P_SOURCEINFO); + + _handle = (unsigned long)handle; + } } Pipe::~Pipe() throw() @@ -69,20 +72,17 @@ return std::make_pair(readPipe, writePipe); } -void Pipe::close() throw(IO::IOError) +void Pipe::_close() throw(IO::IOError) { - if(valid()) - { - if(::close((int)_handle) == -1) - throw IO::IOError(errno, "Could not close pipe", P_SOURCEINFO); - - _handle = (unsigned long)-1; - IODevice::setAccess(None); - IODevice::setValid(false); - } + if(::close((int)_handle) == -1) + throw IO::IOError(errno, "Could not close pipe", P_SOURCEINFO); + + _handle = (unsigned long)-1; + IODevice::setAccess(None); + IODevice::setValid(false); } -size_t Pipe::read(char* buffer, size_t count) throw(IO::IOError) +size_t Pipe::_read(char* buffer, size_t count) throw(IO::IOError) { if(count > SSIZE_MAX) count = SSIZE_MAX; @@ -102,7 +102,7 @@ return ret; } -size_t Pipe::write(const char* buffer, size_t count) throw(IO::IOError) +size_t Pipe::_write(const char* buffer, size_t count) throw(IO::IOError) { if(count > SSIZE_MAX) count = SSIZE_MAX; @@ -122,34 +122,47 @@ return ret; } -void Pipe::sync() const throw(IO::IOError) +void Pipe::_sync() const throw(IO::IOError) { + /* pipes cant be synced !! int ret = fsync((int)_handle); if(ret == -1) - throw IO::IOError(errno, "Could not commit to pipe", P_SOURCEINFO); + throw IO::IOError(errno, "Could not commit to pipe", P_SOURCEINFO); */ } Pipe& Pipe::operator=(const Pipe& p) throw(IO::IOError) { - int handle = ::dup((int)p._handle); - if(handle == -1) - throw IO::IOError(errno, "Could not duplicate pipe handle", P_SOURCEINFO); - - if(valid()) + if(p.valid()) { - try - { - close(); - } - catch(...) + int handle = ::dup((int)p._handle); + if(handle == -1) + throw IO::IOError(errno, "Could not duplicate pipe handle", P_SOURCEINFO); + + if(valid()) { - ::close(handle); - throw; + try + { + close(); + } + catch(...) + { + ::close(handle); + throw; + } } + + IODevice::operator=(p); + _handle = (unsigned long)handle; } + else + { + if(valid()) + close(); - IODevice::operator=(p); - _handle = (unsigned long)handle; + setValid(false); + setEof(true); + setAccess(None); + } return *this; } |
From: Christian P. <cp...@us...> - 2005-01-03 13:50:56
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/include/pclasses/IO Modified Files: IODevice.h Added Files: IOFilter.h Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. --- NEW FILE: IOFilter.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_IOFilter_h #define P_IO_IOFilter_h #include <pclasses/IO/IOError.h> #include <pclasses/IO/IODevice.h> namespace P { namespace IO { class IOFilter { public: IOFilter(); virtual ~IOFilter(); void setDevice(IODevice* dev); virtual IOFilter* create(); virtual void sync(); virtual bool isSeekable(); virtual size_t read(char* buffer, size_t count) throw(IOError); virtual size_t write(const char* buffer, size_t count) throw(IO::IOError); virtual size_t peek(char* buffer, size_t count) throw(IOError); virtual offset_t seek(offset_t offset, IODevice::SeekMode mode) throw(IOError); virtual offset_t size() const throw(IOError); IODevice* device() const throw(); private: IODevice* _dev; }; } } // !namespace P #endif Index: IODevice.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IODevice.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- IODevice.h 1 Jan 2005 19:00:08 -0000 1.3 +++ IODevice.h 3 Jan 2005 13:50:44 -0000 1.4 @@ -28,12 +28,14 @@ namespace IO { +class IOFilter; class IOListener; //! I/O Device base class class IODevice { public: friend class IOListener; + friend class IOFilter; enum OpenMode { OpenCreate, @@ -64,24 +66,24 @@ IODevice() throw(); virtual ~IODevice() throw(); - virtual void close() throw(IOError) = 0; + void close() throw(IOError); - virtual size_t read(char* buffer, size_t count) throw(IOError) = 0; + size_t read(char* buffer, size_t count) throw(IOError); - virtual size_t peek(char* buffer, size_t count) throw(IOError); + size_t write(const char* buffer, size_t count) + throw(IOError); - virtual size_t write(const char* buffer, size_t count) - throw(IOError) = 0; + bool isSeekable() const throw(); - virtual bool isSeekable() const throw(); + offset_t seek(offset_t offset, SeekMode mode) throw(IOError); - virtual offset_t seek(offset_t offset, SeekMode mode) throw(IOError); + size_t peek(char* buffer, size_t count) throw(IOError); - virtual offset_t getPos() throw(IOError); + void sync() const throw(IOError); - virtual void sync() const throw(IOError); + offset_t getPos() throw(IOError); - virtual offset_t size() const throw(IOError); + offset_t size() const throw(IOError); bool valid() const throw(); @@ -89,10 +91,30 @@ bool eof() const throw(); + void setFilter(IOFilter* filter) throw(LogicError); + IOFilter* filter() const throw(); + protected: IODevice(const IODevice& dev) throw(); IODevice& operator=(const IODevice& dev) throw(); + virtual void _close() throw(IOError) = 0; + + virtual size_t _read(char* buffer, size_t count) throw(IOError) = 0; + + 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 size_t _peek(char* buffer, size_t count) throw(IOError); + + virtual void _sync() const throw(IOError); + + virtual offset_t _size() const throw(IOError); + void setValid(bool v) throw(); void setAccess(AccessMode mode) throw(); void setEof(bool eof) throw(); @@ -102,6 +124,8 @@ virtual void removeListener(IOListener& l); private: + IOFilter* _filter; + bool _filterOwner; bool _valid; AccessMode _access; bool _eof; |
From: Christian P. <cp...@us...> - 2005-01-03 13:50:56
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/include/pclasses/System Modified Files: File.h Pipe.h ProcessIO.h Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. Index: Pipe.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Pipe.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Pipe.h 1 Jan 2005 19:00:08 -0000 1.7 +++ Pipe.h 3 Jan 2005 13:50:44 -0000 1.8 @@ -41,15 +41,16 @@ static Pair create() throw(IO::IOError); - void close() throw(IO::IOError); + Pipe& operator=(const Pipe& f) throw(IO::IOError); - size_t read(char* buffer, size_t count) throw(IO::IOError); + protected: + void _close() throw(IO::IOError); - size_t write(const char* buffer, size_t count) throw(IO::IOError); + size_t _read(char* buffer, size_t count) throw(IO::IOError); - void sync() const throw(IO::IOError); + size_t _write(const char* buffer, size_t count) throw(IO::IOError); - Pipe& operator=(const Pipe& f) throw(IO::IOError); + void _sync() const throw(IO::IOError); private: unsigned long _handle; Index: File.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/File.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- File.h 1 Jan 2005 19:00:08 -0000 1.8 +++ File.h 3 Jan 2005 13:50:44 -0000 1.9 @@ -56,16 +56,31 @@ OpenMode omode = OpenCreate, ShareMode smode = AllowNone) throw(IO::IOError); + void resize(size_t sz) throw(IO::IOError); + + /** + Copies f. + + @fixme: what are the semantics for copying the + read/write mode? Does copying a file this way + really make sense? If f is locked then this ctor + cannot succeed, right? + */ + File& operator=(const File& f) throw(IO::IOError); + + static FileInfo stat(const Unicode::String& path) throw(IO::IOError); + + protected: /** Frees any resources associated with this object, like filehandles. */ - void close() throw(IO::IOError); + void _close() throw(IO::IOError); /** Reads up to count bytes and stores them in buffer. Returns the number of bytes read. */ - size_t read(char* buffer, size_t count) throw(IO::IOError); + size_t _read(char* buffer, size_t count) throw(IO::IOError); /** Tries to extract up to count bytes from this object @@ -73,50 +88,36 @@ buffer, and the number of bytes read is returned. */ - size_t peek(char* buffer, size_t count) throw(IO::IOError); + size_t _peek(char* buffer, size_t count) throw(IO::IOError); /** Writes count bytes from buffer to this object's internal representation. */ - size_t write(const char* buffer, size_t count) throw(IO::IOError); + size_t _write(const char* buffer, size_t count) throw(IO::IOError); /** Tries to move the current read position to the given offset. SeekMode determines the relative starting point of offset. */ - offset_t seek(offset_t offset, SeekMode mode) throw(IO::IOError); + offset_t _seek(offset_t offset, SeekMode mode) throw(IO::IOError); /** Returns true if seek() is supported. */ - bool isSeekable() const throw(); + bool _isSeekable() const throw(); /** @fixme: Same as conventional sync() functions??? */ - void sync() const throw(IO::IOError); + void _sync() const throw(IO::IOError); /** Returns the size of this File on disk. */ - offset_t size() const throw(IO::IOError); - - void resize(size_t sz) throw(IO::IOError); - - /** - Copies f. - - @fixme: what are the semantics for copying the - read/write mode? Does copying a file this way - really make sense? If f is locked then this ctor - cannot succeed, right? - */ - File& operator=(const File& f) throw(IO::IOError); - - static FileInfo stat(const Unicode::String& path) throw(IO::IOError); + offset_t _size() const throw(IO::IOError); private: unsigned long _handle; Index: ProcessIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/ProcessIO.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ProcessIO.h 31 Dec 2004 03:22:58 -0000 1.1 +++ ProcessIO.h 3 Jan 2005 13:50:44 -0000 1.2 @@ -37,21 +37,22 @@ ProcessIO(const Pipe& in, const Pipe& out, const Pipe& err) throw(IO::IOError); ~ProcessIO() throw(); - //! Close pipe's to child process - void close() throw(IO::IOError); - void closeWrite() throw(IO::IOError); void closeRead() throw(IO::IOError); void closeErr() throw(IO::IOError); + //! Read from process stderr + size_t readErr(char* buffer, size_t count) throw(IO::IOError); + + protected: + //! Close pipe's to child process + void _close() throw(IO::IOError); + //! Write to process stdin - size_t write(const char* buffer, size_t count) throw(IO::IOError); + size_t _write(const char* buffer, size_t count) throw(IO::IOError); //! Read from process stdout - size_t read(char* buffer, size_t count) throw(IO::IOError); - - //! Read from process stderr - size_t readErr(char* buffer, size_t count) throw(IO::IOError); + size_t _read(char* buffer, size_t count) throw(IO::IOError); private: Pipe _in, _out, _err; |
From: Christian P. <cp...@us...> - 2005-01-03 13:50:54
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/include/pclasses/Net Modified Files: Socket.h Log Message: Added IOFilter support to IODevice. Updated classes that inherit from IODevice. Fixed some minor bugs in ProcessIO class. Index: Socket.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Net/Socket.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Socket.h 23 Dec 2004 04:32:16 -0000 1.2 +++ Socket.h 3 Jan 2005 13:50:44 -0000 1.3 @@ -62,14 +62,6 @@ int protocol() const throw(); - void close() throw(LogicError, IO::IOError); - - size_t read(char* buffer, size_t count) throw(IO::IOError); - - size_t peek(char* buffer, size_t count) throw(IO::IOError); - - size_t write(const char* buffer, size_t count) throw(IO::IOError); - int wait(int wait, unsigned int timeout) throw(IO::IOError); //! Bind socket to given address and port @@ -95,6 +87,14 @@ void open(Domain domain, Type type, int proto) throw(LogicError, IO::IOError); + void _close() throw(IO::IOError); + + size_t _read(char* buffer, size_t count) throw(IO::IOError); + + size_t _peek(char* buffer, size_t count) throw(IO::IOError); + + size_t _write(const char* buffer, size_t count) throw(IO::IOError); + int handle() const throw(); void addListener(IO::IOListener& l); |
From: Christian P. <cp...@us...> - 2005-01-03 13:44:01
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18256/src/IO Added Files: ZLib.cpp Log Message: Added zlib compression support (decompression will follow...) --- NEW FILE: ZLib.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/IO/ZLib.h" #include <zlib.h> namespace P { namespace IO { ZLibError::ZLibError(int err, const char* msg, const char* what, const SourceInfo& si) : RuntimeError(what, si), _err(err), _msg(msg ? msg : "") { } ZLibError::~ZLibError() { } int ZLibError::errorNo() const throw() { return _err; } const std::string& ZLibError::msg() const throw() { return _msg; } ZLibStream::ZLibStream() { _strm = new z_stream; _buffer = new char[1024]; _bufferSize = 1024; _strm->zalloc = Z_NULL; _strm->zfree = Z_NULL; _strm->opaque = Z_NULL; _strm->next_in = Z_NULL; _strm->next_out = (Bytef*)_buffer; _strm->avail_in = 0; _strm->avail_out = _bufferSize; _crc32 = ::crc32(0L, Z_NULL, 0); } ZLibStream::~ZLibStream() { delete _strm; delete[] _buffer; } size_t ZLibStream::bytesAvail() const throw() { return _bufferSize - _strm->avail_out; } size_t ZLibStream::read(char* buffer, size_t count) throw(ZLibError) { size_t avail = bytesAvail(); if(count > avail) count = avail; memcpy(buffer, _strm->next_out - avail, count); // move remaining bytes to top of buffer ... if(count < avail) memmove(_buffer, _strm->next_out - avail + count, avail - count); _strm->next_out = (Bytef*)_buffer; _strm->avail_out = _bufferSize; return count; } UInt32 ZLibStream::crc32() const throw() { return _crc32; } void ZLibStream::put(const char* buffer, size_t count) throw(ZLibError) { if(_strm->avail_out < count) throw ZLibError(Z_BUF_ERROR, 0, "Could not put data into output buffer", P_SOURCEINFO); memcpy(_strm->next_out, buffer, count); _strm->next_out += count; _strm->avail_out -= count; } ZLibOutputStream::ZLibOutputStream(int level) throw(ZLibError) : ZLibStream(), _state(Ready) { int ret; if((ret = deflateInit(_strm, level)) != Z_OK) throw ZLibError(ret, _strm->msg, "Could not init zlib deflate", P_SOURCEINFO); putFooter(); } ZLibOutputStream::~ZLibOutputStream() throw() { } void ZLibOutputStream::putHeader() { char header[] = { 0x1f /*magic1*/, 0x8b /*magic2*/, Z_DEFLATED, 0 /*flags*/, 0, 0, 0, 0 /*time*/, 0 /*xflags*/, 0x03 /* OS code*/ }; put(header, sizeof(header)); } void ZLibOutputStream::putFooter() { UInt32 footer[2]; footer[0] = UInt32(_crc32).littleEndian(); footer[1] = UInt32(_strm->total_in).littleEndian(); put((const char*)footer, sizeof(footer)); } size_t ZLibOutputStream::deflate(const char* buffer, size_t count) throw(ZLibError) { if(!count) return 0; size_t deflated = 0; if(_state == Ready) { _strm->next_in = (Bytef*)buffer; _strm->avail_in = count; int ret = ::deflate(_strm, Z_NO_FLUSH); if(ret != Z_OK) throw ZLibError(ret, _strm->msg, "Could not deflate", P_SOURCEINFO); // update crc32 and return with number of bytes consumed ... deflated = count - _strm->avail_in; _crc32 = ::crc32(_crc32, (const Bytef*)buffer, deflated); } return deflated; } bool ZLibOutputStream::finish() throw(ZLibError) { if(_state < AboutToFinish) { int ret = ::deflate(_strm, Z_FINISH); // not enough buffer was avail... should call finish() again if(ret == Z_OK) return false; if(ret != Z_STREAM_END) throw ZLibError(Z_BUF_ERROR, 0, "Could not finish zlib stream", P_SOURCEINFO); _state = AboutToFinish; } if(_state == AboutToFinish) { if(_strm->avail_out < 8) return false; putHeader(); _state = Finished; } return true; } void ZLibOutputStream::reset() throw(ZLibError) { _strm->next_out = (Bytef*)_buffer; _strm->avail_out = _bufferSize; _crc32 = ::crc32(0L, Z_NULL, 0); _state = Ready; deflateReset(_strm); } } // !namespace IO } // !namespace P |
From: Christian P. <cp...@us...> - 2005-01-03 13:44:00
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18256/include/pclasses/IO Added Files: ZLib.h Log Message: Added zlib compression support (decompression will follow...) --- NEW FILE: ZLib.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_ZLib_h #define P_IO_ZLib_h #include <pclasses/Exception.h> #include <pclasses/IntTypes.h> #include <string> struct z_stream_s; typedef z_stream_s z_stream; namespace P { namespace IO { //! ZLib error class ZLibError: public RuntimeError { public: ZLibError(int err, const char* msg, const char* what, const SourceInfo& si); ~ZLibError(); int errorNo() const throw(); const std::string& msg() const throw(); private: int _err; std::string _msg; }; //! ZLib stream base class ZLibStream { public: ZLibStream(); virtual ~ZLibStream(); //! Number of bytes available to consume size_t bytesAvail() const throw(); //! Consume compressed data size_t read(char* buffer, size_t count) throw(ZLibError); //! Returns the crc32 UInt32 crc32() const throw(); protected: void put(const char* buffer, size_t count) throw(ZLibError); z_stream* _strm; char* _buffer; size_t _bufferSize; UInt32 _crc32; }; //! ZLib output (deflate) stream class ZLibOutputStream: public ZLibStream { public: ZLibOutputStream(int level = 6) throw(ZLibError); ~ZLibOutputStream() throw(); //! Deflate (compress) buffer into output buffer size_t deflate(const char* buffer, size_t count) throw(ZLibError); //! Finish compression and reset state bool finish() throw(ZLibError); //! Reset stream void reset() throw(ZLibError); private: void putHeader(); void putFooter(); enum State { Ready, AboutToFinish, Finished }; State _state; }; } // !namespace IO } // !namespace P #endif |
From: stephan b. <sg...@us...> - 2005-01-01 19:44:52
|
Update of /cvsroot/pclasses/pclasses/src/plugins/sql/mysql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10962 Modified Files: psql_mysql.cpp Log Message: added a workaround to read unknown db data types into a char*. This allows, e.g., TEXT and BLOB fields to be read. Index: psql_mysql.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses/src/plugins/sql/mysql/psql_mysql.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- psql_mysql.cpp 29 Nov 2004 03:34:56 -0000 1.15 +++ psql_mysql.cpp 1 Jan 2005 19:44:42 -0000 1.16 @@ -22,6 +22,7 @@ #include "pclasses/psqlplugin.h" #include <map> +#include <string> #include <sstream> // Some workarounds for includig MySQL -- duplicated defines and the @@ -412,25 +413,34 @@ } #endif - case FIELD_TYPE_STRING: - case FIELD_TYPE_VAR_STRING: + default: +// case FIELD_TYPE_MEDIUM_BLOB: +// case FIELD_TYPE_LONG_BLOB: +// case FIELD_TYPE_BLOB: +// case FIELD_TYPE_VAR_STRING: +// case FIELD_TYPE_STRING: +// case FIELD_TYPE_TIMESTAMP: +// case FIELD_TYPE_DATE: +// case FIELD_TYPE_TIME: +// case FIELD_TYPE_DATETIME: +// case FIELD_TYPE_YEAR: { if(field_val) - val = new SQLString(field_val); + { + std::string buff( field_val, field_val + field->length ); + val = new SQLString(buff.c_str()); + } else + { val = new SQLString(); + } } break; - case FIELD_TYPE_TIMESTAMP: - case FIELD_TYPE_DATE: - case FIELD_TYPE_TIME: - case FIELD_TYPE_DATETIME: - case FIELD_TYPE_YEAR: - //@todo fetch date/time value - { - } - break; +// //@todo fetch date/time value +// { +// } +// break; } delete[] field_val; |
From: stephan b. <sg...@us...> - 2005-01-01 19:43:36
|
Update of /cvsroot/pclasses/pclasses/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10714 Modified Files: piodevice.common.cpp Log Message: added string form of read() Index: piodevice.common.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses/src/core/piodevice.common.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- piodevice.common.cpp 10 Mar 2004 19:34:09 -0000 1.1 +++ piodevice.common.cpp 1 Jan 2005 19:43:16 -0000 1.2 @@ -17,6 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <vector> +#include <string> #include "pclasses/piodevice.h" namespace P { @@ -38,4 +40,16 @@ } } +size_t +IODevice::read( std::string & buffer, size_t count ) throw(IOError) +{ + typedef std::vector<char> VC; + VC v(count,'\0'); + size_t ret = this->read( &v[0], count ); + buffer = (0 == ret) + ? "" + : std::string( v.begin(), v.begin() + ret ); + return ret; +} + } |
From: stephan b. <sg...@us...> - 2005-01-01 19:42:51
|
Update of /cvsroot/pclasses/pclasses/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10540 Modified Files: pthreadpool.cpp Log Message: removed an unused var, to stop a warning from the compiler Index: pthreadpool.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses/src/core/pthreadpool.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pthreadpool.cpp 3 May 2004 06:47:22 -0000 1.5 +++ pthreadpool.cpp 1 Jan 2005 19:42:36 -0000 1.6 @@ -276,7 +276,7 @@ { m_lock.lock(); - ThreadJob* job = (ThreadJob*)worker->m_job; + // ThreadJob* job = (ThreadJob*)worker->m_job; /* finish job, killing the worker thread if max number of idle threads is already reached ... */ |
From: stephan b. <sg...@us...> - 2005-01-01 19:42:03
|
Update of /cvsroot/pclasses/pclasses/src/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10355 Modified Files: piorequest.cpp Log Message: added string form of receive() Index: piorequest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses/src/io/piorequest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- piorequest.cpp 27 Feb 2004 02:09:46 -0000 1.1 +++ piorequest.cpp 1 Jan 2005 19:41:54 -0000 1.2 @@ -17,6 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <string> +#include <vector> #include "pclasses/piorequest.h" namespace P { @@ -47,6 +49,20 @@ {} + +size_t +IORequest_Get::receive( std::string & buffer, size_t count ) +{ + typedef std::vector<char> VC; + VC v(count,'\0'); + size_t ret = this->receive( &v[0], count ); + buffer = (0 == ret) + ? "" + : std::string( v.begin(), v.begin() + ret ); + return ret; +} + + IORequest_Put::IORequest_Put(IOHandler* handler, const URL& url) : IORequest(handler,url) {} |
From: stephan b. <sg...@us...> - 2005-01-01 19:40:25
|
Update of /cvsroot/pclasses/pclasses/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10117 Modified Files: piodevice.h piorequest.h Log Message: added std::string form of read/receive() Index: piodevice.h =================================================================== RCS file: /cvsroot/pclasses/pclasses/include/pclasses/piodevice.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- piodevice.h 10 Mar 2004 19:35:01 -0000 1.12 +++ piodevice.h 1 Jan 2005 19:40:09 -0000 1.13 @@ -20,6 +20,8 @@ #ifndef _piodevice_h_ #define _piodevice_h_ +#include <string> + #include <pclasses/pconfig.h> #include <pclasses/pexport.h> #include <pclasses/pexception.h> @@ -99,6 +101,8 @@ //! Read from device virtual size_t read(char* buffer, size_t count) throw(IOError); + //! Same as read(char*,size_t) but writes to the given std::string + size_t read( std::string & buffer, size_t count ) throw(IOError); //! Peek incoming data on device /*! Index: piorequest.h =================================================================== RCS file: /cvsroot/pclasses/pclasses/include/pclasses/piorequest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- piorequest.h 3 Mar 2004 09:20:17 -0000 1.2 +++ piorequest.h 1 Jan 2005 19:40:09 -0000 1.3 @@ -147,6 +147,9 @@ less than requested. */ virtual size_t receive(char* buff, size_t count) = 0; + //! Same as receive(char*,size_t) but writes to the given std::string + size_t receive( std::string & buffer, size_t count ); + }; //! Network I/O Put-request |
From: stephan b. <sg...@us...> - 2005-01-01 19:24:37
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6900/include/pclasses/IO Added Files: StringDevice.h Log Message: egg. IO experiment. --- NEW FILE: StringDevice.h --- #ifndef P_IO_STRINGDEVICE_HPP_INCLUDED #define P_IO_STRINGDEVICE_HPP_INCLUDED 1 #include "pclasses/IO/IODevice.h" #include "pclasses/Unicode/String.h" namespace P { namespace IO { /** StringDevice is an experiment to get to know the IO layer better. It implements an IODevice interface into a Unicode::String buffer of arbitrary size. */ class StringDevice : public IODevice { public: typedef ::P::Unicode::String StringType; StringDevice(){} virtual ~StringDevice() throw() {} virtual size_t read(char *buffer, size_t count) throw (IOError); virtual size_t peek(char *buffer, size_t count) throw (IOError); virtual size_t write(const char *buffer, size_t count) throw (IOError); virtual offset_t seek(offset_t offset, SeekMode mode) throw (IOError); virtual void close() throw (IOError) {} virtual offset_t getPos() throw (IOError) { return this->m_pos; } virtual bool isSeekable() const throw () { return true; } virtual void sync() const throw (IOError) {} virtual offset_t size () const throw (IOError) { return this->m_buf.size(); } StringType & str() { return this->m_buf; } const StringType & str() const { return this->m_buf; } private: size_t m_pos; StringType m_buf; }; } } // namespace P::IO #endif // P_IO_STRINGDEVICE_HPP_INCLUDED |
From: stephan b. <sg...@us...> - 2005-01-01 19:24:36
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6900/src/IO Added Files: StringDevice.cpp Log Message: egg. IO experiment. --- NEW FILE: StringDevice.cpp --- #include "pclasses/IO/StringDevice.h" namespace P { namespace IO { size_t StringDevice::peek(char *buffer, size_t count) throw (IOError) { size_t at = this->getPos(); size_t to = ( (count + at) > this->size() ) ? this->size() : at + count; size_t ret = 0; for( ; at < to; at++ ) { buffer[ret++] = this->m_buf.at(at).latin1(); } return ret; } size_t StringDevice::read(char *buffer, size_t count) throw (IOError) { size_t s1 = this->size(); this->m_pos += this->peek( buffer, count ); return this->m_pos - s1; } size_t StringDevice::write(const char *buffer, size_t count) throw (IOError) { if( ! buffer || !count ) return 0; size_t s1 = this->size(); this->m_buf.append( StringDevice::StringType( buffer, count ) ); return this->m_buf.size() - s1; } offset_t StringDevice::seek(offset_t offset, SeekMode mode) throw (IOError) { // NYI return -1; } } } // namespace P::IO |
From: stephan b. <sg...@us...> - 2005-01-01 19:19:43
|
Update of /cvsroot/pclasses/pclasses/src/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5089 Modified Files: purl.cpp Log Message: changed to empty throw()s to throw InvalidURL Index: purl.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses/src/net/purl.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- purl.cpp 5 Jan 2004 17:17:59 -0000 1.8 +++ purl.cpp 1 Jan 2005 19:19:30 -0000 1.9 @@ -120,12 +120,11 @@ if((is >> ch) && ch == '/' && (is >> ch) && ch == '/') break; - - throw; + throw InvalidURL(std::string("Invalid url: "+url).c_str(), P_SOURCEINFO); + } else if(!isalnum(ch) && !isalpha(ch)) - throw; - + throw InvalidURL(std::string("Invalid url: "+url).c_str(), P_SOURCEINFO); os << ch; } |
From: Christian P. <cp...@us...> - 2005-01-01 19:00:21
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv395/src/System Modified Files: Pipe.posix.cpp File.posix.cpp Log Message: Removed LogicError from open()/close() new semantics: open(): reopen with new file close(): closes file (when open) Index: File.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/File.posix.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- File.posix.cpp 31 Dec 2004 03:21:19 -0000 1.9 +++ File.posix.cpp 1 Jan 2005 19:00:08 -0000 1.10 @@ -108,28 +108,24 @@ } void File::open(const Unicode::String& name, AccessMode amode, OpenMode omode, - ShareMode smode) throw(LogicError, IO::IOError) + ShareMode smode) throw(IO::IOError) { - if(!valid()) - { - int flags = OpenMode2Flags(omode) | AccessMode2Flags(amode); - - int handle = ::open(name.utf8().c_str(), flags, 0644); - if(handle == -1) - throw IO::IOError(errno, "Could not open file", P_SOURCEINFO); - - _handle = (unsigned long)handle; - IODevice::setAccess(amode); - IODevice::setValid(true); - IODevice::setEof(false); + if(valid()) + close(); + + int flags = OpenMode2Flags(omode) | AccessMode2Flags(amode); - return; - } + int handle = ::open(name.utf8().c_str(), flags, 0644); + if(handle == -1) + throw IO::IOError(errno, "Could not open file", P_SOURCEINFO); - throw LogicError("File is already open", P_SOURCEINFO); + _handle = (unsigned long)handle; + IODevice::setAccess(amode); + IODevice::setValid(true); + IODevice::setEof(false); } -void File::close() throw(LogicError, IO::IOError) +void File::close() throw(IO::IOError) { if(valid()) { @@ -139,10 +135,7 @@ _handle = (unsigned long)-1; IODevice::setAccess(None); IODevice::setValid(false); - return; } - - throw LogicError("File is not open", P_SOURCEINFO); } size_t File::read(char* buffer, size_t count) throw(IO::IOError) Index: Pipe.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Pipe.posix.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Pipe.posix.cpp 30 Dec 2004 19:36:48 -0000 1.6 +++ Pipe.posix.cpp 1 Jan 2005 19:00:08 -0000 1.7 @@ -69,7 +69,7 @@ return std::make_pair(readPipe, writePipe); } -void Pipe::close() throw(LogicError, IO::IOError) +void Pipe::close() throw(IO::IOError) { if(valid()) { @@ -79,10 +79,7 @@ _handle = (unsigned long)-1; IODevice::setAccess(None); IODevice::setValid(false); - return; } - - throw LogicError("Pipe is not open", P_SOURCEINFO); } size_t Pipe::read(char* buffer, size_t count) throw(IO::IOError) |
From: Christian P. <cp...@us...> - 2005-01-01 19:00:18
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv395/include/pclasses/System Modified Files: Pipe.h File.h Log Message: Removed LogicError from open()/close() new semantics: open(): reopen with new file close(): closes file (when open) Index: Pipe.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Pipe.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Pipe.h 31 Dec 2004 03:20:41 -0000 1.6 +++ Pipe.h 1 Jan 2005 19:00:08 -0000 1.7 @@ -41,7 +41,7 @@ static Pair create() throw(IO::IOError); - void close() throw(LogicError, IO::IOError); + void close() throw(IO::IOError); size_t read(char* buffer, size_t count) throw(IO::IOError); Index: File.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/File.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- File.h 31 Dec 2004 03:21:18 -0000 1.7 +++ File.h 1 Jan 2005 19:00:08 -0000 1.8 @@ -54,12 +54,12 @@ */ void open(const Unicode::String& name, AccessMode amode, OpenMode omode = OpenCreate, - ShareMode smode = AllowNone) throw(LogicError, IO::IOError); + ShareMode smode = AllowNone) throw(IO::IOError); /** Frees any resources associated with this object, like filehandles. */ - void close() throw(LogicError, IO::IOError); + void close() throw(IO::IOError); /** Reads up to count bytes and stores them in |
From: Christian P. <cp...@us...> - 2005-01-01 19:00:17
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv395/include/pclasses/IO Modified Files: IODevice.h Log Message: Removed LogicError from open()/close() new semantics: open(): reopen with new file close(): closes file (when open) Index: IODevice.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IO/IODevice.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IODevice.h 30 Dec 2004 19:36:47 -0000 1.2 +++ IODevice.h 1 Jan 2005 19:00:08 -0000 1.3 @@ -64,7 +64,7 @@ IODevice() throw(); virtual ~IODevice() throw(); - virtual void close() throw(LogicError, IOError) = 0; + virtual void close() throw(IOError) = 0; virtual size_t read(char* buffer, size_t count) throw(IOError) = 0; |
From: Christian P. <cp...@us...> - 2004-12-31 18:44:14
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32377/include/pclasses Added Files: Signal.h Log Message: Added beginning of Signals --- NEW FILE: Signal.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_Signal_h #define P_Signal_h #include <pclasses/Callback.h> #include <list> namespace P { template <class ListType, class CallbackType> void bind_slot(ListType& list, CallbackType cb) { list.push_back(new CallbackType(cb)); } template <class ListType, class CallbackType> void unbind_slot(ListType& list, CallbackType cb) { typename ListType::iterator i = list.begin(); while(i != list.end()) { if(*i == cb) { delete *i; list.erase(i); break; } ++i; } } template <class ListType> void unbind_slots(ListType& list) { typename ListType::iterator i = list.begin(); while(i != list.end()) { delete *i; i = list.erase(i); } } /* -------------------- Signal0 ---------------- */ template <class RetType> class SignalBase0 { public: typedef std::list< Callback0<RetType>* > CallbackList; SignalBase0() { } virtual ~SignalBase0() { unbind_slots(_slots); } template <class CallbackType> void bind(CallbackType slot) { bind_slot(_slots, slot); } template <class CallbackType> void unbind(CallbackType slot) { unbind_slot(_slots, slot); } virtual RetType exec() const = 0; protected: CallbackList _slots; }; template <class RetType> class Signal0: public SignalBase0<RetType> { public: RetType exec() const { RetType ret = RetType(); typename CallbackList::const_iterator i = _slots.begin(); while(i != _slots.end()) { ret = (*i)->exec(); if(!ret) break; ++i; } return ret; } }; template <> class Signal0<void>: public SignalBase0<void> { public: void exec() const { CallbackList::const_iterator i = _slots.begin(); while(i != _slots.end()) { (*i)->exec(); ++i; } } }; } // !namespace P #endif |
From: Christian P. <cp...@us...> - 2004-12-31 18:43:51
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32154/include/pclasses Added Files: Callback.h Log Message: Added Callback proxy templates. --- NEW FILE: Callback.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_Callback_h #define P_Callback_h namespace P { /* ----------------- Callback0 ------------------ */ template <typename RetType> class Callback0 { public: virtual ~Callback0() { } virtual RetType exec() = 0; protected: Callback0() { } }; template <> class Callback0<void> { public: virtual ~Callback0() { } virtual void exec() = 0; protected: Callback0() { } }; /* -------------- Function0 ------------- */ template <typename RetType> class Function0: public Callback0<RetType> { public: typedef RetType (*FuncPtr)(); Function0(FuncPtr ptr) : _funcPtr(ptr) { } RetType exec() { return (*_funcPtr)(); } private: FuncPtr _funcPtr; }; template <> class Function0<void>: public Callback0<void> { public: typedef void (*FuncPtr)(); Function0(FuncPtr ptr) : _funcPtr(ptr) { } void exec() { (*_funcPtr)(); } private: FuncPtr _funcPtr; }; template <typename RetType> Function0<RetType> callback(RetType (*ptr)()) { return Function0<RetType>(ptr); } /* ---------- Method0 ------------ */ template <typename RetType, class ObjT> class Method0: public Callback0<RetType> { public: typedef RetType (ObjT::*FuncPtr)(); Method0(ObjT* obj, FuncPtr ptr) : _obj(obj), _funcPtr(ptr) { } RetType exec() { return (_obj->*_funcPtr)(); } private: ObjT* _obj; FuncPtr _funcPtr; }; template <class ObjT> class Method0<void, ObjT>: public Callback0<void> { public: typedef void (ObjT::*FuncPtr)(); Method0(ObjT* obj, FuncPtr ptr) : _obj(obj), _funcPtr(ptr) { } void exec() { (_obj->*_funcPtr)(); } private: ObjT* _obj; FuncPtr _funcPtr; }; template <typename RetType, class ObjT> Method0<RetType,ObjT> callback(ObjT* obj, RetType (ObjT::*ptr)()) { return Method0<RetType,ObjT>(obj, ptr); } } // !namespace P #endif |
From: stephan b. <sg...@us...> - 2004-12-31 17:42:15
|
Update of /cvsroot/pclasses/pclasses2/src/SIO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20285/src/SIO Modified Files: Makefile.toc registrations.cpp SIO.h Log Message: Reverted from S11nNode "fat" type to s11n_node, because: a) it introduces a circular dep on nodes and serializables. b) since it inherits a Serializabe, it is Serializable, and a Serializable node logically makes no sense. Nodes ARE the state, and we don't save the state of the state. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/SIO/Makefile.toc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.toc 31 Dec 2004 16:15:57 -0000 1.3 +++ Makefile.toc 31 Dec 2004 17:41:59 -0000 1.4 @@ -7,11 +7,12 @@ SOURCES = \ registrations.cpp \ - S11nNode.cpp \ SIO.cpp +# S11nNode.cpp -HEADERS = $(wildcard *.h) +HEADERS = SIO.h +# $(wildcard *.h) OBJECTS = $(patsubst %.cpp,%.o,$(SOURCES)) Index: registrations.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/SIO/registrations.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- registrations.cpp 31 Dec 2004 16:15:57 -0000 1.2 +++ registrations.cpp 31 Dec 2004 17:41:59 -0000 1.3 @@ -6,7 +6,6 @@ #include <pclasses/pclasses-config.h> // PCLASSES_HAVE_LIBEXPAT #include <pclasses/SIO/SIO.h> -#include <pclasses/SIO/S11nNode.h> #ifdef PCLASSES_HAVE_LIBEXPAT // KLUDGE until i get S11nNode fully integrated... Index: SIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/SIO/SIO.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SIO.h 29 Dec 2004 19:54:44 -0000 1.1 +++ SIO.h 31 Dec 2004 17:41:59 -0000 1.2 @@ -27,7 +27,7 @@ #include <pclasses/s11n/s11n.h> #include <pclasses/s11n/io/serializers.h> #include <pclasses/Plugin/Plugin.h> -#include <pclasses/SIO/S11nNode.h> +// #include <pclasses/SIO/S11nNode.h> namespace P { @@ -56,6 +56,7 @@ namespace SIO { + typedef ::P::s11n::s11n_node S11nNode; /** NodeTraits provide the interface for fetching and manipulating S11nNode data. |
From: stephan b. <sg...@us...> - 2004-12-31 17:42:12
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20285/test Modified Files: s11nTest.cpp Log Message: Reverted from S11nNode "fat" type to s11n_node, because: a) it introduces a circular dep on nodes and serializables. b) since it inherits a Serializabe, it is Serializable, and a Serializable node logically makes no sense. Nodes ARE the state, and we don't save the state of the state. Index: s11nTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/s11nTest.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- s11nTest.cpp 30 Dec 2004 22:56:03 -0000 1.10 +++ s11nTest.cpp 31 Dec 2004 17:41:59 -0000 1.11 @@ -472,18 +472,18 @@ save( thedate, std::cout ); save( dt, std::cout ); - CERR << "Using S11nNode-specific API...\n"; - NODE_TYPE tmnode; - assert( tmnode.serialize( dt ) ); - assert( save( tmnode, std::cout ) ); +// CERR << "Using S11nNode-specific API...\n"; +// NODE_TYPE tmnode; +// assert( tmnode.serialize( dt ) ); +// assert( save( tmnode, std::cout ) ); - DateTime * pdt = tmnode.deserialize<DateTime>(); - assert( pdt ); - CERR << "deserialized (DateTime*) == " << *pdt<<"\n"; - delete pdt; - DateTime vdt; - assert( tmnode.deserialize( vdt ) ); - CERR << "deserialized DateTime == " << vdt<<"\n"; +// DateTime * pdt = tmnode.deserialize<DateTime>(); +// assert( pdt ); +// CERR << "deserialized (DateTime*) == " << *pdt<<"\n"; +// delete pdt; +// DateTime vdt; +// assert( tmnode.deserialize( vdt ) ); +// CERR << "deserialized DateTime == " << vdt<<"\n"; } |
From: stephan b. <sg...@us...> - 2004-12-31 17:24:35
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16562/include/pclasses/System Modified Files: Mime.h Log Message: Removed empty MimePluginHandler type. It introduces a circular dep on Plugin, and isn't necessary (a typedef will do). Index: Mime.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Mime.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Mime.h 25 Dec 2004 18:58:32 -0000 1.9 +++ Mime.h 31 Dec 2004 17:24:25 -0000 1.10 @@ -322,17 +322,4 @@ } } // P::System -#include "pclasses/Plugin/Plugin.h" -namespace P { - -namespace System -{ - template <typename InterfaceT> - class MimeHandlerFactory : public ::P::Plugin::PluginManager< InterfaceT > - { - - }; - -} } // P::System - #endif |