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 |