Xerces-C++ 3.3.0
MemBufInputSource.hpp
Go to the documentation of this file.
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 * $Id$
20 */
21
22
23#if !defined(XERCESC_INCLUDE_GUARD_MEMBUFINPUTSOURCE_HPP)
24#define XERCESC_INCLUDE_GUARD_MEMBUFINPUTSOURCE_HPP
25
27
29
30class BinInputStream;
31
32
64{
65public :
66 // -----------------------------------------------------------------------
67 // Constructors and Destructor
68 // -----------------------------------------------------------------------
69
72
96 (
97 const XMLByte* const srcDocBytes
98 , const XMLSize_t byteCount
99 , const XMLCh* const bufId
100 , const bool adoptBuffer = false
102 );
103
109 (
110 const XMLByte* const srcDocBytes
111 , const XMLSize_t byteCount
112 , const char* const bufId
113 , const bool adoptBuffer = false
115 );
117
126
127
128 // -----------------------------------------------------------------------
129 // Virtual input source interface
130 // -----------------------------------------------------------------------
131
134
146
148
149
150 // -----------------------------------------------------------------------
151 // Setter methods
152 // -----------------------------------------------------------------------
153
157
173 void setCopyBufToStream(const bool newState);
174
184 void resetMemBufInputSource(const XMLByte* const srcDocBytes
185 , const XMLSize_t byteCount);
187
188
189private :
190 // -----------------------------------------------------------------------
191 // Unimplemented constructors and operators
192 // -----------------------------------------------------------------------
194 MemBufInputSource& operator=(const MemBufInputSource&);
195
196 // -----------------------------------------------------------------------
197 // Private data members
198 //
199 // fAdopted
200 // Indicates whether the buffer is adopted or not. If so, then it
201 // is destroyed when the input source is destroyed.
202 //
203 // fByteCount
204 // The size of the source document.
205 //
206 // fCopyBufToStream
207 // This defaults to true (the safe option), which causes it to
208 // give a copy of the buffer to any streams it creates. If you set
209 // it to false, it will allow the streams to just reference the
210 // buffer (in which case this input source must stay alive as long
211 // as the buffer is in use by the stream.)
212 //
213 // fSrcBytes
214 // The source memory buffer that is being spooled from. Whether it
215 // belongs to the this input source or not is controlled by the
216 // fAdopted flag.
217 // -----------------------------------------------------------------------
218 bool fAdopted;
219 XMLSize_t fByteCount;
220 bool fCopyBufToStream;
221 const XMLByte* fSrcBytes;
222};
223
224
225inline void MemBufInputSource::setCopyBufToStream(const bool newState)
226{
227 fCopyBufToStream = newState;
228}
229
231
232#endif
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
unsigned char XMLByte
Definition XercesDefs.hpp:65
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
Definition BinInputStream.hpp:30
A single input source for an XML entity.
Definition InputSource.hpp:63
This class is a derivative of the standard InputSource class.
Definition MemBufInputSource.hpp:64
void setCopyBufToStream(const bool newState)
By default, for safety's sake, each newly created stream from this input source will make its own cop...
Definition MemBufInputSource.hpp:225
MemBufInputSource(const XMLByte *const srcDocBytes, const XMLSize_t byteCount, const XMLCh *const bufId, const bool adoptBuffer=false, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
A memory buffer input source is constructed from a buffer of byte data, and the count of bytes in tha...
void resetMemBufInputSource(const XMLByte *const srcDocBytes, const XMLSize_t byteCount)
This methods allows the MemBufInputSource to be used for more than one input source,...
BinInputStream * makeStream() const
This method will return a binary input stream derivative that will parse from the memory buffer.
MemBufInputSource(const XMLByte *const srcDocBytes, const XMLSize_t byteCount, const char *const bufId, const bool adoptBuffer=false, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
This constructor is identical to the previous one, except that it takes the fake system id in local c...
~MemBufInputSource()
If the buffer was adopted, the copy made during construction is deleted at this point.
Configurable memory manager.
Definition MemoryManager.hpp:40
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121