Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

StreamCoder.h

00001 /*****************************************************************************
00002  * Author:   Valient Gough <vgough@pobox.com>
00003  *
00004  *****************************************************************************
00005  * Copyright (c) 2001, Valient Gough
00006  *
00007  * This library is free software; you can distribute it and/or modify it under
00008  * the terms of the GNU Lesser General Public License (LGPL), as published by
00009  * the Free Software Foundation; either version 2.1 of the License, or (at your
00010  * option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
00015  * details.
00016  *
00017  */
00018 
00019 #ifndef _StreamCoder_incl_
00020 #define _StreamCoder_incl_
00021 
00022 #include <rel/IODevice.h>
00023 #include <rel/SmartPtr.h>
00024 
00025 #include <string>
00026 
00027 namespace rel
00028 {
00029 
00035     class StreamCoder
00036     {
00037     public:
00038         typedef IODevice::size_type size_type;
00039 
00040         StreamCoder(const SmartPtr<IODevice> &passThru);
00041         virtual ~StreamCoder();
00042 
00043 
00044         virtual bool read(int8_t &) const;
00045         virtual bool read(uint8_t &) const;
00046         virtual bool read(int16_t &) const;
00047         virtual bool read(uint16_t &) const;
00048         virtual bool read(int32_t &) const;
00049         virtual bool read(uint32_t &) const;
00050         virtual bool read(int64_t &) const;
00051         virtual bool read(uint64_t &) const;
00052         virtual bool read(float &) const;
00053         virtual bool read(double &) const;
00054         virtual bool read(std::string &) const;
00055 
00056 
00057         virtual bool write(int8_t);
00058         virtual bool write(uint8_t);
00059         virtual bool write(int16_t);
00060         virtual bool write(uint16_t);
00061         virtual bool write(int32_t);
00062         virtual bool write(uint32_t);
00063         virtual bool write(int64_t);
00064         virtual bool write(uint64_t);
00065         virtual bool write(float);
00066         virtual bool write(double);
00067         virtual bool write(const std::string &);
00068 
00069 
00070         // functions from IODevice
00071         virtual int getReadDescriptor() const;
00072         virtual bool isDirectAccess() const;
00073         virtual size_type at() const;
00074         virtual bool at(size_type offset);
00075         virtual bool atEnd() const;
00076         virtual void flush();
00077 
00078         // These are the same as the read/write(string) functions.  They write
00079         // a length specifier to the stream followed by the data.
00080         virtual bool writeBytes(const char *data, size_type len);
00081         virtual bool readBytes(char *data, size_type maxLen) const;
00082 
00083         // read/write the raw data.  These do not store length specifiers
00084         virtual size_type writeRawBytes(const char *data, size_type len);
00085         virtual size_type readRawBytes(char *data, size_type maxLen) const;
00086 
00087         virtual SmartPtr<char*> print();
00088 
00089     protected:
00090         SmartPtr<IODevice> passThru;
00091     };
00092 
00093 } // namespace rel
00094 
00095 #endif
00096 

Generated at Sat Sep 22 02:20:00 2001 for librel by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001