MemBufInputSource.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: MemBufInputSource.hpp 932889 2010-04-11 13:10:10Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_MEMBUFINPUTSOURCE_HPP)
#define XERCESC_INCLUDE_GUARD_MEMBUFINPUTSOURCE_HPP
#include <xercesc/sax/InputSource.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class BinInputStream;
class XMLPARSER_EXPORT MemBufInputSource : public InputSource
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
MemBufInputSource
(
const XMLByte* const srcDocBytes
, const XMLSize_t byteCount
, const XMLCh* const bufId
, const bool adoptBuffer = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
MemBufInputSource
(
const XMLByte* const srcDocBytes
, const XMLSize_t byteCount
, const char* const bufId
, const bool adoptBuffer = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~MemBufInputSource();
// -----------------------------------------------------------------------
// Virtual input source interface
// -----------------------------------------------------------------------
BinInputStream* makeStream() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setCopyBufToStream(const bool newState);
void resetMemBufInputSource(const XMLByte* const srcDocBytes
, const XMLSize_t byteCount);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
MemBufInputSource(const MemBufInputSource&);
MemBufInputSource& operator=(const MemBufInputSource&);
// -----------------------------------------------------------------------
// Private data members
//
// fAdopted
// Indicates whether the buffer is adopted or not. If so, then it
// is destroyed when the input source is destroyed.
//
// fByteCount
// The size of the source document.
//
// fCopyBufToStream
// This defaults to true (the safe option), which causes it to
// give a copy of the buffer to any streams it creates. If you set
// it to false, it will allow the streams to just reference the
// buffer (in which case this input source must stay alive as long
// as the buffer is in use by the stream.)
//
// fSrcBytes
// The source memory buffer that is being spooled from. Whether it
// belongs to the this input source or not is controlled by the
// fAdopted flag.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fByteCount;
bool fCopyBufToStream;
const XMLByte* fSrcBytes;
};
inline void MemBufInputSource::setCopyBufToStream(const bool newState)
{
fCopyBufToStream = newState;
}
XERCES_CPP_NAMESPACE_END
#endif
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
MemBufInputSource::setCopyBufToStream
void setCopyBufToStream(const bool newState)
By default, for safety&#39;s sake, each newly created stream from this input source will make its own cop...
Definition: MemBufInputSource.hpp:223
MemBufInputSource
This class is a derivative of the standard InputSource class.
Definition: MemBufInputSource.hpp:61
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:118
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLByte
unsigned char XMLByte
Definition: XercesDefs.hpp:65
InputSource::makeStream
virtual BinInputStream * makeStream() const =0
Makes the byte stream for this input source.
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:110
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
BinInputStream
Definition: BinInputStream.hpp:29
InputSource.hpp
InputSource
A single input source for an XML entity.
Definition: InputSource.hpp:62