Xerces-C++  3.2.3
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 
30 class BinInputStream;
31 
32 
62 {
63 public :
64  // -----------------------------------------------------------------------
65  // Constructors and Destructor
66  // -----------------------------------------------------------------------
67 
70 
94  (
95  const XMLByte* const srcDocBytes
96  , const XMLSize_t byteCount
97  , const XMLCh* const bufId
98  , const bool adoptBuffer = false
100  );
101 
107  (
108  const XMLByte* const srcDocBytes
109  , const XMLSize_t byteCount
110  , const char* const bufId
111  , const bool adoptBuffer = false
113  );
115 
124 
125 
126  // -----------------------------------------------------------------------
127  // Virtual input source interface
128  // -----------------------------------------------------------------------
129 
132 
143  BinInputStream* makeStream() const;
144 
146 
147 
148  // -----------------------------------------------------------------------
149  // Setter methods
150  // -----------------------------------------------------------------------
151 
155 
171  void setCopyBufToStream(const bool newState);
172 
182  void resetMemBufInputSource(const XMLByte* const srcDocBytes
183  , const XMLSize_t byteCount);
185 
186 
187 private :
188  // -----------------------------------------------------------------------
189  // Unimplemented constructors and operators
190  // -----------------------------------------------------------------------
192  MemBufInputSource& operator=(const MemBufInputSource&);
193 
194  // -----------------------------------------------------------------------
195  // Private data members
196  //
197  // fAdopted
198  // Indicates whether the buffer is adopted or not. If so, then it
199  // is destroyed when the input source is destroyed.
200  //
201  // fByteCount
202  // The size of the source document.
203  //
204  // fCopyBufToStream
205  // This defaults to true (the safe option), which causes it to
206  // give a copy of the buffer to any streams it creates. If you set
207  // it to false, it will allow the streams to just reference the
208  // buffer (in which case this input source must stay alive as long
209  // as the buffer is in use by the stream.)
210  //
211  // fSrcBytes
212  // The source memory buffer that is being spooled from. Whether it
213  // belongs to the this input source or not is controlled by the
214  // fAdopted flag.
215  // -----------------------------------------------------------------------
216  bool fAdopted;
217  XMLSize_t fByteCount;
218  bool fCopyBufToStream;
219  const XMLByte* fSrcBytes;
220 };
221 
222 
223 inline void MemBufInputSource::setCopyBufToStream(const bool newState)
224 {
225  fCopyBufToStream = newState;
226 }
227 
229 
230 #endif
InputSource.hpp
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLByte
unsigned char XMLByte
Definition: XercesDefs.hpp:65
BinInputStream
Definition: BinInputStream.hpp:29
MemBufInputSource::setCopyBufToStream
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:223
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
MemBufInputSource
This class is a derivative of the standard InputSource class.
Definition: MemBufInputSource.hpp:61
InputSource::makeStream
virtual BinInputStream * makeStream() const =0
Makes the byte stream for this input source.
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
InputSource
A single input source for an XML entity.
Definition: InputSource.hpp:62
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163