|
1 /* |
|
2 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 * contributor license agreements. See the NOTICE file distributed with |
|
4 * this work for additional information regarding copyright ownership. |
|
5 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 * (the "License"); you may not use this file except in compliance with |
|
7 * the License. You may obtain a copy of the License at |
|
8 * |
|
9 * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 * |
|
11 * Unless required by applicable law or agreed to in writing, software |
|
12 * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 * See the License for the specific language governing permissions and |
|
15 * limitations under the License. |
|
16 */ |
|
17 |
|
18 /* |
|
19 * |
|
20 * Revision 1.5 2004/09/08 13:56:21 peiyongz |
|
21 * Apache License Version 2.0 |
|
22 * |
|
23 * Revision 1.4 2004/01/29 11:48:46 cargilld |
|
24 * Code cleanup changes to get rid of various compiler diagnostic messages. |
|
25 * |
|
26 * Revision 1.3 2003/05/16 03:11:22 knoaman |
|
27 * Partial implementation of the configurable memory manager. |
|
28 * |
|
29 * Revision 1.2 2002/11/04 15:22:03 tng |
|
30 * C++ Namespace Support. |
|
31 * |
|
32 * Revision 1.1.1.1 2002/02/01 22:22:10 peiyongz |
|
33 * sane_include |
|
34 * |
|
35 * Revision 1.3 2000/02/24 20:05:24 abagchi |
|
36 * Swat for removing Log from API docs |
|
37 * |
|
38 * Revision 1.2 2000/02/06 07:48:01 rahulj |
|
39 * Year 2K copyright swat. |
|
40 * |
|
41 * Revision 1.1.1.1 1999/11/09 01:04:07 twl |
|
42 * Initial checkin |
|
43 * |
|
44 * Revision 1.3 1999/11/08 20:45:04 rahul |
|
45 * Swat for adding in Product name and CVS comment log variable. |
|
46 * |
|
47 */ |
|
48 |
|
49 #if !defined(BINMEMINPUTSTREAM_HPP) |
|
50 #define BINMEMINPUTSTREAM_HPP |
|
51 |
|
52 #include <xercesc/util/BinInputStream.hpp> |
|
53 #include <xercesc/util/PlatformUtils.hpp> |
|
54 |
|
55 XERCES_CPP_NAMESPACE_BEGIN |
|
56 |
|
57 class XMLUTIL_EXPORT BinMemInputStream : public BinInputStream |
|
58 { |
|
59 public : |
|
60 // ----------------------------------------------------------------------- |
|
61 // Class specific types |
|
62 // ----------------------------------------------------------------------- |
|
63 enum BufOpts |
|
64 { |
|
65 BufOpt_Adopt |
|
66 , BufOpt_Copy |
|
67 , BufOpt_Reference |
|
68 }; |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------- |
|
72 // Constructors and Destructor |
|
73 // ----------------------------------------------------------------------- |
|
74 BinMemInputStream |
|
75 ( |
|
76 const XMLByte* const initData |
|
77 , const unsigned int capacity |
|
78 , const BufOpts bufOpt = BufOpt_Copy |
|
79 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
80 ); |
|
81 virtual ~BinMemInputStream(); |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------- |
|
85 // Stream management methods |
|
86 // ----------------------------------------------------------------------- |
|
87 void reset(); |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------- |
|
91 // Implementation of the input stream interface |
|
92 // ----------------------------------------------------------------------- |
|
93 virtual unsigned int curPos() const; |
|
94 |
|
95 virtual unsigned int readBytes |
|
96 ( |
|
97 XMLByte* const toFill |
|
98 , const unsigned int maxToRead |
|
99 ); |
|
100 |
|
101 inline unsigned int getSize() const; |
|
102 |
|
103 private : |
|
104 // ----------------------------------------------------------------------- |
|
105 // Unimplemented constructors and operators |
|
106 // ----------------------------------------------------------------------- |
|
107 BinMemInputStream(const BinMemInputStream&); |
|
108 BinMemInputStream& operator=(const BinMemInputStream&); |
|
109 // ----------------------------------------------------------------------- |
|
110 // Private data members |
|
111 // |
|
112 // fBuffer |
|
113 // The buffer of bytes that we are streaming. |
|
114 // |
|
115 // fBufOpt |
|
116 // Indicates the ownership status of the buffer. The caller can have |
|
117 // us adopt it (we delete it), reference it, or just make our own |
|
118 // copy of it. |
|
119 // |
|
120 // fCapacity |
|
121 // The size of the buffer being streamed. |
|
122 // |
|
123 // fCurIndex |
|
124 // The current index where the next byte will be read from. When it |
|
125 // hits fCapacity, we are done. |
|
126 // ----------------------------------------------------------------------- |
|
127 const XMLByte* fBuffer; |
|
128 BufOpts fBufOpt; |
|
129 unsigned int fCapacity; |
|
130 unsigned int fCurIndex; |
|
131 MemoryManager* fMemoryManager; |
|
132 }; |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // BinMemInputStream: Stream management methods |
|
137 // --------------------------------------------------------------------------- |
|
138 inline void BinMemInputStream::reset() |
|
139 { |
|
140 fCurIndex = 0; |
|
141 } |
|
142 |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // BinMemInputStream: Implementation of the input stream interface |
|
146 // --------------------------------------------------------------------------- |
|
147 inline unsigned int BinMemInputStream::curPos() const |
|
148 { |
|
149 return fCurIndex; |
|
150 } |
|
151 |
|
152 inline unsigned int BinMemInputStream::getSize() const |
|
153 { |
|
154 return fCapacity; |
|
155 } |
|
156 |
|
157 XERCES_CPP_NAMESPACE_END |
|
158 |
|
159 #endif |