Panda3D

subStream.h

00001 // Filename: subStream.h
00002 // Created by:  drose (02Aug02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef SUBSTREAM_H
00016 #define SUBSTREAM_H
00017 
00018 #include "pandabase.h"
00019 #include "subStreamBuf.h"
00020 #include "streamWrapper.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : ISubStream
00024 // Description : An istream object that presents a subwindow into
00025 //               another istream.  The first character read from this
00026 //               stream will be the "start" character from the source
00027 //               istream; just before the file pointer reaches the
00028 //               "end" character, eof is returned.
00029 //
00030 //               The source stream must be one that we can randomly
00031 //               seek within.  The resulting ISubStream will also
00032 //               support arbitrary seeks.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDAEXPRESS ISubStream : public istream {
00035 PUBLISHED:
00036   INLINE ISubStream();
00037   INLINE ISubStream(IStreamWrapper *source, streampos start, streampos end);
00038 
00039   INLINE ISubStream &open(IStreamWrapper *source, streampos start, streampos end);
00040   INLINE ISubStream &close();
00041 
00042 private:
00043   SubStreamBuf _buf;
00044 };
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //       Class : OSubStream
00048 // Description : An ostream object that presents a subwindow into
00049 //               another ostream.  The first character written to this
00050 //               stream will be the "start" character in the dest
00051 //               istream; no characters may be written to character
00052 //               "end" or later (unless end is zero).
00053 //
00054 //               The dest stream must be one that we can randomly
00055 //               seek within.  The resulting OSubStream will also
00056 //               support arbitrary seeks.
00057 ////////////////////////////////////////////////////////////////////
00058 class EXPCL_PANDAEXPRESS OSubStream : public ostream {
00059 PUBLISHED:
00060   INLINE OSubStream();
00061   INLINE OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append = false);
00062 
00063   INLINE OSubStream &open(OStreamWrapper *dest, streampos start, streampos end, bool append = false);
00064   INLINE OSubStream &close();
00065 
00066 private:
00067   SubStreamBuf _buf;
00068 };
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //       Class : SubStream
00072 // Description : Combined ISubStream and OSubStream for bidirectional
00073 //               I/O.
00074 ////////////////////////////////////////////////////////////////////
00075 class EXPCL_PANDAEXPRESS SubStream : public iostream {
00076 PUBLISHED:
00077   INLINE SubStream();
00078   INLINE SubStream(StreamWrapper *nested, streampos start, streampos end, bool append = false);
00079 
00080   INLINE SubStream &open(StreamWrapper *nested, streampos start, streampos end, bool append = false);
00081   INLINE SubStream &close();
00082 
00083 private:
00084   SubStreamBuf _buf;
00085 };
00086 
00087 #include "subStream.I"
00088 
00089 #endif
00090 
00091 
 All Classes Functions Variables Enumerations