• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/io/DesStream.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _desstream_h
00018 #define _desstream_h
00019 
00020 #include <spl/types.h>
00021 #include <spl/Debug.h>
00022 #include <spl/Des.h>
00023 #include <spl/io/Stream.h>
00024 #include <spl/String.h>
00025 
00032 class DesStream;
00033 typedef RefCountPtrCast<DesStream, spl::IStream, spl::IStreamPtr> DesStreamPtr;
00034 typedef WeakReference<DesStream, spl::IStreamPtr> DesStreamRef;
00035 
00036 REGISTER_TYPEOF(80, DesStreamPtr);
00037 REGISTER_TYPEOF( 448, DesStreamRef );
00038 
00042 class DesStream : public spl::IStream
00043 {
00044 protected:
00045         DES m_des;
00046         String m_password;
00047         spl::IStreamPtr m_stream;
00048         bool m_ownStream;
00049 
00050 public:
00051         DesStream(const String& password, spl::IStreamPtr stream);
00052         virtual ~DesStream();
00053 
00054         virtual void Close();
00055         virtual void Flush();
00056         virtual int Read(Array<byte>& buffer, const int offset, int count);
00057         virtual int ReadByte();
00058         virtual long Seek(const long offset, const SeekOrigin origin);
00059         virtual void Write(const Array<byte>& buffer, const int offset, const int count);
00060         virtual void WriteByte(byte value);
00061 
00062         virtual bool CanRead() const;
00063         virtual bool CanSeek() const;
00064         virtual bool CanWrite() const;
00065 
00066         virtual long Length() const;
00067         virtual long Position() const;
00068 
00069 #ifdef DEBUG
00070         virtual void ValidateMem() const;
00071         virtual void CheckMem() const;
00072 #endif
00073 };
00074 
00075 REGISTER_TYPEOF(82, DesStream);
00076 
00079 #endif