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