00001 /*00002 * Licensed to the Apache Software Foundation (ASF) under one or more00003 * contributor license agreements. See the NOTICE file distributed with00004 * this work for additional information regarding copyright ownership.00005 * The ASF licenses this file to You under the Apache License, Version 2.000006 * (the "License"); you may not use this file except in compliance with00007 * the License. You may obtain a copy of the License at00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.000010 * 00011 * Unless required by applicable law or agreed to in writing, software00012 * distributed under the License is distributed on an "AS IS" BASIS,00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.00014 * See the License for the specific language governing permissions and00015 * limitations under the License.00016 */00017
00018 /*00019 * $Id: MemBufInputSource.hpp 568078 2007-08-21 11:43:25Z amassari $00020 */00021
00022
00023 #if !defined(MEMBUFINPUTSOURCE_HPP)00024#define MEMBUFINPUTSOURCE_HPP00025
00026 #include <xercesc/sax/InputSource.hpp>00027
00028 XERCES_CPP_NAMESPACE_BEGIN00029
00030 class BinInputStream;
00031
00032
00061class MemBufInputSource : publicInputSource00062 {
00063 public :
00064 // -----------------------------------------------------------------------00065 // Constructors and Destructor00066 // -----------------------------------------------------------------------00067
00070
00093 MemBufInputSource00094 (
00095 constXMLByte* const srcDocBytes
00096 , constunsignedint byteCount
00097 , const XMLCh* const bufId
00098 , constbool adoptBuffer = false00099 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager00100 );
00101
00106 MemBufInputSource00107 (
00108 constXMLByte* const srcDocBytes
00109 , constunsignedint byteCount
00110 , constchar* const bufId
00111 , constbool adoptBuffer = false00112 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager00113 );
00115
00122 ~MemBufInputSource();
00124
00125
00126 // -----------------------------------------------------------------------00127 // Virtual input source interface00128 // -----------------------------------------------------------------------00129
00132
00143 BinInputStream* makeStream() const;
00144
00146
00147
00148 // -----------------------------------------------------------------------00149 // Setter methods00150 // -----------------------------------------------------------------------00151
00155
00171 void setCopyBufToStream(constbool newState);
00172
00182 void resetMemBufInputSource(constXMLByte* const srcDocBytes
00183 , constunsignedint byteCount);
00185
00186
00187 private :
00188 // -----------------------------------------------------------------------00189 // Unimplemented constructors and operators00190 // -----------------------------------------------------------------------00191 MemBufInputSource(constMemBufInputSource&);
00192 MemBufInputSource& operator=(constMemBufInputSource&);
00193
00194 // -----------------------------------------------------------------------00195 // Private data members00196 //00197 // fAdopted00198 // Indicates whether the buffer is adopted or not. If so, then it00199 // is destroyed when the input source is destroyed.00200 //00201 // fByteCount00202 // The size of the source document.00203 //00204 // fCopyBufToStream00205 // This defaults to true (the safe option), which causes it to00206 // give a copy of the buffer to any streams it creates. If you set00207 // it to false, it will allow the streams to just reference the00208 // buffer (in which case this input source must stay alive as long00209 // as the buffer is in use by the stream.)00210 //00211 // fSrcBytes00212 // The source memory buffer that is being spooled from. Whether it00213 // belongs to the this input source or not is controlled by the00214 // fAdopted flag.00215 // -----------------------------------------------------------------------00216 bool fAdopted;
00217 unsignedint fByteCount;
00218 bool fCopyBufToStream;
00219 constXMLByte* fSrcBytes;
00220 };
00221
00222
00223inlinevoidMemBufInputSource::setCopyBufToStream(constbool newState)
00224 {
00225 fCopyBufToStream = newState;
00226 }
00227
00228 XERCES_CPP_NAMESPACE_END00229
00230 #endif