Panda3D
 All Classes Functions Variables Enumerations
subStream.I
1 // Filename: subStream.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ISubStream::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE ISubStream::
22 ISubStream() : istream(&_buf) {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: ISubStream::Constructor
27 // Access: Public
28 // Description:
29 ////////////////////////////////////////////////////////////////////
30 INLINE ISubStream::
31 ISubStream(IStreamWrapper *source, streampos start, streampos end) : istream(&_buf) {
32  open(source, start, end);
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: ISubStream::open
37 // Access: Public
38 // Description: Starts the SubStream reading from the indicated
39 // source, with the first character being the character
40 // at position "start" within the source, for end -
41 // start total characters. The character at "end"
42 // within the source will never be read; this will
43 // appear to be EOF.
44 //
45 // If end is zero, it indicates that the ISubStream will
46 // continue until the end of the source stream.
47 ////////////////////////////////////////////////////////////////////
49 open(IStreamWrapper *source, streampos start, streampos end) {
50  clear((ios_iostate)0);
51  _buf.open(source, NULL, start, end, false);
52  return *this;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: ISubStream::close
57 // Access: Public
58 // Description: Resets the SubStream to empty, but does not actually
59 // close the source istream.
60 ////////////////////////////////////////////////////////////////////
62 close() {
63  _buf.close();
64  return *this;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: OSubStream::Constructor
69 // Access: Public
70 // Description:
71 ////////////////////////////////////////////////////////////////////
72 INLINE OSubStream::
73 OSubStream() : ostream(&_buf) {
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: OSubStream::Constructor
78 // Access: Public
79 // Description:
80 ////////////////////////////////////////////////////////////////////
81 INLINE OSubStream::
82 OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append) : ostream(&_buf) {
83  open(dest, start, end, append);
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: OSubStream::open
88 // Access: Public
89 // Description: Starts the SubStream reading from the indicated
90 // dest, with the first character being the character
91 // at position "start" within the dest, for end -
92 // start total characters. The character at "end"
93 // within the dest will never be read; this will
94 // appear to be EOF.
95 //
96 // If end is zero, it indicates that the OSubStream will
97 // continue until the end of the dest stream.
98 ////////////////////////////////////////////////////////////////////
100 open(OStreamWrapper *dest, streampos start, streampos end, bool append) {
101  clear((ios_iostate)0);
102  _buf.open(NULL, dest, start, end, append);
103  return *this;
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: OSubStream::close
108 // Access: Public
109 // Description: Resets the SubStream to empty, but does not actually
110 // close the dest ostream.
111 ////////////////////////////////////////////////////////////////////
112 INLINE OSubStream &OSubStream::
113 close() {
114  _buf.close();
115  return *this;
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: SubStream::Constructor
120 // Access: Public
121 // Description:
122 ////////////////////////////////////////////////////////////////////
123 INLINE SubStream::
124 SubStream() : iostream(&_buf) {
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: SubStream::Constructor
129 // Access: Public
130 // Description:
131 ////////////////////////////////////////////////////////////////////
132 INLINE SubStream::
133 SubStream(StreamWrapper *nested, streampos start, streampos end, bool append) : iostream(&_buf) {
134  open(nested, start, end, append);
135 }
136 
137 ////////////////////////////////////////////////////////////////////
138 // Function: SubStream::open
139 // Access: Public
140 // Description: Starts the SubStream reading and writing from the
141 // indicated nested stream, within the indicated range.
142 // "end" is the first character outside of the range.
143 //
144 // If end is zero, it indicates that the SubStream will
145 // continue until the end of the nested stream.
146 ////////////////////////////////////////////////////////////////////
147 INLINE SubStream &SubStream::
148 open(StreamWrapper *nested, streampos start, streampos end, bool append) {
149  clear((ios_iostate)0);
150  _buf.open(nested, nested, start, end, append);
151  return *this;
152 }
153 
154 ////////////////////////////////////////////////////////////////////
155 // Function: SubStream::close
156 // Access: Public
157 // Description: Resets the SubStream to empty, but does not actually
158 // close the nested ostream.
159 ////////////////////////////////////////////////////////////////////
160 INLINE SubStream &SubStream::
161 close() {
162  _buf.close();
163  return *this;
164 }
165 
166 
ISubStream & open(IStreamWrapper *source, streampos start, streampos end)
Starts the SubStream reading from the indicated source, with the first character being the character ...
Definition: subStream.I:49
OSubStream & open(OStreamWrapper *dest, streampos start, streampos end, bool append=false)
Starts the SubStream reading from the indicated dest, with the first character being the character at...
Definition: subStream.I:100
This class provides a locking wrapper around a combination ostream/istream pointer.
OSubStream & close()
Resets the SubStream to empty, but does not actually close the dest ostream.
Definition: subStream.I:113
SubStream & open(StreamWrapper *nested, streampos start, streampos end, bool append=false)
Starts the SubStream reading and writing from the indicated nested stream, within the indicated range...
Definition: subStream.I:148
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
ISubStream & close()
Resets the SubStream to empty, but does not actually close the source istream.
Definition: subStream.I:62
SubStream & close()
Resets the SubStream to empty, but does not actually close the nested ostream.
Definition: subStream.I:161
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