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