Panda3D
subStream.h
1 // Filename: subStream.h
2 // Created by: drose (02Aug02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SUBSTREAM_H
16 #define SUBSTREAM_H
17 
18 #include "pandabase.h"
19 #include "subStreamBuf.h"
20 #include "streamWrapper.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ISubStream
24 // Description : An istream object that presents a subwindow into
25 // another istream. The first character read from this
26 // stream will be the "start" character from the source
27 // istream; just before the file pointer reaches the
28 // "end" character, eof is returned.
29 //
30 // The source stream must be one that we can randomly
31 // seek within. The resulting ISubStream will also
32 // support arbitrary seeks.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDAEXPRESS ISubStream : public istream {
35 PUBLISHED:
36  INLINE ISubStream();
37  INLINE ISubStream(IStreamWrapper *source, streampos start, streampos end);
38 
39  INLINE ISubStream &open(IStreamWrapper *source, streampos start, streampos end);
40  INLINE ISubStream &close();
41 
42 private:
43  SubStreamBuf _buf;
44 };
45 
46 ////////////////////////////////////////////////////////////////////
47 // Class : OSubStream
48 // Description : An ostream object that presents a subwindow into
49 // another ostream. The first character written to this
50 // stream will be the "start" character in the dest
51 // istream; no characters may be written to character
52 // "end" or later (unless end is zero).
53 //
54 // The dest stream must be one that we can randomly
55 // seek within. The resulting OSubStream will also
56 // support arbitrary seeks.
57 ////////////////////////////////////////////////////////////////////
58 class EXPCL_PANDAEXPRESS OSubStream : public ostream {
59 PUBLISHED:
60  INLINE OSubStream();
61  INLINE OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append = false);
62 
63  INLINE OSubStream &open(OStreamWrapper *dest, streampos start, streampos end, bool append = false);
64  INLINE OSubStream &close();
65 
66 private:
67  SubStreamBuf _buf;
68 };
69 
70 ////////////////////////////////////////////////////////////////////
71 // Class : SubStream
72 // Description : Combined ISubStream and OSubStream for bidirectional
73 // I/O.
74 ////////////////////////////////////////////////////////////////////
75 class EXPCL_PANDAEXPRESS SubStream : public iostream {
76 PUBLISHED:
77  INLINE SubStream();
78  INLINE SubStream(StreamWrapper *nested, streampos start, streampos end, bool append = false);
79 
80  INLINE SubStream &open(StreamWrapper *nested, streampos start, streampos end, bool append = false);
81  INLINE SubStream &close();
82 
83 private:
84  SubStreamBuf _buf;
85 };
86 
87 #include "subStream.I"
88 
89 #endif
90 
91 
This class provides a locking wrapper around a combination ostream/istream pointer.
An istream object that presents a subwindow into another istream.
Definition: subStream.h:34
This class provides a locking wrapper around an arbitrary istream pointer.
Definition: streamWrapper.h:53
The streambuf object that implements ISubStream.
Definition: subStreamBuf.h:25
An ostream object that presents a subwindow into another ostream.
Definition: subStream.h:58
This class provides a locking wrapper around an arbitrary ostream pointer.
Definition: streamWrapper.h:81
Combined ISubStream and OSubStream for bidirectional I/O.
Definition: subStream.h:75