Reordered files in all libs - now all includes are in "libname/include" dir - logical, isn't it? This should break compilation however.

This commit is contained in:
pelya
2010-10-26 14:43:54 +03:00
parent fc58bc53c0
commit 6b9b163689
520 changed files with 41 additions and 43205 deletions

View File

@@ -0,0 +1,33 @@
/*
* 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: ArrayIndexOutOfBoundsException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ARRAYINDEXOUTOFBOUNDSEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_ARRAYINDEXOUTOFBOUNDSEXCEPTION_HPP
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(ArrayIndexOutOfBoundsException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,266 @@
/*
* 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: Base64.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BASE64_HPP)
#define XERCESC_INCLUDE_GUARD_BASE64_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides encode/decode for RFC 2045 Base64 as
// defined by RFC 2045, N. Freed and N. Borenstein.
// RFC 2045: Multipurpose Internet Mail Extensions (MIME)
// Part One: Format of Internet Message Bodies. Reference
// 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
// This class is used by XML Schema binary format validation
//
//
class XMLUTIL_EXPORT Base64
{
public :
enum Conformance
{
Conf_RFC2045
, Conf_Schema
};
//@{
/**
* Encodes octets into Base64 data
*
* NOTE: The returned buffer is dynamically allocated and is the
* responsibility of the caller to delete it when not longer needed.
* Use the memory manager to release the returned buffer or
* operator delete() if none was provided.
*
* @param inputData Binary data in XMLByte stream.
* @param inputLength Length of the XMLByte stream.
* @param outputLength Length of the encoded Base64 byte stream.
* @param memMgr client provided memory manager
* @return Encoded Base64 data in XMLByte stream,
* or NULL if input data can not be encoded.
*/
static XMLByte* encode(const XMLByte* const inputData
, const XMLSize_t inputLength
, XMLSize_t* outputLength
, MemoryManager* const memMgr = 0);
/**
* Decodes Base64 data into octets
*
* NOTE: The returned buffer is dynamically allocated and is the
* responsibility of the caller to delete it when not longer needed.
* Use the memory manager to release the returned buffer or
* operator delete() if none was provided.
*
* @param inputData Base64 data in XMLByte stream.
* @param decodedLength Length of decoded XMLByte stream.
* @param memMgr client provided memory manager
* @param conform conformance specified: if the input data conforms to the
* RFC 2045 it is allowed to have any number of whitespace
* characters inside; if it conforms to the XMLSchema specs,
* it is allowed to have at most one whitespace character
* between the quartets
* @return Decoded binary data in XMLByte stream,
* or NULL if input data can not be decoded.
*/
static XMLByte* decode(
const XMLByte* const inputData
, XMLSize_t* decodedLength
, MemoryManager* const memMgr = 0
, Conformance conform = Conf_RFC2045
);
/**
* Decodes Base64 data into octets
*
* NOTE: The returned buffer is dynamically allocated and is the
* responsibility of the caller to delete it when not longer needed.
* Use the memory manager to release the returned buffer or
* operator delete() if none was provided.
*
* @param inputData Base64 data in XMLCh stream.
* @param decodedLength Length of decoded XMLByte stream.
* @param memMgr client provided memory manager
* @param conform conformance specified: if the input data conforms to the
* RFC 2045 it is allowed to have any number of whitespace
* characters inside; if it conforms to the XMLSchema specs,
* it is allowed to have at most one whitespace character
* between the quartets
* @return Decoded binary data in XMLByte stream,
* or NULL if input data can not be decoded.
*/
static XMLByte* decodeToXMLByte(
const XMLCh* const inputData
, XMLSize_t* decodedLength
, MemoryManager* const memMgr = 0
, Conformance conform = Conf_RFC2045
);
/**
* Get data length
*
* Returns length of decoded data given an array
* containing encoded data.
*
* @param inputData Base64 data in XMLCh stream.
* @param memMgr client provided memory manager
* @param conform conformance specified
* @return Length of decoded data,
* or -1 if input data can not be decoded.
*/
static int getDataLength(
const XMLCh* const inputData
, MemoryManager* const memMgr = 0
, Conformance conform = Conf_RFC2045
);
//@}
/**
* get canonical representation
*
* Caller is responsible for the proper deallocation
* of the string returned.
*
* @param inputData A string containing the Base64
* @param memMgr client provided memory manager
* @param conform conformance specified
*
* return: the canonical representation of the Base64
* if it is a valid Base64
* 0 otherwise
*/
static XMLCh* getCanonicalRepresentation
(
const XMLCh* const inputData
, MemoryManager* const memMgr = 0
, Conformance conform = Conf_RFC2045
);
private :
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
static XMLByte* decode(
const XMLByte* const inputData
, XMLSize_t* outputLength
, XMLByte*& canRepData
, MemoryManager* const memMgr = 0
, Conformance conform = Conf_RFC2045
);
static bool isData(const XMLByte& octet);
static bool isPad(const XMLByte& octet);
static XMLByte set1stOctet(const XMLByte&, const XMLByte&);
static XMLByte set2ndOctet(const XMLByte&, const XMLByte&);
static XMLByte set3rdOctet(const XMLByte&, const XMLByte&);
static void split1stOctet(const XMLByte&, XMLByte&, XMLByte&);
static void split2ndOctet(const XMLByte&, XMLByte&, XMLByte&);
static void split3rdOctet(const XMLByte&, XMLByte&, XMLByte&);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Base64();
Base64(const Base64&);
// -----------------------------------------------------------------------
// Private data members
//
// base64Alphabet
// The Base64 alphabet (see RFC 2045).
//
// base64Padding
// Padding character (see RFC 2045).
//
// base64Inverse
// Table used in decoding base64.
//
// isInitialized
// Set once base64Inverse is initialized.
//
// quadsPerLine
// Number of quadruplets per one line. The encoded output
// stream must be represented in lines of no more
// than 19 quadruplets each.
//
// -----------------------------------------------------------------------
static const XMLByte base64Alphabet[];
static const XMLByte base64Padding;
static const XMLByte base64Inverse[];
static const unsigned int quadsPerLine;
};
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
inline bool Base64::isPad(const XMLByte& octet)
{
return ( octet == base64Padding );
}
inline XMLByte Base64::set1stOctet(const XMLByte& b1, const XMLByte& b2)
{
return (( b1 << 2 ) | ( b2 >> 4 ));
}
inline XMLByte Base64::set2ndOctet(const XMLByte& b2, const XMLByte& b3)
{
return (( b2 << 4 ) | ( b3 >> 2 ));
}
inline XMLByte Base64::set3rdOctet(const XMLByte& b3, const XMLByte& b4)
{
return (( b3 << 6 ) | b4 );
}
inline void Base64::split1stOctet(const XMLByte& ch, XMLByte& b1, XMLByte& b2) {
b1 = ch >> 2;
b2 = ( ch & 0x3 ) << 4;
}
inline void Base64::split2ndOctet(const XMLByte& ch, XMLByte& b2, XMLByte& b3) {
b2 |= ch >> 4; // combine with previous value
b3 = ( ch & 0xf ) << 2;
}
inline void Base64::split3rdOctet(const XMLByte& ch, XMLByte& b3, XMLByte& b4) {
b3 |= ch >> 6; // combine with previous value
b4 = ( ch & 0x3f );
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,158 @@
/*
* 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: BaseRefVectorOf.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ABSTRACTVECTOROF_HPP)
#define XERCESC_INCLUDE_GUARD_ABSTRACTVECTOROF_HPP
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/util/XMLEnumerator.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Abstract base class for the xerces internal representation of Vector.
*
* The destructor is abstract, forcing each of RefVectorOf and
* RefArrayVectorOf to implement their own appropriate one.
*
*/
template <class TElem> class BaseRefVectorOf : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
BaseRefVectorOf
(
const XMLSize_t maxElems
, const bool adoptElems = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~BaseRefVectorOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
void addElement(TElem* const toAdd);
virtual void setElementAt(TElem* const toSet, const XMLSize_t setAt);
void insertElementAt(TElem* const toInsert, const XMLSize_t insertAt);
TElem* orphanElementAt(const XMLSize_t orphanAt);
virtual void removeAllElements();
virtual void removeElementAt(const XMLSize_t removeAt);
virtual void removeLastElement();
bool containsElement(const TElem* const toCheck);
virtual void cleanup();
void reinitialize();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLSize_t curCapacity() const;
const TElem* elementAt(const XMLSize_t getAt) const;
TElem* elementAt(const XMLSize_t getAt);
XMLSize_t size() const;
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Miscellaneous
// -----------------------------------------------------------------------
void ensureExtraCapacity(const XMLSize_t length);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
BaseRefVectorOf(const BaseRefVectorOf<TElem>& copy);
BaseRefVectorOf& operator=(const BaseRefVectorOf<TElem>& copy);
protected:
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
bool fAdoptedElems;
XMLSize_t fCurCount;
XMLSize_t fMaxCount;
TElem** fElemList;
MemoryManager* fMemoryManager;
};
//
// An enumerator for a vector. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TElem> class BaseRefVectorEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
BaseRefVectorEnumerator
(
BaseRefVectorOf<TElem>* const toEnum
, const bool adopt = false
);
virtual ~BaseRefVectorEnumerator();
BaseRefVectorEnumerator(const BaseRefVectorEnumerator<TElem>& copy);
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
BaseRefVectorEnumerator& operator=(const BaseRefVectorEnumerator<TElem>& copy);
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurIndex
// This is the current index into the vector.
//
// fToEnum
// The reference vector being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fCurIndex;
BaseRefVectorOf<TElem>* fToEnum;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/BaseRefVectorOf.c>
#endif
#endif

View File

@@ -0,0 +1,107 @@
/*
* 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: BinFileInputStream.hpp 670359 2008-06-22 13:43:45Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BINFILEINPUTSTREAM_HPP)
#define XERCESC_INCLUDE_GUARD_BINFILEINPUTSTREAM_HPP
#include <xercesc/util/BinInputStream.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT BinFileInputStream : public BinInputStream
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
BinFileInputStream
(
const XMLCh* const fileName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
BinFileInputStream
(
const char* const fileName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
BinFileInputStream
(
const FileHandle toUse
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~BinFileInputStream();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getIsOpen() const;
XMLFilePos getSize() const;
void reset();
// -----------------------------------------------------------------------
// Implementation of the input stream interface
// -----------------------------------------------------------------------
virtual XMLFilePos curPos() const;
virtual XMLSize_t readBytes
(
XMLByte* const toFill
, const XMLSize_t maxToRead
);
virtual const XMLCh* getContentType() const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
BinFileInputStream(const BinFileInputStream&);
BinFileInputStream& operator=(const BinFileInputStream&);
// -----------------------------------------------------------------------
// Private data members
//
// fSource
// The source file that we represent. The FileHandle type is defined
// per platform.
// -----------------------------------------------------------------------
FileHandle fSource;
MemoryManager* const fMemoryManager;
};
// ---------------------------------------------------------------------------
// BinFileInputStream: Getter methods
// ---------------------------------------------------------------------------
inline bool BinFileInputStream::getIsOpen() const
{
return (fSource != (FileHandle) XERCES_Invalid_File_Handle);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,87 @@
/*
* 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: BinInputStream.hpp 670359 2008-06-22 13:43:45Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BININPUTSTREAM_HPP)
#define XERCESC_INCLUDE_GUARD_BININPUTSTREAM_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT BinInputStream : public XMemory
{
public :
// -----------------------------------------------------------------------
// Virtual destructor for derived classes
// -----------------------------------------------------------------------
virtual ~BinInputStream();
// -----------------------------------------------------------------------
// The virtual input stream interface
// -----------------------------------------------------------------------
virtual XMLFilePos curPos() const = 0;
virtual XMLSize_t readBytes
(
XMLByte* const toFill
, const XMLSize_t maxToRead
) = 0;
/**
* Return the "out-of-band" content type for the data supplied by this
* input stream in the form of the media-type production (mime type
* with optional parameters such as encoding) as defined by the HTTP 1.1
* specification. If no such content type is provided for the data, 0 is
* returned. This function is expected to return the correct value at
* any time after the construction of the stream.
*
* An example of the stream that may return non-0 from this function is
* an HTTP stream with the value returned taken from the "Content-Type"
* HTTP header. Note also that if the encoding of the data is known
* to the application by some other means then the setEncoding function
* in the InputSource object should be used instead. The getContentType
* function should only be used to return information that is intrinsic
* to the stream.
*
* @return The content type, or 0 if one is not available.
*/
virtual const XMLCh* getContentType() const = 0;
protected :
// -----------------------------------------------------------------------
// Hidden Constructors
// -----------------------------------------------------------------------
BinInputStream();
private :
// -----------------------------------------------------------------------
// Unimplemented Constructors
// -----------------------------------------------------------------------
BinInputStream(const BinInputStream&);
BinInputStream& operator=(const BinInputStream&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,134 @@
/*
* 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: BinMemInputStream.hpp 670359 2008-06-22 13:43:45Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BINMEMINPUTSTREAM_HPP)
#define XERCESC_INCLUDE_GUARD_BINMEMINPUTSTREAM_HPP
#include <xercesc/util/BinInputStream.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT BinMemInputStream : public BinInputStream
{
public :
// -----------------------------------------------------------------------
// Class specific types
// -----------------------------------------------------------------------
enum BufOpts
{
BufOpt_Adopt
, BufOpt_Copy
, BufOpt_Reference
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
BinMemInputStream
(
const XMLByte* const initData
, const XMLSize_t capacity
, const BufOpts bufOpt = BufOpt_Copy
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~BinMemInputStream();
// -----------------------------------------------------------------------
// Stream management methods
// -----------------------------------------------------------------------
void reset();
// -----------------------------------------------------------------------
// Implementation of the input stream interface
// -----------------------------------------------------------------------
virtual XMLFilePos curPos() const;
virtual XMLSize_t readBytes
(
XMLByte* const toFill
, const XMLSize_t maxToRead
);
virtual const XMLCh* getContentType() const;
inline XMLSize_t getSize() const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
BinMemInputStream(const BinMemInputStream&);
BinMemInputStream& operator=(const BinMemInputStream&);
// -----------------------------------------------------------------------
// Private data members
//
// fBuffer
// The buffer of bytes that we are streaming.
//
// fBufOpt
// Indicates the ownership status of the buffer. The caller can have
// us adopt it (we delete it), reference it, or just make our own
// copy of it.
//
// fCapacity
// The size of the buffer being streamed.
//
// fCurIndex
// The current index where the next byte will be read from. When it
// hits fCapacity, we are done.
// -----------------------------------------------------------------------
const XMLByte* fBuffer;
BufOpts fBufOpt;
XMLSize_t fCapacity;
XMLSize_t fCurIndex;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// BinMemInputStream: Stream management methods
// ---------------------------------------------------------------------------
inline void BinMemInputStream::reset()
{
fCurIndex = 0;
}
// ---------------------------------------------------------------------------
// BinMemInputStream: Implementation of the input stream interface
// ---------------------------------------------------------------------------
inline XMLFilePos BinMemInputStream::curPos() const
{
return fCurIndex;
}
inline XMLSize_t BinMemInputStream::getSize() const
{
return fCapacity;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,67 @@
/*
* 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: BitOps.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BITOPS_HPP)
#define XERCESC_INCLUDE_GUARD_BITOPS_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT BitOps
{
public:
// -----------------------------------------------------------------------
// Public static methods
// -----------------------------------------------------------------------
static inline XMLCh swapBytes(const XMLUInt16 toSwap)
{
//The mask is required to overcome a compiler error on solaris
return XMLCh(((toSwap >> 8) | (toSwap << 8)) & 0xFFFF);
}
static inline unsigned int swapBytes(const XMLUInt32 toSwap)
{
return
(
(toSwap >> 24)
| (toSwap << 24)
| ((toSwap & 0xFF00) << 8)
| ((toSwap & 0xFF0000) >> 8)
);
}
protected :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators. (These ought to be private,
// but that produces spurious compiler warnings
// on some platforms.)
// -----------------------------------------------------------------------
BitOps();
BitOps(const BitOps&);
BitOps& operator=(const BitOps&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,107 @@
/*
* 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: BitSet.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BITSET_HPP)
#define XERCESC_INCLUDE_GUARD_BITSET_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT BitSet : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
BitSet( const XMLSize_t size
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
BitSet(const BitSet& toCopy);
~BitSet();
// -----------------------------------------------------------------------
// Equality methods
// -----------------------------------------------------------------------
bool equals(const BitSet& other) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool allAreCleared() const;
bool allAreSet() const;
XMLSize_t size() const;
bool get(const XMLSize_t index) const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void clear(const XMLSize_t index);
void clearAll();
void set(const XMLSize_t index);
// -----------------------------------------------------------------------
// Bitwise logical operations
// -----------------------------------------------------------------------
void andWith(const BitSet& other);
void orWith(const BitSet& other);
void xorWith(const BitSet& other);
// -----------------------------------------------------------------------
// Miscellaneous
// -----------------------------------------------------------------------
XMLSize_t hash(const XMLSize_t hashModulus) const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors
// -----------------------------------------------------------------------
BitSet();
BitSet& operator=(const BitSet&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void ensureCapacity(const XMLSize_t bits);
// -----------------------------------------------------------------------
// Data members
//
// fBits
// The array of unsigned longs used to store the bits.
//
// fUnitLen
// The length of the storage array, in storage units not bits.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
unsigned long* fBits;
XMLSize_t fUnitLen;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,69 @@
/*
* 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: CountedPointer.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_COUNTEDPOINTERTO_HPP)
#define XERCESC_INCLUDE_GUARD_COUNTEDPOINTERTO_HPP
#include <xercesc/util/NullPointerException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class T> class CountedPointerTo : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
CountedPointerTo(const CountedPointerTo<T>& toCopy);
CountedPointerTo(T* p = 0);
~CountedPointerTo();
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
CountedPointerTo<T>& operator=(const CountedPointerTo<T>& other);
operator T*();
const T* operator->() const;
T* operator->();
const T& operator*() const;
T& operator*();
private:
// -----------------------------------------------------------------------
// Data members
//
// fPtr
// The pointer that we are counting. The T type must implement the
// addRef() and removeRef() APIs but it doesn't have to derive from
// any particular type.
// -----------------------------------------------------------------------
T* fPtr;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/CountedPointer.c>
#endif
#endif

View File

@@ -0,0 +1,80 @@
/*
* 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: DefaultPanicHandler.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DEFAULT_PANICHANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_DEFAULT_PANICHANDLER_HPP
#include <xercesc/util/PanicHandler.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Receive notification of panic.
*
* <p>This is Xerces' default implementation of the PanicHanlder
* interface, which will be instantiated and used in the
* absence of an application's panic handler.
* </p>
*/
class XMLUTIL_EXPORT DefaultPanicHandler : public XMemory, public PanicHandler
{
public:
/** @name hidden Constructors */
//@{
/** Default constructor */
DefaultPanicHandler(){};
/** Destructor */
virtual ~DefaultPanicHandler(){};
//@}
/** @name Implement virtual panic handler interface */
//@{
/**
* Receive notification of panic
*
* <p>Upon invocation, a corresponding error message will be output
* to the stderr, and program exit.
* </p>
*
* @param reason The reason of panic
*
*/
virtual void panic(const PanicHandler::PanicReasons reason);
//@}
private:
/* Unimplemented Constructors and operators */
/* Copy constructor */
DefaultPanicHandler(const PanicHandler&);
/** Assignment operator */
DefaultPanicHandler& operator=(const DefaultPanicHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: EmptyStackException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_EMPTYSTACKEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_EMPTYSTACKEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(EmptyStackException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,85 @@
/*
* 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: EncodingValidator.hpp 635560 2008-03-10 14:10:09Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ENCODINGVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ENCODINGVALIDATOR_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/ValueHashTableOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* A singleton class that checks whether an encoding name is a valid IANA
* encoding
*/
class XMLUTIL_EXPORT EncodingValidator {
public:
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
bool isValidEncoding(const XMLCh* const encName);
// -----------------------------------------------------------------------
// Instance methods
// -----------------------------------------------------------------------
static EncodingValidator* instance();
private:
// -----------------------------------------------------------------------
// Constructor and destructors
// -----------------------------------------------------------------------
EncodingValidator();
~EncodingValidator();
// -----------------------------------------------------------------------
// Private Helpers methods
// -----------------------------------------------------------------------
/*
* Initializes the registry with a set of valid IANA encoding names
*/
void initializeRegistry();
// -----------------------------------------------------------------------
// Private data members
//
// fEncodingRegistry
// Contains a set of IANA encoding names
//
// fInstance
// An EncodingValidator singleton instance
// -----------------------------------------------------------------------
ValueHashTableOf<bool>* fEncodingRegistry;
static EncodingValidator* fInstance;
friend class XMLInitializer;
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End file EncodingValidator.hpp
*/

View File

@@ -0,0 +1,60 @@
/*
* 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: PosixFileMgr.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_POSIXFILEMGR_HPP)
#define XERCESC_INCLUDE_GUARD_POSIXFILEMGR_HPP
#include <xercesc/util/XMLFileMgr.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// Concrete implementation of XMLFileMgr, implementing
// file access on posix compatible systems.
class PosixFileMgr : public XMLFileMgr
{
public:
PosixFileMgr();
virtual ~PosixFileMgr();
// File access
virtual FileHandle fileOpen(const XMLCh* path, bool toWrite, MemoryManager* const manager);
virtual FileHandle fileOpen(const char* path, bool toWrite, MemoryManager* const manager);
virtual FileHandle openStdIn(MemoryManager* const manager);
virtual void fileClose(FileHandle f, MemoryManager* const manager);
virtual void fileReset(FileHandle f, MemoryManager* const manager);
virtual XMLFilePos curPos(FileHandle f, MemoryManager* const manager);
virtual XMLFilePos fileSize(FileHandle f, MemoryManager* const manager);
virtual XMLSize_t fileRead(FileHandle f, XMLSize_t byteCount, XMLByte* buffer, MemoryManager* const manager);
virtual void fileWrite(FileHandle f, XMLSize_t byteCount, const XMLByte* buffer, MemoryManager* const manager);
// Ancillary path handling routines
virtual XMLCh* getFullPath(const XMLCh* const srcPath, MemoryManager* const manager);
virtual XMLCh* getCurrentDirectory(MemoryManager* const manager);
virtual bool isRelative(const XMLCh* const toCheck, MemoryManager* const manager);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,73 @@
/*
* 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: FlagJanitor.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_FLAGJANITOR_HPP)
#define XERCESC_INCLUDE_GUARD_FLAGJANITOR_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class T> class FlagJanitor
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
FlagJanitor(T* const valPtr, const T newVal);
~FlagJanitor();
// -----------------------------------------------------------------------
// Value management methods
// -----------------------------------------------------------------------
void release();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
FlagJanitor();
FlagJanitor(const FlagJanitor<T>&);
FlagJanitor<T>& operator=(const FlagJanitor<T>&);
// -----------------------------------------------------------------------
// Private data members
//
// fOldVal
// The old value that was in the flag when we were constructed.
//
// fValPtr
// A pointer to the flag that we are to restore the value of
// -----------------------------------------------------------------------
T fOldVal;
T* fValPtr;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/FlagJanitor.c>
#endif
#endif

View File

@@ -0,0 +1,223 @@
/*
* 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: Hash2KeysSetOf.hpp 883368 2009-11-23 15:28:19Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_HASH2KEYSSETOF_HPP)
#define XERCESC_INCLUDE_GUARD_HASH2KEYSSETOF_HPP
#include <xercesc/util/Hashers.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// This hash table is similar to Hash2KeysSetOf with an additional integer as key2
// Forward declare the enumerator so it can be our friend.
//
template <class THasher>
class Hash2KeysSetOfEnumerator;
//
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
struct Hash2KeysSetBucketElem
{
Hash2KeysSetBucketElem* fNext;
const void* fKey1;
int fKey2;
};
template <class THasher>
class Hash2KeysSetOf : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
Hash2KeysSetOf(
const XMLSize_t modulus,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
Hash2KeysSetOf(
const XMLSize_t modulus,
const THasher& hasher,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~Hash2KeysSetOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool isEmpty() const;
bool containsKey(const void* const key1, const int key2) const;
void removeKey(const void* const key1, const int key2);
void removeKey(const void* const key1);
void removeAll();
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
MemoryManager* getMemoryManager() const;
XMLSize_t getHashModulus() const;
// -----------------------------------------------------------------------
// Putters
// -----------------------------------------------------------------------
void put(const void* key1, int key2);
bool putIfNotPresent(const void* key1, int key2);
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class Hash2KeysSetOfEnumerator<THasher>;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Hash2KeysSetOf(const Hash2KeysSetOf<THasher>&);
Hash2KeysSetOf<THasher>& operator=(const Hash2KeysSetOf<THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
Hash2KeysSetBucketElem* findBucketElem(const void* const key1, const int key2, XMLSize_t& hashVal);
const Hash2KeysSetBucketElem* findBucketElem(const void* const key1, const int key2, XMLSize_t& hashVal) const;
void initialize(const XMLSize_t modulus);
void rehash();
// -----------------------------------------------------------------------
// Data members
//
// fBucketList
// This is the array that contains the heads of all of the list
// buckets, one for each possible hash value.
//
// fHashModulus
// The modulus used for this hash table, to hash the keys. This is
// also the number of elements in the bucket list.
//
// fCount
// The number of elements currently in the map
//
// fHash
// The hasher for the key1 data type.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
Hash2KeysSetBucketElem** fBucketList;
XMLSize_t fHashModulus;
XMLSize_t fCount;
Hash2KeysSetBucketElem* fAvailable;
THasher fHasher;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class THasher>
class Hash2KeysSetOfEnumerator : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
Hash2KeysSetOfEnumerator(Hash2KeysSetOf<THasher>* const toEnum
, const bool adopt = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~Hash2KeysSetOfEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
void Reset();
// -----------------------------------------------------------------------
// New interface
// -----------------------------------------------------------------------
void nextElementKey(const void*&, int&);
void setPrimaryKey(const void* key);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Hash2KeysSetOfEnumerator(const Hash2KeysSetOfEnumerator<THasher>&);
Hash2KeysSetOfEnumerator<THasher>& operator=(const Hash2KeysSetOfEnumerator<THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void findNext();
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurElem
// This is the current bucket bucket element that we are on.
//
// fCurHash
// The is the current hash buck that we are working on. Once we hit
// the end of the bucket that fCurElem is in, then we have to start
// working this one up to the next non-empty bucket.
//
// fToEnum
// The value array being enumerated.
//
// fLockPrimaryKey
// Indicates that we are requested to iterate over the secondary keys
// associated with the given primary key
//
// -----------------------------------------------------------------------
bool fAdopted;
Hash2KeysSetBucketElem* fCurElem;
XMLSize_t fCurHash;
Hash2KeysSetOf<THasher>* fToEnum;
MemoryManager* const fMemoryManager;
const void* fLockPrimaryKey;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/Hash2KeysSetOf.c>
#endif
#endif

View File

@@ -0,0 +1,95 @@
/*
* 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: Hashers.hpp 679382 2008-07-24 12:09:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_HASHERS_HPP)
#define XERCESC_INCLUDE_GUARD_HASHERS_HPP
#include <xercesc/util/XMLString.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// Common hashers. Only widely-used hashers should be placed here.
//
/**
* Hasher for keys that are const XMLCh*.
*/
struct StringHasher
{
/**
* Returns a hash value based on the key
*
* @param key the key to be hashed
* @param mod the modulus the hasher should use
*/
XMLSize_t getHashVal(const void* key, XMLSize_t mod) const
{
return XMLString::hash ((const XMLCh*)key, mod);
}
/**
* Compares two keys and determines if they are semantically equal
*
* @param key1 the first key to be compared
* @param key2 the second key to be compared
*
* @return true if they are equal
*/
bool equals(const void *const key1, const void *const key2) const
{
return XMLString::equals ((const XMLCh*)key1, (const XMLCh*)key2);
}
};
/**
* Hasher for keys that are pointers.
*/
struct PtrHasher
{
/**
* Returns a hash value based on the key
*
* @param key the key to be hashed
* @param mod the modulus the hasher should use
*/
XMLSize_t getHashVal(const void* key, XMLSize_t mod) const
{
return ((XMLSize_t)key) % mod;
}
/**
* Compares two keys and determines if they are semantically equal
*
* @param key1 the first key to be compared
* @param key2 the second key to be compared
*
* @return true if they are equal
*/
bool equals(const void *const key1, const void *const key2) const
{
return key1 == key2;
}
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,128 @@
/*
* 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: HexBin.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_HEXBIN_HPP)
#define XERCESC_INCLUDE_GUARD_HEXBIN_HPP
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT HexBin
{
public :
//@{
/**
* return the length of hexData in terms of HexBinary.
*
* @param hexData A string containing the HexBinary
*
* return: -1 if it contains any invalid HexBinary
* the length of the HexNumber otherwise.
*/
static int getDataLength(const XMLCh* const hexData);
/**
* check an array of data against the Hex table.
*
* @param hexData A string containing the HexBinary
*
* return: false if it contains any invalid HexBinary
* true otherwise.
*/
static bool isArrayByteHex(const XMLCh* const hexData);
/**
* get canonical representation
*
* Caller is responsible for the proper deallocation
* of the string returned.
*
* @param hexData A string containing the HexBinary
* @param manager The MemoryManager to use to allocate the string
*
* return: the canonical representation of the HexBinary
* if it is a valid HexBinary,
* 0 otherwise
*/
static XMLCh* getCanonicalRepresentation
(
const XMLCh* const hexData
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Decodes HexBinary data into XMLByte
*
* NOTE: The returned buffer is dynamically allocated and is the
* responsibility of the caller to delete it when not longer needed.
* Use the memory manager to release the returned buffer.
*
* @param hexData HexBinary data in XMLCh stream.
* @param manager client provided memory manager
* @return Decoded binary data in XMLByte stream,
* or NULL if input data can not be decoded.
*/
static XMLByte* decodeToXMLByte(
const XMLCh* const hexData
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
private :
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
static bool isHex(const XMLCh& octet);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
HexBin();
HexBin(const HexBin&);
HexBin& operator=(const HexBin&);
// -----------------------------------------------------------------------
// Private data members
//
// isInitialized
//
// set once hexNumberTable is initialized.
//
// hexNumberTable
//
// arrany holding valid hexNumber character.
//
// -----------------------------------------------------------------------
static const XMLByte hexNumberTable[];
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: IOException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IOEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_IOEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(IOException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: IllegalArgumentException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ILLEGALARGUMENTEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_ILLEGALARGUMENTEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(IllegalArgumentException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: InvalidCastException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_INVALIDCASTEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_INVALIDCASTEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(InvalidCastException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,166 @@
/*
* 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: Janitor.hpp 669844 2008-06-20 10:11:44Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_JANITOR_HPP)
#define XERCESC_INCLUDE_GUARD_JANITOR_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class T> class Janitor : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
Janitor(T* const toDelete);
~Janitor();
// -----------------------------------------------------------------------
// Public, non-virtual methods
// -----------------------------------------------------------------------
void orphan();
// small amount of auto_ptr compatibility
T& operator*() const;
T* operator->() const;
T* get() const;
T* release();
void reset(T* p = 0);
bool isDataNull();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Janitor();
Janitor(const Janitor<T>&);
Janitor<T>& operator=(const Janitor<T>&);
// -----------------------------------------------------------------------
// Private data members
//
// fData
// This is the pointer to the object or structure that must be
// destroyed when this object is destroyed.
// -----------------------------------------------------------------------
T* fData;
};
template <class T> class ArrayJanitor : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ArrayJanitor(T* const toDelete);
ArrayJanitor(T* const toDelete, MemoryManager* const manager);
~ArrayJanitor();
// -----------------------------------------------------------------------
// Public, non-virtual methods
// -----------------------------------------------------------------------
void orphan();
// small amount of auto_ptr compatibility
T& operator[](int index) const;
T* get() const;
T* release();
void reset(T* p = 0);
void reset(T* p, MemoryManager* const manager);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ArrayJanitor();
ArrayJanitor(const ArrayJanitor<T>& copy);
ArrayJanitor<T>& operator=(const ArrayJanitor<T>& copy);
// -----------------------------------------------------------------------
// Private data members
//
// fData
// This is the pointer to the object or structure that must be
// destroyed when this object is destroyed.
// -----------------------------------------------------------------------
T* fData;
MemoryManager* fMemoryManager;
};
template <class T> class JanitorMemFunCall
{
public :
typedef void (T::*MFPT) ();
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
JanitorMemFunCall(
T* object,
MFPT toCall);
~JanitorMemFunCall();
// small amount of auto_ptr compatibility
T& operator*() const;
T* operator->() const;
T* get() const;
T* release();
void reset(T* p = 0);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
JanitorMemFunCall();
JanitorMemFunCall(const JanitorMemFunCall<T>&);
JanitorMemFunCall<T>& operator=(const JanitorMemFunCall<T>&);
// -----------------------------------------------------------------------
// Private data members
//
// fObject
// This is the pointer to the object for which we will call the
// member function when this object is destroyed.
// -----------------------------------------------------------------------
T* fObject;
MFPT fToCall;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/Janitor.c>
#endif
#endif

View File

@@ -0,0 +1,223 @@
/*
* 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: KVStringPair.hpp 554580 2007-07-09 09:09:51Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_KVSTRINGPAIR_HPP)
#define XERCESC_INCLUDE_GUARD_KVSTRINGPAIR_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides a commonly used data structure, which is that of
// a pair of strings which represent a 'key=value' type mapping. It works
// only in terms of XMLCh type raw strings.
//
class XMLUTIL_EXPORT KVStringPair : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
KVStringPair(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
KVStringPair
(
const XMLCh* const key
, const XMLCh* const value
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
KVStringPair
(
const XMLCh* const key
, const XMLCh* const value
, const XMLSize_t valueLength
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
KVStringPair
(
const XMLCh* const key
, const XMLSize_t keyLength
, const XMLCh* const value
, const XMLSize_t valueLength
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
KVStringPair(const KVStringPair& toCopy);
~KVStringPair();
// -----------------------------------------------------------------------
// Getters
//
// We support the
// -----------------------------------------------------------------------
const XMLCh* getKey() const;
XMLCh* getKey();
const XMLCh* getValue() const;
XMLCh* getValue();
// -----------------------------------------------------------------------
// Setters
// -----------------------------------------------------------------------
void setKey(const XMLCh* const newKey);
void setValue(const XMLCh* const newValue);
void setKey
(
const XMLCh* const newKey
, const XMLSize_t newKeyLength
);
void setValue
(
const XMLCh* const newValue
, const XMLSize_t newValueLength
);
void set
(
const XMLCh* const newKey
, const XMLCh* const newValue
);
void set
(
const XMLCh* const newKey
, const XMLSize_t newKeyLength
, const XMLCh* const newValue
, const XMLSize_t newValueLength
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(KVStringPair)
private :
// unimplemented:
KVStringPair& operator=(const KVStringPair&);
// -----------------------------------------------------------------------
// Private data members
//
// fKey
// The string that represents the key field of this object.
//
// fKeyAllocSize
// The amount of memory allocated for fKey.
//
// fValue
// The string that represents the value of this pair object.
//
// fValueAllocSize
// The amount of memory allocated for fValue.
//
// -----------------------------------------------------------------------
XMLSize_t fKeyAllocSize;
XMLSize_t fValueAllocSize;
XMLCh* fKey;
XMLCh* fValue;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// KVStringPair: Getters
// ---------------------------------------------------------------------------
inline const XMLCh* KVStringPair::getKey() const
{
return fKey;
}
inline XMLCh* KVStringPair::getKey()
{
return fKey;
}
inline const XMLCh* KVStringPair::getValue() const
{
return fValue;
}
inline XMLCh* KVStringPair::getValue()
{
return fValue;
}
// ---------------------------------------------------------------------------
// KVStringPair: Setters
// ---------------------------------------------------------------------------
inline void KVStringPair::setKey(const XMLCh* const newKey)
{
setKey(newKey, XMLString::stringLen(newKey));
}
inline void KVStringPair::setValue(const XMLCh* const newValue)
{
setValue(newValue, XMLString::stringLen(newValue));
}
inline void KVStringPair::setKey( const XMLCh* const newKey
, const XMLSize_t newKeyLength)
{
if (newKeyLength >= fKeyAllocSize)
{
fMemoryManager->deallocate(fKey); //delete [] fKey;
fKey = 0;
fKeyAllocSize = newKeyLength + 1;
fKey = (XMLCh*) fMemoryManager->allocate(fKeyAllocSize * sizeof(XMLCh)); //new XMLCh[fKeyAllocSize];
}
memcpy(fKey, newKey, (newKeyLength+1) * sizeof(XMLCh)); // len+1 because of the 0 at the end
}
inline void KVStringPair::setValue( const XMLCh* const newValue
, const XMLSize_t newValueLength)
{
if (newValueLength >= fValueAllocSize)
{
fMemoryManager->deallocate(fValue); //delete [] fValue;
fValue = 0;
fValueAllocSize = newValueLength + 1;
fValue = (XMLCh*) fMemoryManager->allocate(fValueAllocSize * sizeof(XMLCh)); //new XMLCh[fValueAllocSize];
}
memcpy(fValue, newValue, (newValueLength+1) * sizeof(XMLCh)); // len+1 because of the 0 at the end
}
inline void KVStringPair::set( const XMLCh* const newKey
, const XMLCh* const newValue)
{
setKey(newKey, XMLString::stringLen(newKey));
setValue(newValue, XMLString::stringLen(newValue));
}
inline void KVStringPair::set( const XMLCh* const newKey
, const XMLSize_t newKeyLength
, const XMLCh* const newValue
, const XMLSize_t newValueLength)
{
setKey(newKey, newKeyLength);
setValue(newValue, newValueLength);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,81 @@
/*
* 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: KeyRefPair.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_KEYREFPAIR_HPP)
#define XERCESC_INCLUDE_GUARD_KEYREFPAIR_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class TKey, class TValue> class KeyRefPair : public XMemory
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
KeyRefPair();
KeyRefPair(TKey* key, TValue* value);
KeyRefPair(const KeyRefPair<TKey,TValue>* toCopy);
KeyRefPair(const KeyRefPair<TKey,TValue>& toCopy);
~KeyRefPair();
// -------------------------------------------------------------------
// Getters
// -------------------------------------------------------------------
const TKey* getKey() const;
TKey* getKey();
const TValue* getValue() const;
TValue* getValue();
// -------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------
TKey* setKey(TKey* newKey);
TValue* setValue(TValue* newValue);
private :
// unimplemented:
KeyRefPair<TKey,TValue>& operator=(const KeyRefPair<TKey,TValue>&);
// -------------------------------------------------------------------
// Private data members
//
// fKey
// The object that represents the key of the pair
//
// fValue
// The object that represents the value of the pair
// -------------------------------------------------------------------
TKey* fKey;
TValue* fValue;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/KeyRefPair.c>
#endif
#endif

View File

@@ -0,0 +1,81 @@
/*
* 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: KeyValuePair.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_KEYVALUEPAIR_HPP)
#define XERCESC_INCLUDE_GUARD_KEYVALUEPAIR_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class TKey, class TValue> class KeyValuePair : public XMemory
{
public :
// -------------------------------------------------------------------
// Constructors and Destructor
// -------------------------------------------------------------------
KeyValuePair();
KeyValuePair(const TKey& key, const TValue& value);
KeyValuePair(const KeyValuePair<TKey,TValue>& toCopy);
~KeyValuePair();
// -------------------------------------------------------------------
// Getters
// -------------------------------------------------------------------
const TKey& getKey() const;
TKey& getKey();
const TValue& getValue() const;
TValue& getValue();
// -------------------------------------------------------------------
// Setters
// -------------------------------------------------------------------
TKey& setKey(const TKey& newKey);
TValue& setValue(const TValue& newValue);
private :
// unimplemented:
KeyValuePair<TKey,TValue>& operator=(const KeyValuePair<TKey,TValue>&);
// -------------------------------------------------------------------
// Private data members
//
// fKey
// The object that represents the key of the pair
//
// fValue
// The object that represents the value of the pair
// -------------------------------------------------------------------
TKey fKey;
TValue fValue;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/KeyValuePair.c>
#endif
#endif

View File

@@ -0,0 +1,101 @@
/*
* 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: InMemMsgLoader.hpp 570552 2007-08-28 19:57:36Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_INMEMMSGLOADER_HPP)
#define XERCESC_INCLUDE_GUARD_INMEMMSGLOADER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLMsgLoader.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This is a simple in memory message loader implementation. For those
// folks who just want a single language and want something very fast and
// efficient, can basically just provide a couple of arrays of Unicode
// strings that can be looked up by the message id.
//
class XMLUTIL_EXPORT InMemMsgLoader : public XMLMsgLoader
{
public :
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
InMemMsgLoader(const XMLCh* const msgDomain);
~InMemMsgLoader();
// -----------------------------------------------------------------------
// Implementation of the virtual message loader API
// -----------------------------------------------------------------------
virtual bool loadMsg
(
const XMLMsgLoader::XMLMsgId msgToLoad
, XMLCh* const toFill
, const XMLSize_t maxChars
);
virtual bool loadMsg
(
const XMLMsgLoader::XMLMsgId msgToLoad
, XMLCh* const toFill
, const XMLSize_t maxChars
, const XMLCh* const repText1
, const XMLCh* const repText2 = 0
, const XMLCh* const repText3 = 0
, const XMLCh* const repText4 = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual bool loadMsg
(
const XMLMsgLoader::XMLMsgId msgToLoad
, XMLCh* const toFill
, const XMLSize_t maxChars
, const char* const repText1
, const char* const repText2 = 0
, const char* const repText3 = 0
, const char* const repText4 = 0
, MemoryManager * const manager = XMLPlatformUtils::fgMemoryManager
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
InMemMsgLoader();
InMemMsgLoader(const InMemMsgLoader&);
InMemMsgLoader& operator=(const InMemMsgLoader&);
// -----------------------------------------------------------------------
// Private data members
//
// fMsgDomain
// This is the message domain that we are for loading message from.
// -----------------------------------------------------------------------
XMLCh* fMsgDomain;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,51 @@
/*
* 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: NoThreadMutexMgr.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NOTHREADMUTEXMGR_HPP)
#define XERCESC_INCLUDE_GUARD_NOTHREADMUTEXMGR_HPP
#include <xercesc/util/XMLMutexMgr.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/*
The NoThread mutex manager is for use where no threading is used
in an environment. Since no threading is used, mutexes are not
needed, so the implementation does essentially nothing.
*/
class NoThreadMutexMgr : public XMLMutexMgr
{
public:
NoThreadMutexMgr();
virtual ~NoThreadMutexMgr();
// Mutex operations
virtual XMLMutexHandle create(MemoryManager* const manager);
virtual void destroy(XMLMutexHandle mtx, MemoryManager* const manager);
virtual void lock(XMLMutexHandle mtx);
virtual void unlock(XMLMutexHandle mtx);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,47 @@
/*
* 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: PosixMutexMgr.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_POSIXMUTEXMGR_HPP)
#define XERCESC_INCLUDE_GUARD_POSIXMUTEXMGR_HPP
#include <xercesc/util/XMLMutexMgr.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// Posix mutex implementation.
class PosixMutexMgr : public XMLMutexMgr
{
public:
PosixMutexMgr();
virtual ~PosixMutexMgr();
// Mutex operations
virtual XMLMutexHandle create(MemoryManager* const manager);
virtual void destroy(XMLMutexHandle mtx, MemoryManager* const manager);
virtual void lock(XMLMutexHandle mtx);
virtual void unlock(XMLMutexHandle mtx);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,108 @@
/*
* 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: Mutexes.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_MUTEXES_HPP)
#define XERCESC_INCLUDE_GUARD_MUTEXES_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLMutex : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLMutex(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~XMLMutex();
// -----------------------------------------------------------------------
// Lock control methods
// -----------------------------------------------------------------------
void lock();
void unlock();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLMutex(const XMLMutex&);
XMLMutex& operator=(const XMLMutex&);
// -----------------------------------------------------------------------
// Private data members
//
// fHandle
// The raw mutex handle. Its just a void pointer so we do not
// pass judgement on its value at all. We just pass it into the
// platform utilities methods which knows what's really in it.
// fManager
// The MemoryManager that this XMLMutex was initialized with.
// -----------------------------------------------------------------------
void* fHandle;
MemoryManager* fManager;
// -----------------------------------------------------------------------
// Sun PlatformUtils needs access to fHandle to initialize the
// atomicOpsMutex at startup.
// -----------------------------------------------------------------------
friend class XMLPlatformUtils;
};
class XMLUTIL_EXPORT XMLMutexLock : public XMemory
{
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
public:
XMLMutexLock(XMLMutex* const toLock);
~XMLMutexLock();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLMutexLock();
XMLMutexLock(const XMLMutexLock&);
XMLMutexLock& operator=(const XMLMutexLock&);
// -----------------------------------------------------------------------
// Private data members
//
// fToLock
// The mutex object that we are locking
// -----------------------------------------------------------------------
XMLMutex* fToLock;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,207 @@
/*
* 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: NameIdPool.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NAMEIDPOOL_HPP)
#define XERCESC_INCLUDE_GUARD_NAMEIDPOOL_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// Forward declare the enumerator so he can be our friend. Can you say
// friend? Sure...
//
template <class TElem> class NameIdPoolEnumerator;
//
// This class is provided to serve as the basis of many of the pools that
// are used by the scanner and validators. They often need to be able to
// store objects in such a way that they can be quickly accessed by the
// name field of the object, and such that each element added is assigned
// a unique id via which it can be accessed almost instantly.
//
// Object names are enforced as being unique, since that's what all these
// pools require. So its effectively a hash table in conjunction with an
// array of references into the hash table by id. Ids are assigned such that
// id N can be used to get the Nth element from the array of references.
// This provides very fast access by id.
//
// The way these pools are used, elements are never removed except when the
// whole thing is flushed. This makes it very easy to maintain the two
// access methods in sync.
//
// For efficiency reasons, the id reference array is never flushed until
// the dtor. This way, it does not have to be regrown every time its reused.
//
// All elements are assumed to be owned by the pool!
//
template <class TElem> class NameIdPool : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
NameIdPool
(
const XMLSize_t hashModulus
, const XMLSize_t initSize = 128
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~NameIdPool();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool containsKey(const XMLCh* const key) const;
void removeAll();
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
TElem* getByKey(const XMLCh* const key);
const TElem* getByKey(const XMLCh* const key) const;
TElem* getById(const XMLSize_t elemId);
const TElem* getById(const XMLSize_t elemId) const;
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Putters
//
// Dups are not allowed and cause an IllegalArgumentException. The id
// of the new element is returned.
// -----------------------------------------------------------------------
XMLSize_t put(TElem* const valueToAdopt);
protected :
// -----------------------------------------------------------------------
// Declare the enumerator our friend so he can see our members
// -----------------------------------------------------------------------
friend class NameIdPoolEnumerator<TElem>;
private :
// -----------------------------------------------------------------------
// Unused constructors and operators
// -----------------------------------------------------------------------
NameIdPool(const NameIdPool<TElem>&);
NameIdPool<TElem>& operator=(const NameIdPool<TElem>&);
// -----------------------------------------------------------------------
// Data members
//
// fBucketList
// This is the hash table that contains the values.
//
// fIdPtrs
// fIdPtrsCount
// This is the array of pointers to the bucket elements in order of
// their assigned ids. So taking id N and referencing this array
// gives you the element with that id. The count field indicates
// the current size of this list. When fIdCounter+1 reaches this
// value the list must be expanded.
//
// fIdCounter
// This is used to give out unique ids to added elements. It starts
// at zero (which means empty), and is bumped up for each newly added
// element. So the first element is 1, the next is 2, etc... This
// means that this value is set to the top index of the fIdPtrs array.
//
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
TElem** fIdPtrs;
XMLSize_t fIdPtrsCount;
XMLSize_t fIdCounter;
RefHashTableOf<TElem> fBucketList;
};
//
// An enumerator for a name id pool. It derives from the basic enumerator
// class, so that pools can be generically enumerated.
//
template <class TElem> class NameIdPoolEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
NameIdPoolEnumerator
(
NameIdPool<TElem>* const toEnum
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
NameIdPoolEnumerator
(
const NameIdPoolEnumerator<TElem>& toCopy
);
virtual ~NameIdPoolEnumerator();
// -----------------------------------------------------------------------
// Public operators
// -----------------------------------------------------------------------
NameIdPoolEnumerator<TElem>& operator=
(
const NameIdPoolEnumerator<TElem>& toAssign
);
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
XMLSize_t size() const;
private :
// -----------------------------------------------------------------------
// Data Members
//
// fCurIndex
// This is the current index into the pool's id mapping array. This
// is now we enumerate it.
//
// fToEnum
// The name id pool that is being enumerated.
// -----------------------------------------------------------------------
XMLSize_t fCurIndex;
NameIdPool<TElem>* fToEnum;
MemoryManager* fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/NameIdPool.c>
#endif
#endif

View File

@@ -0,0 +1,228 @@
/*
* 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: BinFileInputStream.hpp 553903 2007-07-06 14:43:42Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BINHTTPINPUTSTREAMCOMMON_HPP)
#define XERCESC_INCLUDE_GUARD_BINHTTPINPUTSTREAMCOMMON_HPP
#include <xercesc/util/XMLURL.hpp>
#include <xercesc/util/BinInputStream.hpp>
#include <xercesc/util/XMLNetAccessor.hpp>
#include <xercesc/framework/MemoryManager.hpp>
#include <string.h>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class implements a simple expanding character buffer
//
class XMLUTIL_EXPORT CharBuffer
{
public:
CharBuffer(XMLSize_t capacity = 1023,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager)
: fCapacity(capacity),
fIndex(0),
fMemoryManager(manager)
{
fBuffer = (char*)fMemoryManager->allocate((fCapacity + 1) * sizeof(char));
}
~CharBuffer()
{
fMemoryManager->deallocate(fBuffer);
}
const char* getRawBuffer() const
{
fBuffer[fIndex] = 0;
return fBuffer;
}
char* getRawBuffer()
{
fBuffer[fIndex] = 0;
return fBuffer;
}
XMLSize_t getLen() const
{
return fIndex;
}
void reset()
{
fIndex = 0;
}
void append(const char *chars)
{
if(chars != 0 && *chars != 0) {
// get length of chars
XMLSize_t count = 0;
for(; *(chars+count); ++count) ;
if(fIndex + count >= fCapacity) {
ensureCapacity(count);
}
memcpy(&fBuffer[fIndex], chars, count * sizeof(char));
fIndex += count;
}
}
void append(const char *chars, XMLSize_t len)
{
if(chars != 0 && len != 0) {
if(fIndex + len >= fCapacity) {
ensureCapacity(len);
}
memcpy(&fBuffer[fIndex], chars, len * sizeof(char));
fIndex += len;
}
}
void appendDecimalNumber(unsigned int n)
{
if(n >= 10) {
appendDecimalNumber(n / 10);
n = n % 10;
}
if(fIndex + 1 >= fCapacity)
ensureCapacity(1);
fBuffer[fIndex] = '0' + n;
++fIndex;
}
void set(const char *chars)
{
reset();
append(chars);
}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CharBuffer(const CharBuffer &);
CharBuffer &operator=(const CharBuffer &);
void ensureCapacity(XMLSize_t extraNeeded)
{
// If we can't handle it, try doubling the buffer size.
XMLSize_t newCap = (fIndex + extraNeeded) * 2;
if(newCap > fCapacity)
{
// Allocate new buffer
char* newBuf = (char*)fMemoryManager->allocate((newCap + 1) * sizeof(char));
// Copy over the old stuff
memcpy(newBuf, fBuffer, fIndex * sizeof(char));
// Clean up old buffer and store new stuff
fMemoryManager->deallocate(fBuffer);
fBuffer = newBuf;
fCapacity = newCap;
}
}
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
char *fBuffer;
XMLSize_t fCapacity;
XMLSize_t fIndex;
MemoryManager *fMemoryManager;
};
//
// Common base implementation of HTTP BinInputStream that is used by some
// platform-specific implementations.
//
class XMLUTIL_EXPORT BinHTTPInputStreamCommon : public BinInputStream
{
public :
virtual XMLFilePos curPos() const;
virtual XMLSize_t readBytes
(
XMLByte* const toFill
, const XMLSize_t maxToRead
);
virtual const XMLCh *getContentType() const;
protected :
BinHTTPInputStreamCommon(MemoryManager *manager);
virtual ~BinHTTPInputStreamCommon();
/**
* \return The HTTP status code
*/
int sendRequest(const XMLURL &url, const XMLNetHTTPInfo *httpInfo);
XMLCh *findHeader(const char *name);
virtual bool send(const char *buf, XMLSize_t len) = 0;
/**
* \return The length of the data received, or -1 if an error occured
*/
virtual int receive(char *buf, XMLSize_t len) = 0;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
BinHTTPInputStreamCommon(const BinHTTPInputStreamCommon&);
BinHTTPInputStreamCommon& operator=(const BinHTTPInputStreamCommon&);
void createHTTPRequest(const XMLURL &urlSource, const XMLNetHTTPInfo *httpInfo, CharBuffer &buffer);
// -----------------------------------------------------------------------
// Private data members
//
// fBytesProcessed
// Its a rolling count of the number of bytes processed off this
// input stream.
// fBuffer
// Holds the http header, plus the first part of the actual
// data. Filled at the time the stream is opened, data goes
// out to user in response to readBytes().
// fBufferPos
// Pointers into fBuffer, showing start and end+1 of content
// that readBytes must return.
// -----------------------------------------------------------------------
XMLSize_t fBytesProcessed;
CharBuffer fBuffer;
char * fBufferPos;
XMLCh * fContentType;
MemoryManager* fMemoryManager;
};
inline XMLFilePos BinHTTPInputStreamCommon::curPos() const
{
return fBytesProcessed;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: NoSuchElementException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NOSUCHELEMENTEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_NOSUCHELEMENTEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(NoSuchElementException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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: NullPointerException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NULLPOINTEREXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_NULLPOINTEREXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(NullPointerException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: NumberFormatException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NUMBERFORMATEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_NUMBERFORMATEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(NumberFormatException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,96 @@
/*
* 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: OutOfMemoryException.hpp 673960 2008-07-04 08:50:12Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_OUT_OF_MEMORY_EXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_OUT_OF_MEMORY_EXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/XMLExceptMsgs.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
static const XMLCh gDefOutOfMemoryErrMsg[] =
{
chLatin_O, chLatin_u, chLatin_t, chLatin_O
, chLatin_f, chLatin_M, chLatin_e, chLatin_m
, chLatin_o, chLatin_r, chLatin_y, chNull
};
class XMLUTIL_EXPORT OutOfMemoryException : public XMemory
{
public:
OutOfMemoryException();
~OutOfMemoryException();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLExcepts::Codes getCode() const;
const XMLCh* getMessage() const;
const XMLCh* getType() const;
const char* getSrcFile() const;
XMLFileLoc getSrcLine() const;
OutOfMemoryException(const OutOfMemoryException& toCopy);
OutOfMemoryException& operator=(const OutOfMemoryException& toAssign);
};
// constructors/destructors...
inline OutOfMemoryException::OutOfMemoryException() {}
inline OutOfMemoryException::~OutOfMemoryException() {}
inline OutOfMemoryException::OutOfMemoryException(const OutOfMemoryException& other) : XMemory(other) {}
inline OutOfMemoryException& OutOfMemoryException::operator=(const OutOfMemoryException&)
{
return *this;
}
// ---------------------------------------------------------------------------
// OutOfMemoryException: Getter methods
// ---------------------------------------------------------------------------
inline XMLExcepts::Codes OutOfMemoryException::getCode() const
{
return XMLExcepts::Out_Of_Memory;
}
inline const XMLCh* OutOfMemoryException::getMessage() const
{
return gDefOutOfMemoryErrMsg;
}
inline const XMLCh* OutOfMemoryException::getType() const
{
return gDefOutOfMemoryErrMsg;
}
inline const char* OutOfMemoryException::getSrcFile() const
{
return "";
}
inline XMLFileLoc OutOfMemoryException::getSrcLine() const {
return 0;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,239 @@
/*
* 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: PSVIUni.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_PSVIUNI_HPP)
#define XERCESC_INCLUDE_GUARD_PSVIUNI_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT PSVIUni
{
public :
static const XMLCh fgPsvColon[];
//Infoset Element Names
static const XMLCh fgAllDeclarationsProcessed[];
static const XMLCh fgAttribute[];
static const XMLCh fgAttributes[];
static const XMLCh fgAttributeType[];
static const XMLCh fgBaseURI[];
static const XMLCh fgCharacter[];
static const XMLCh fgCharacterEncodingScheme[];
static const XMLCh fgChildren[];
static const XMLCh fgComment[];
static const XMLCh fgContent[];
static const XMLCh fgDocument[];
static const XMLCh fgDocTypeDeclaration[];
static const XMLCh fgDocumentElement[];
static const XMLCh fgElement[];
static const XMLCh fgInScopeNamespaces[];
static const XMLCh fgLocalName[];
static const XMLCh fgNamespace[];
static const XMLCh fgNamespaceAttributes[];
static const XMLCh fgNamespaceName[];
static const XMLCh fgNormalizedValue[];
static const XMLCh fgNotations[];
static const XMLCh fgPrefix[];
static const XMLCh fgProcessingInstruction[];
static const XMLCh fgReferences[];
static const XMLCh fgSpecified[];
static const XMLCh fgStandalone[];
static const XMLCh fgTarget[];
static const XMLCh fgText[];
static const XMLCh fgTextContent[];
static const XMLCh fgUnparsedEntities[];
static const XMLCh fgVersion[];
//PSVI Element Names
static const XMLCh fgAbstract[];
static const XMLCh fgAnnotation[];
static const XMLCh fgAnnotations[];
static const XMLCh fgApplicationInformation[];
static const XMLCh fgAttributeDeclaration[];
static const XMLCh fgAttributeGroupDefinition[];
static const XMLCh fgAttributeUse[];
static const XMLCh fgAttributeUses[];
static const XMLCh fgAttributeWildcard[];
static const XMLCh fgBaseTypeDefinition[];
static const XMLCh fgCanonicalRepresentation[];
static const XMLCh fgComplexTypeDefinition[];
static const XMLCh fgCompositor[];
static const XMLCh fgContentType[];
static const XMLCh fgDeclaration[];
static const XMLCh fgDerivationMethod[];
static const XMLCh fgDisallowedSubstitutions[];
static const XMLCh fgPsvDocument[];
static const XMLCh fgDocumentLocation[];
static const XMLCh fgElementDeclaration[];
static const XMLCh fgFacets[];
static const XMLCh fgFacetFixed[];
static const XMLCh fgFields[];
static const XMLCh fgFinal[];
static const XMLCh fgFundamentalFacets[];
static const XMLCh fgIdentityConstraintCategory[];
static const XMLCh fgIdentityConstraintDefinition[];
static const XMLCh fgIdentityConstraintDefinitions[];
static const XMLCh fgIdentityConstraintTable[];
static const XMLCh fgIdIdrefTable[];
static const XMLCh fgItemTypeDefinition[];
static const XMLCh fgMaxOccurs[];
static const XMLCh fgMemberTypeDefinition[];
static const XMLCh fgMemberTypeDefinitions[];
static const XMLCh fgMinOccurs[];
static const XMLCh fgModelGroup[];
static const XMLCh fgModelGroupDefinition[];
static const XMLCh fgName[];
static const XMLCh fgNamespaceConstraint[];
static const XMLCh fgNamespaces[];
static const XMLCh fgNamespaceSchemaInformation[];
static const XMLCh fgNil[];
static const XMLCh fgNillable[];
static const XMLCh fgNotation[];
static const XMLCh fgNotationDeclaration[];
static const XMLCh fgParticle[];
static const XMLCh fgParticles[];
static const XMLCh fgPrimitiveTypeDefinition[];
static const XMLCh fgProcessContents[];
static const XMLCh fgProhibitedSubstitutions[];
static const XMLCh fgPublicIdentifier[];
static const XMLCh fgReferencedKey[];
static const XMLCh fgRequired[];
static const XMLCh fgSchemaAnnotations[];
static const XMLCh fgSchemaComponents[];
static const XMLCh fgSchemaDefault[];
static const XMLCh fgSchemaDocument[];
static const XMLCh fgSchemaDocuments[];
static const XMLCh fgSchemaErrorCode[];
static const XMLCh fgSchemaInformation[];
static const XMLCh fgSchemaNamespace[];
static const XMLCh fgSchemaNormalizedValue[];
static const XMLCh fgSchemaSpecified[];
static const XMLCh fgScope[];
static const XMLCh fgSelector[];
static const XMLCh fgSimpleTypeDefinition[];
static const XMLCh fgSubstitutionGroupAffiliation[];
static const XMLCh fgSubstitutionGroupExclusions[];
static const XMLCh fgSystemIdentifier[];
static const XMLCh fgTargetNamespace[];
static const XMLCh fgTerm[];
static const XMLCh fgTypeDefinition[];
static const XMLCh fgUserInformation[];
static const XMLCh fgValidationAttempted[];
static const XMLCh fgValidationContext[];
static const XMLCh fgValidity[];
static const XMLCh fgValue[];
static const XMLCh fgValueConstraint[];
static const XMLCh fgVariety[];
static const XMLCh fgWildcard[];
static const XMLCh fgXpath[];
//PSVI Element Values
static const XMLCh fgAll[];
static const XMLCh fgAny[];
static const XMLCh fgAppinfo[];
static const XMLCh fgAtomic[];
static const XMLCh fgChoice[];
static const XMLCh fgDefault[];
static const XMLCh fgDocumentation[];
static const XMLCh fgElementOnly[];
static const XMLCh fgEmpty[];
static const XMLCh fgExtension[];
static const XMLCh fgFalse[];
static const XMLCh fgFull[];
static const XMLCh fgGlobal[];
static const XMLCh fgInfoset[];
static const XMLCh fgInvalid[];
static const XMLCh fgKey[];
static const XMLCh fgKeyref[];
static const XMLCh fgLax[];
static const XMLCh fgList[];
static const XMLCh fgLocal[];
static const XMLCh fgMixed[];
static const XMLCh fgNone[];
static const XMLCh fgNotKnown[];
static const XMLCh fgNsNamespace[];
static const XMLCh fgOnePointZero[];
static const XMLCh fgPartial[];
static const XMLCh fgRestrict[];
static const XMLCh fgRestriction[];
static const XMLCh fgSchema[];
static const XMLCh fgSequence[];
static const XMLCh fgSimple[];
static const XMLCh fgSkip[];
static const XMLCh fgStrict[];
static const XMLCh fgSubstitution[];
static const XMLCh fgTotal[];
static const XMLCh fgTrue[];
static const XMLCh fgUnbounded[];
static const XMLCh fgUnion[];
static const XMLCh fgUnique[];
static const XMLCh fgUnknown[];
static const XMLCh fgValid[];
static const XMLCh fgVCFixed[];
static const XMLCh fgXMLChNull[];
//PSVI Element Types (Shortened)
static const XMLCh fgAg[];
static const XMLCh fgAnnot[];
static const XMLCh fgAttr[];
static const XMLCh fgAu[];
static const XMLCh fgElt[];
static const XMLCh fgIdc[];
static const XMLCh fgMg[];
static const XMLCh fgNot[];
static const XMLCh fgType[];
//Facets
static const XMLCh fgBounded[];
static const XMLCh fgCardinality[];
static const XMLCh fgEnumeration[];
static const XMLCh fgFractionDigits[];
static const XMLCh fgLength[];
static const XMLCh fgMaxExclusive[];
static const XMLCh fgMaxInclusive[];
static const XMLCh fgMaxLength[];
static const XMLCh fgMinExclusive[];
static const XMLCh fgMinInclusive[];
static const XMLCh fgMinLength[];
static const XMLCh fgNumeric[];
static const XMLCh fgOrdered[];
static const XMLCh fgPattern[];
static const XMLCh fgTotalDigits[];
static const XMLCh fgWhiteSpace[];
//Namespaces and prefixes
static const XMLCh fgNamespaceInfoset[];
static const XMLCh fgXsi[];
static const XMLCh fgNamespaceInstance[];
static const XMLCh fgPsv[];
static const XMLCh fgNamespacePsvi[];
static const XMLCh fgXml[];
static const XMLCh fgNamespaceXmlSchema[];
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,112 @@
/*
* 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: PanicHandler.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_PANICHANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_PANICHANDLER_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Receive notification of panic.
*
* <p>This is the interface, through which the Xercesc reports
* a panic to the application.
* </p>
*
* <p>Application may implement this interface, instantiate an
* object of the derivative, and plug it to Xercesc in the
* invocation to XMLPlatformUtils::Initialize(), if it prefers
* to handling panic itself rather than Xercesc doing it.
* </p>
*
*/
class XMLUTIL_EXPORT PanicHandler
{
public:
/** @name Public Types */
//@{
enum PanicReasons
{
Panic_NoTransService
, Panic_NoDefTranscoder
, Panic_CantFindLib
, Panic_UnknownMsgDomain
, Panic_CantLoadMsgDomain
, Panic_SynchronizationErr
, Panic_SystemInit
, Panic_AllStaticInitErr
, Panic_MutexErr
, PanicReasons_Count
};
//@}
protected:
/** @name hidden Constructors */
//@{
/** Default constructor */
PanicHandler(){};
public:
/** Destructor */
virtual ~PanicHandler(){};
//@}
/** @name The virtual panic handler interface */
//@{
/**
* Receive notification of panic
*
* This method is called when an unrecoverable error has occurred in the Xerces library.
*
* This method must not return normally, otherwise, the results are undefined.
*
* Ways of handling this call could include throwing an exception or exiting the process.
*
* Once this method has been called, the results of calling any other Xerces API,
* or using any existing Xerces objects are undefined.
*
* @param reason The reason of panic
*
*/
virtual void panic(const PanicHandler::PanicReasons reason) = 0;
//@}
static const char* getPanicReasonString(const PanicHandler::PanicReasons reason);
private:
/* Unimplemented Constructors and operators */
/* Copy constructor */
PanicHandler(const PanicHandler&);
/** Assignment operator */
PanicHandler& operator=(const PanicHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: ParseException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_PARSEEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_PARSEEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(ParseException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,839 @@
/*
* 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: PlatformUtils.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_PLATFORMUTILS_HPP)
#define XERCESC_INCLUDE_GUARD_PLATFORMUTILS_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/PanicHandler.hpp>
#include <xercesc/util/XMLFileMgr.hpp>
#include <xercesc/util/XMLMutexMgr.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLMsgLoader;
class XMLNetAccessor;
class XMLTransService;
class MemoryManager;
class XMLMutex;
//
// For internal use only
//
// This class provides a simple abstract API via which lazily evaluated
// data can be cleaned up.
//
class XMLUTIL_EXPORT XMLDeleter
{
public :
virtual ~XMLDeleter();
protected :
XMLDeleter();
private :
XMLDeleter(const XMLDeleter&);
XMLDeleter& operator=(const XMLDeleter&);
};
/**
* Utilities that must be implemented in a platform-specific way.
*
* This class contains methods that must be implemented in a platform
* specific manner. The actual implementations of these methods are
* available in the per-platform files inside <code>src/util/Platforms
* </code>.
*/
class XMLUTIL_EXPORT XMLPlatformUtils
{
public :
/** @name Public Static Data */
//@{
/** The network accessor
*
* This is provided by the per-platform driver, so each platform can
* choose what actual implementation it wants to use. The object must
* be dynamically allocated.
*
* <i>Note that you may optionally, if your platform driver does not
* install a network accessor, set it manually from your client code
* after calling Initialize(). This works because this object is
* not required during initialization, and only comes into play during
* actual XML parsing.</i>
*/
static XMLNetAccessor* fgNetAccessor;
/** The transcoding service.
*
* This is provided by the per platform driver, so each platform can
* choose what implementation it wants to use. When the platform
* independent initialization code needs to get a transcoding service
* object, it will call <code>makeTransService()</code> to ask the
* per-platform code to create one. Only one transcoding service
* object is requested per-process, so it is shared and synchronized
* among parser instances within that process.
*/
static XMLTransService* fgTransService;
#ifdef OS390
static XMLTransService* fgTransService2;
#endif
/** The Panic Handler
*
* This is the application provided panic handler.
*/
static PanicHandler* fgUserPanicHandler;
/** The Panic Handler
*
* This is the default panic handler.
*/
static PanicHandler* fgDefaultPanicHandler;
/** The configurable memory manager
*
* This is the pluggable memory manager. If it is not provided by an
* application, a default implementation is used.
*/
static MemoryManager* fgMemoryManager;
static XMLFileMgr* fgFileMgr;
static XMLMutexMgr* fgMutexMgr;
/** Global mutex for fast or infrequent operations.
*
* Use this mutex only for fast (e.g., increment an integer,
* check flag, etc.) or infrequent (e.g., once-off initialization)
* operations.
*/
static XMLMutex* fgAtomicMutex;
static bool fgXMLChBigEndian;
static bool fgSSE2ok;
//@}
/** @name Initialization and Panic methods */
//@{
/** Perform per-process parser initialization
*
* Initialization <b>must</b> be called first in any client code.
*
* @param locale The locale to use for messages.
*
* The locale is set iff the Initialize() is invoked for the very first time,
* to ensure that each and every message loader, in the process space, share
* the same locale.
*
* All subsequent invocations of Initialize(), with a different locale, have
* no effect on the message loaders, either instantiated, or to be instantiated.
*
* To set to a different locale, client application needs to Terminate() (or
* multiple Terminate() in the case where multiple Initialize() have been invoked
* before), followed by Initialize(new_locale).
*
* The default locale is "en_US".
*
* @param nlsHome User specified location where MsgLoader retrieves error message files.
* the discussion above with regard to locale, applies to nlsHome as well.
*
* @param panicHandler Application's panic handler, application owns this handler.
* Application shall make sure that the plugged panic handler persists
* through the call to XMLPlatformUtils::Terminate().
*
* @param memoryManager Plugged-in memory manager which is owned by the
* application. Applications must make sure that the
* plugged-in memory manager persist through the call to
* XMLPlatformUtils::Terminate()
*/
static void Initialize(const char* const locale = XMLUni::fgXercescDefaultLocale
, const char* const nlsHome = 0
, PanicHandler* const panicHandler = 0
, MemoryManager* const memoryManager = 0);
/** Perform per-process parser initialization
*
* Initialization <b>must</b> be called first in any client code.
*
* @param initialDOMHeapAllocSize The size of the first memory block
* allocated by the DOMDocument heap. Note that changing this parameter
* may result in poor performance and/or excessive memory usage. For
* the default value refer to dom/impl/DOMDocumentImpl.cpp.
*
* @param maxDOMHeapAllocSize The maximum size of the memory block
* allocated by the DOMDocument heap. As the document grows, the
* allocated by the heap memory blocks grow from initialDOMHeapAllocSize
* to maxDOMHeapAllocSize. Note that changing this parameter may result
* in poor performance and/or excessive memory usage. For the default
* value refer to dom/impl/DOMDocumentImpl.cpp.
*
* @param maxDOMSubAllocationSize The maximum size of the memory block
* requested that is handled by the DOMDocument heap. A request for a
* larger block is handled directly by the memory manager. Note that
* changing this parameter may result in poor performance and/or
* excessive memory usage. For the default value refer to
* dom/impl/DOMDocumentImpl.cpp.
*
* @param locale The locale to use for messages.
*
* The locale is set iff the Initialize() is invoked for the very first time,
* to ensure that each and every message loader, in the process space, share
* the same locale.
*
* All subsequent invocations of Initialize(), with a different locale, have
* no effect on the message loaders, either instantiated, or to be instantiated.
*
* To set to a different locale, client application needs to Terminate() (or
* multiple Terminate() in the case where multiple Initialize() have been invoked
* before), followed by Initialize(new_locale).
*
* The default locale is "en_US".
*
* @param nlsHome User specified location where MsgLoader retrieves error message files.
* the discussion above with regard to locale, applies to nlsHome as well.
*
* @param panicHandler Application's panic handler, application owns this handler.
* Application shall make sure that the plugged panic handler persists
* through the call to XMLPlatformUtils::Terminate().
*
* @param memoryManager Plugged-in memory manager which is owned by the
* application. Applications must make sure that the plugged-in memory
* manager persist through the call to XMLPlatformUtils::Terminate()
*/
static void Initialize(XMLSize_t initialDOMHeapAllocSize
, XMLSize_t maxDOMHeapAllocSize
, XMLSize_t maxDOMSubAllocationSize
, const char* const locale = XMLUni::fgXercescDefaultLocale
, const char* const nlsHome = 0
, PanicHandler* const panicHandler = 0
, MemoryManager* const memoryManager = 0);
/** Perform per-process parser termination
*
* The termination call is currently optional, to aid those dynamically
* loading the parser to clean up before exit, or to avoid spurious
* reports from leak detectors.
*/
static void Terminate();
/** The panic mechanism.
*
* If, during initialization, we cannot even get far enough along
* to get transcoding up or get message loading working, we call
* this method.</p>
*
* Each platform can implement it however they want. This method will
* delegate the panic handling to a user specified panic handler or
* in the absence of it, the default panic handler.
*
* In case the default panic handler does not support a particular
* platform, the platform specific panic handling shall be implemented
* here </p>.
*
* @param reason The enumeration that defines the cause of the failure
*/
static void panic
(
const PanicHandler::PanicReasons reason
);
//@}
/** @name File Methods */
//@{
/** Make a new file object appropriate for the platform.
*
* @param manager The MemoryManager to use to allocate objects
*/
static XMLFileMgr* makeFileMgr(MemoryManager* const manager);
/** Get the current file position
*
* This must be implemented by the per-platform driver, which should
* use local file services to determine the current position within
* the passed file.
*
* Since the file API provided here only reads, if the host platform
* supports separate read/write positions, only the read position is
* of any interest, and hence should be the one returned.
*
* @param theFile The file handle
* @param manager The MemoryManager to use to allocate objects
*/
static XMLFilePos curFilePos(FileHandle theFile
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Closes the file handle
*
* This must be implemented by the per-platform driver, which should
* use local file services to close the passed file handle, and to
* destroy the passed file handle and any allocated data or system
* resources it contains.
*
* @param theFile The file handle to close
* @param manager The MemoryManager to use to allocate objects
*/
static void closeFile(FileHandle theFile
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Returns the file size
*
* This must be implemented by the per-platform driver, which should
* use local file services to determine the current size of the file
* represented by the passed handle.
*
* @param theFile The file handle whose size you want
* @param manager The MemoryManager to use to allocate objects
* @return Returns the size of the file in bytes
*/
static XMLFilePos fileSize(FileHandle theFile
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Opens the file
*
* This must be implemented by the per-platform driver, which should
* use local file services to open passed file. If it fails, a
* null handle pointer should be returned.
*
* @param fileName The string containing the name of the file
* @param manager The MemoryManager to use to allocate objects
* @return The file handle of the opened file
*/
static FileHandle openFile(const char* const fileName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Opens a named file
*
* This must be implemented by the per-platform driver, which should
* use local file services to open the passed file. If it fails, a
* null handle pointer should be returned.
*
* @param fileName The string containing the name of the file
* @param manager The MemoryManager to use to allocate objects
* @return The file handle of the opened file
*/
static FileHandle openFile(const XMLCh* const fileName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Open a named file to write
*
* This must be implemented by the per-platform driver, which should
* use local file services to open passed file. If it fails, a
* null handle pointer should be returned.
*
* @param fileName The string containing the name of the file
* @param manager The MemoryManager to use to allocate objects
* @return The file handle of the opened file
*/
static FileHandle openFileToWrite(const char* const fileName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Open a named file to write
*
* This must be implemented by the per-platform driver, which should
* use local file services to open the passed file. If it fails, a
* null handle pointer should be returned.
*
* @param fileName The string containing the name of the file
* @param manager The MemoryManager to use to allocate objects
* @return The file handle of the opened file
*/
static FileHandle openFileToWrite(const XMLCh* const fileName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Opens the standard input as a file
*
* This must be implemented by the per-platform driver, which should
* use local file services to open a handle to the standard input.
* It should be a copy of the standard input handle, since it will
* be closed later!
*
* @param manager The MemoryManager to use to allocate objects
* @return The file handle of the standard input stream
*/
static FileHandle openStdInHandle(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Reads the file buffer
*
* This must be implemented by the per-platform driver, which should
* use local file services to read up to 'toRead' bytes of data from
* the passed file, and return those bytes in the 'toFill' buffer. It
* is not an error not to read the requested number of bytes. When the
* end of file is reached, zero should be returned.
*
* @param theFile The file handle to be read from.
* @param toRead The maximum number of byte to read from the current
* position
* @param toFill The byte buffer to fill
* @param manager The MemoryManager to use to allocate objects
*
* @return Returns the number of bytes read from the stream or file
*/
static XMLSize_t readFileBuffer
(
FileHandle theFile
, const XMLSize_t toRead
, XMLByte* const toFill
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Writes the buffer to the file
*
* This must be implemented by the per-platform driver, which should
* use local file services to write up to 'toWrite' bytes of data to
* the passed file. Unless exception raised by local file services,
* 'toWrite' bytes of data is to be written to the passed file.
*
* @param theFile The file handle to be written to.
* @param toWrite The maximum number of byte to write from the current
* position
* @param toFlush The byte buffer to flush
* @param manager The MemoryManager to use to allocate objects
* @return void
*/
static void writeBufferToFile
(
FileHandle const theFile
, XMLSize_t toWrite
, const XMLByte* const toFlush
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Resets the file handle
*
* This must be implemented by the per-platform driver which will use
* local file services to reset the file position to the start of the
* the file.
*
* @param theFile The file handle that you want to reset
* @param manager The MemoryManager to use to allocate objects
*/
static void resetFile(FileHandle theFile
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@}
/** @name File System Methods */
//@{
/** Gets the full path from a relative path
*
* This must be implemented by the per-platform driver. It should
* complete a relative path using the 'current directory', or whatever
* the local equivalent of a current directory is. If the passed
* source path is actually fully qualified, then a straight copy of it
* will be returned.
*
* @param srcPath The path of the file for which you want the full path
*
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*
* @return Returns the fully qualified path of the file name including
* the file name. This is dyanmically allocated and must be
* deleted by the caller when its no longer needed! The memory
* returned will beallocated using the static memory manager, if
* user do not supply a memory manager. Users then need to make
* sure to use either the default or user specific memory manager
* to deallocate the memory.
*/
static XMLCh* getFullPath
(
const XMLCh* const srcPath
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Gets the current working directory
*
* This must be implemented by the per-platform driver. It returns
* the current working directory is.
* @param manager The MemoryManager to use to allocate objects
* @return Returns the current working directory.
* This is dyanmically allocated and must be deleted
* by the caller when its no longer needed! The memory returned
* will be allocated using the static memory manager, if users
* do not supply a memory manager. Users then need to make sure
* to use either the default or user specific memory manager to
* deallocate the memory.
*/
static XMLCh* getCurrentDirectory
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Check if a character is a slash
*
* This must be implemented by the per-platform driver.
*
* @param c the character to be examined
*
* @return true if the character examined is a slash
* false otherwise
*/
static inline bool isAnySlash(XMLCh c);
/** Remove occurrences of the pair of dot slash
*
* To remove the sequence, dot slash if it is part of the sequence,
* slash dot slash.
*
* @param srcPath The path for which you want to remove the dot slash sequence.
* @param manager The MemoryManager to use to allocate objects
* @return
*/
static void removeDotSlash(XMLCh* const srcPath
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Remove occurrences of the dot dot slash
*
* To remove the sequence, slash dot dot slash and its preceding path segment
* if and only if the preceding path segment is not slash dot dot slash.
*
* @param srcPath The path for which you want to remove the slash dot
* dot slash sequence and its preceding path segment.
* @param manager The MemoryManager to use to allocate objects
* @return
*/
static void removeDotDotSlash(XMLCh* const srcPath
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Determines if a path is relative or absolute
*
* This must be implemented by the per-platform driver, which should
* determine whether the passed path is relative or not. The concept
* of relative and absolute might be... well relative on different
* platforms. But, as long as the determination is made consistently
* and in coordination with the weavePaths() method, it should work
* for any platform.
*
* @param toCheck The file name which you want to check
* @param manager The MemoryManager to use to allocate objects
* @return Returns true if the filename appears to be relative
*/
static bool isRelative(const XMLCh* const toCheck
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Utility to join two paths
*
* This must be implemented by the per-platform driver, and should
* weave the relative path part together with the base part and return
* a new path that represents this combination.
*
* If the relative part turns out to be fully qualified, it will be
* returned as is. If it is not, then it will be woven onto the
* passed base path, by removing one path component for each leading
* "../" (or whatever is the equivalent in the local system) in the
* relative path.
*
* @param basePath The string containing the base path
* @param relativePath The string containing the relative path
* @param manager The MemoryManager to use to allocate objects
* @return Returns a string containing the 'woven' path. It should
* be dynamically allocated and becomes the responsibility of the
* caller to delete.
*/
static XMLCh* weavePaths
(
const XMLCh* const basePath
, const XMLCh* const relativePath
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/** @name Timing Methods */
//@{
/** Gets the system time in milliseconds
*
* This must be implemented by the per-platform driver, which should
* use local services to return the current value of a running
* millisecond timer. Note that the value returned is only as accurate
* as the millisecond time of the underlying host system.
*
* @return Returns the system time as an unsigned long
*/
static unsigned long getCurrentMillis();
//@}
/** @name Mutex Methods */
//@{
/** Factory method for creating MutexMgr object.
*
* This factory method creates a mutexmgr that will be used
* on the particular platform.
*
* @param manager The MemoryManager to use to allocate objects
*/
static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager);
/** Closes a mutex handle
*
* Each per-platform driver must implement this. Only it knows what
* the actual content of the passed mutex handle is.
*
* @param mtxHandle The mutex handle that you want to close
* @param manager The MemoryManager used to allocate the object
*/
static void closeMutex(void* const mtxHandle, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Locks a mutex handle
*
* Each per-platform driver must implement this. Only it knows what
* the actual content of the passed mutex handle is.
*
* @param mtxHandle The mutex handle that you want to lock
*/
static void lockMutex(void* const mtxHandle);
/** Make a new mutex
*
* Each per-platform driver must implement this. Only it knows what
* the actual content of the passed mutex handle is. The returned
* handle pointer will be eventually passed to closeMutex() which is
* also implemented by the platform driver.
*
* @param manager The MemoryManager to use to allocate objects
*/
static void* makeMutex(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Unlocks a mutex
*
* Each per-platform driver must implement this. Only it knows what
* the actual content of the passed mutex handle is.
*
* Note that, since the underlying system synchronization services
* are used, Xerces cannot guarantee that lock/unlock operations are
* correctly enforced on a per-thread basis or that incorrect nesting
* of lock/unlock operations will be caught.
*
* @param mtxHandle The mutex handle that you want to unlock
*/
static void unlockMutex(void* const mtxHandle);
//@}
/** @name External Message Support */
//@{
/** Loads the message set from among the available domains
*
* The returned object must be dynamically allocated and the caller
* becomes responsible for cleaning it up.
*
* @param msgDomain The message domain which you want to load
*/
static XMLMsgLoader* loadMsgSet(const XMLCh* const msgDomain);
//@}
/** @name NEL Character Handling */
//@{
/**
* This function enables the recognition of NEL(0x85) char and LSEP (0x2028) as newline chars
* which is disabled by default.
* It is only called once per process. Once it is set, any subsequent calls
* will result in exception being thrown.
*
* Note: 1. Turning this option on will make the parser non compliant to XML 1.0.
* 2. This option has no effect to document conforming to XML 1.1 compliant,
* which always recognize these two chars (0x85 and 0x2028) as newline characters.
*
*/
static void recognizeNEL(bool state
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Return the value of fgNEL flag.
*/
static bool isNELRecognized();
//@}
/** @name Strict IANA Encoding Checking */
//@{
/**
* This function enables/disables strict IANA encoding names checking.
*
* The strict checking is disabled by default.
*
* @param state If true, a strict IANA encoding name check is performed,
* otherwise, no checking.
*
*/
static void strictIANAEncoding(const bool state);
/**
* Returns whether a strict IANA encoding name check is enabled or
* disabled.
*/
static bool isStrictIANAEncoding();
//@}
/**
* Aligns the specified pointer per platform block allocation
* requirements.
*
* The results of this function may be altered by defining
* XML_PLATFORM_NEW_BLOCK_ALIGNMENT.
*/
static inline XMLSize_t alignPointerForNewBlockAllocation(XMLSize_t ptrSize);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLPlatformUtils();
/** @name Private static methods */
//@{
/** Loads a message set from the available domains
*
* @param msgDomain The message domain containing the message to be
* loaded
*/
static XMLMsgLoader* loadAMsgSet(const XMLCh* const msgDomain);
/** Creates a net accessor object.
*
* Each per-platform driver must implement this method. However,
* having a Net Accessor is optional and this method can return a
* null pointer if remote access via HTTP and FTP URLs is not required.
*
* @return An object derived from XMLNetAccessor. It must be dynamically
* allocated, since it will be deleted later.
*/
static XMLNetAccessor* makeNetAccessor();
/** Creates a Transcoding service
*
* Each per-platform driver must implement this method and return some
* derivative of the XMLTransService class. This object serves as the
* transcoder factory for this process. The object must be dynamically
* allocated and the caller is responsible for cleaning it up.
*
* @return A dynamically allocated object of some class derived from
* the XMLTransService class.
*/
static XMLTransService* makeTransService();
/** Search for sequence, slash dot dot slash
*
* @param srcPath the path to search
*
* @return the position of the first occurrence of slash dot dot slash
* -1 if no such sequence is found
*/
static int searchSlashDotDotSlash(XMLCh* const srcPath);
//@}
/** @name Private static methods */
//@{
/**
* Indicates whether the memory manager was supplied by the user
* or not. Users own the memory manager, and if none is supplied,
* Xerces uses a default one that it owns and is responsible for
* deleting in Terminate().
*/
static bool fgMemMgrAdopted;
//@}
};
MakeXMLException(XMLPlatformUtilsException, XMLUTIL_EXPORT)
// ---------------------------------------------------------------------------
// XMLPlatformUtils: alignPointerForNewBlockAllocation
// ---------------------------------------------------------------------------
// Calculate alignment required by platform for a new
// block allocation. We use this in our custom allocators
// to ensure that returned blocks are properly aligned.
// Note that, although this will take a pointer and return the position
// at which it should be placed for correct alignment, in our code
// we normally use XMLSize_t parameters to discover what the alignment
// of header blocks should be. Thus, if this is to be
// used for the former purpose, to make compilers happy
// some casting will be necessary - neilg.
//
// Note: XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be specified on a
// per-architecture basis to dictate the alignment requirements
// of the architecture. In the absense of this specification,
// this routine guesses at the correct alignment value.
//
// A XML_PLATFORM_NEW_BLOCK_ALIGNMENT value of zero is illegal.
// If a platform requires absolutely no alignment, a value
// of 1 should be specified ("align pointers on 1 byte boundaries").
//
inline XMLSize_t
XMLPlatformUtils::alignPointerForNewBlockAllocation(XMLSize_t ptrSize)
{
// Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined
// as needed to dictate alignment requirements on a
// per-architecture basis. In the absense of that we
// take an educated guess.
#ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT
static const XMLSize_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT;
#else
static const XMLSize_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double);
#endif
// Calculate current alignment of pointer
XMLSize_t current = ptrSize % alignment;
// Adjust pointer alignment as needed
return (current == 0)
? ptrSize
: (ptrSize + alignment - current);
}
// ---------------------------------------------------------------------------
// XMLDeleter: Public Destructor
// ---------------------------------------------------------------------------
inline XMLDeleter::~XMLDeleter()
{
}
// ---------------------------------------------------------------------------
// XMLDeleter: Hidden constructors and operators
// ---------------------------------------------------------------------------
inline XMLDeleter::XMLDeleter()
{
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,217 @@
/*
* 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: QName.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_QNAME_HPP)
#define XERCESC_INCLUDE_GUARD_QNAME_HPP
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT QName : public XSerializable, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
/** Default constructor. */
QName(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Constructs a specified qname using prefix, and localpart. */
QName
(
const XMLCh* const prefix
, const XMLCh* const localPart
, const unsigned int uriId
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Constructs a specified qname using rawName. */
QName
(
const XMLCh* const rawName
, const unsigned int uriId
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Copy constructor. */
QName(const QName& qname);
~QName();
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
const XMLCh* getPrefix() const;
XMLCh* getPrefix();
const XMLCh* getLocalPart() const;
XMLCh* getLocalPart();
unsigned int getURI() const;
const XMLCh* getRawName() const;
XMLCh* getRawName();
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Setters
// -----------------------------------------------------------------------
void setName
(
const XMLCh* const prefix
, const XMLCh* const localPart
, const unsigned int uriId
);
void setName
(
const XMLCh* const rawName
, const unsigned int uriId
);
void setPrefix(const XMLCh*) ;
void setLocalPart(const XMLCh*) ;
void setNPrefix(const XMLCh*, const XMLSize_t ) ;
void setNLocalPart(const XMLCh*, const XMLSize_t ) ;
void setURI(const unsigned int) ;
void setValues(const QName& qname);
// -----------------------------------------------------------------------
// comparison
// -----------------------------------------------------------------------
bool operator==(const QName&) const;
// -----------------------------------------------------------------------
// Misc
// -----------------------------------------------------------------------
void cleanUp();
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(QName)
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
QName& operator=(const QName&);
// -----------------------------------------------------------------------
// Private instance variables
//
// We copy the followings from XMLAttr.hpp, but stick to Java version's
// naming convention
//
// fPrefix
// fPrefixBufSz
// The prefix that was applied to this attribute's name, and the
// current size of the buffer (minus one for the null.) Prefixes
// really don't matter technically but it might be required for
// practical reasons, to recreate the original document for instance.
//
// fLocalPart
// fLocalPartBufSz
// The base part of the name of the attribute, and the current size
// of the buffer (minus one, where the null is.)
//
// fRawName
// fRawNameBufSz
// This is the QName form of the name, which is faulted in (from the
// prefix and name) upon request. The size field indicates the
// current size of the buffer (minus one for the null.) It will be
// zero until filled in.
//
// fURIId
// The id of the URI that this attribute belongs to.
// -----------------------------------------------------------------------
XMLSize_t fPrefixBufSz;
XMLSize_t fLocalPartBufSz;
XMLSize_t fRawNameBufSz;
unsigned int fURIId;
XMLCh* fPrefix;
XMLCh* fLocalPart;
XMLCh* fRawName;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// QName: Getter methods
// ---------------------------------------------------------------------------
inline const XMLCh* QName::getPrefix() const
{
return fPrefix;
}
inline XMLCh* QName::getPrefix()
{
return fPrefix;
}
inline const XMLCh* QName::getLocalPart() const
{
return fLocalPart;
}
inline XMLCh* QName::getLocalPart()
{
return fLocalPart;
}
inline unsigned int QName::getURI() const
{
return fURIId;
}
inline MemoryManager* QName::getMemoryManager() const
{
return fMemoryManager;
}
// ---------------------------------------------------------------------------
// QName: Setter methods
// ---------------------------------------------------------------------------
inline void QName::setURI(const unsigned int uriId)
{
fURIId = uriId;
}
inline void QName::setPrefix(const XMLCh* prefix)
{
setNPrefix(prefix, XMLString::stringLen(prefix));
}
inline void QName::setLocalPart(const XMLCh* localPart)
{
setNLocalPart(localPart, XMLString::stringLen(localPart));
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,150 @@
/*
* 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: RefArrayOf.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFARRAY_HPP)
#define XERCESC_INCLUDE_GUARD_REFARRAY_HPP
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/XMLEnumerator.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class TElem> class RefArrayOf : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefArrayOf
(
const XMLSize_t size
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefArrayOf
(
TElem* values[]
, const XMLSize_t size
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefArrayOf(const RefArrayOf<TElem>& source);
~RefArrayOf();
// -----------------------------------------------------------------------
// Public operators
// -----------------------------------------------------------------------
TElem*& operator[](const XMLSize_t index);
const TElem* operator[](const XMLSize_t index) const;
RefArrayOf<TElem>& operator=(const RefArrayOf<TElem>& toAssign);
bool operator==(const RefArrayOf<TElem>& toCompare) const;
bool operator!=(const RefArrayOf<TElem>& toCompare) const;
// -----------------------------------------------------------------------
// Copy operations
// -----------------------------------------------------------------------
XMLSize_t copyFrom(const RefArrayOf<TElem>& srcArray);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLSize_t length() const;
TElem** rawData() const;
// -----------------------------------------------------------------------
// Element management methods
// -----------------------------------------------------------------------
void deleteAt(const XMLSize_t index);
void deleteAllElements();
void resize(const XMLSize_t newSize);
private :
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
XMLSize_t fSize;
TElem** fArray;
MemoryManager* fMemoryManager;
};
//
// An enumerator for a reference array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TElem> class RefArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefArrayEnumerator
(
RefArrayOf<TElem>* const toEnum
, const bool adopt = false
);
virtual ~RefArrayEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefArrayEnumerator(const RefArrayEnumerator<TElem>&);
RefArrayEnumerator<TElem>& operator=(const RefArrayEnumerator<TElem>&);
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed array. If so then
// we delete it when we are destroyed.
//
// fCurIndex
// This is the current index into the array.
//
// fToEnum
// The reference array being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fCurIndex;
RefArrayOf<TElem>* fToEnum;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefArrayOf.c>
#endif
#endif

View File

@@ -0,0 +1,70 @@
/*
* 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: RefArrayVectorOf.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFARRAYVECTOROF_HPP)
#define XERCESC_INCLUDE_GUARD_REFARRAYVECTOROF_HPP
#include <xercesc/util/BaseRefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Class with implementation for vectors of pointers to arrays - implements from
* the Abstract class Vector
*/
template <class TElem> class RefArrayVectorOf : public BaseRefVectorOf<TElem>
{
public :
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
RefArrayVectorOf( const XMLSize_t maxElems
, const bool adoptElems = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// -----------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------
~RefArrayVectorOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
void setElementAt(TElem* const toSet, const XMLSize_t setAt);
void removeAllElements();
void removeElementAt(const XMLSize_t removeAt);
void removeLastElement();
void cleanup();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefArrayVectorOf(const RefArrayVectorOf<TElem>&);
RefArrayVectorOf<TElem>& operator=(const RefArrayVectorOf<TElem>&);
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefArrayVectorOf.c>
#endif
#endif

View File

@@ -0,0 +1,258 @@
/*
* 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: RefHash2KeysTableOf.hpp 883368 2009-11-23 15:28:19Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFHASH2KEYSTABLEOF_HPP)
#define XERCESC_INCLUDE_GUARD_REFHASH2KEYSTABLEOF_HPP
#include <xercesc/util/Hashers.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// This hash table is similar to RefHashTableOf with an additional integer as key2
// Forward declare the enumerator so it can be our friend.
//
template <class TVal, class THasher = StringHasher>
class RefHash2KeysTableOfEnumerator;
//
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
template <class TVal>
struct RefHash2KeysTableBucketElem
{
RefHash2KeysTableBucketElem(void* key1, int key2, TVal* const value, RefHash2KeysTableBucketElem<TVal>* next)
: fData(value), fNext(next), fKey1(key1), fKey2(key2)
{
}
~RefHash2KeysTableBucketElem() {};
TVal* fData;
RefHash2KeysTableBucketElem<TVal>* fNext;
void* fKey1;
int fKey2;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHash2KeysTableBucketElem(const RefHash2KeysTableBucketElem<TVal>&);
RefHash2KeysTableBucketElem<TVal>& operator=(const RefHash2KeysTableBucketElem<TVal>&);
};
template <class TVal, class THasher = StringHasher>
class RefHash2KeysTableOf : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefHash2KeysTableOf(
const XMLSize_t modulus,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHash2KeysTableOf(
const XMLSize_t modulus,
const THasher& hasher,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHash2KeysTableOf(
const XMLSize_t modulus,
const bool adoptElems,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHash2KeysTableOf(
const XMLSize_t modulus,
const bool adoptElems,
const THasher& hasher,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~RefHash2KeysTableOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool isEmpty() const;
bool containsKey(const void* const key1, const int key2) const;
void removeKey(const void* const key1, const int key2);
void removeKey(const void* const key1);
void removeAll();
void transferElement(const void* const key1, void* key2);
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
TVal* get(const void* const key1, const int key2);
const TVal* get(const void* const key1, const int key2) const;
MemoryManager* getMemoryManager() const;
XMLSize_t getHashModulus() const;
// -----------------------------------------------------------------------
// Putters
// -----------------------------------------------------------------------
void put(void* key1, int key2, TVal* const valueToAdopt);
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class RefHash2KeysTableOfEnumerator<TVal, THasher>;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHash2KeysTableOf(const RefHash2KeysTableOf<TVal, THasher>&);
RefHash2KeysTableOf<TVal>& operator=(const RefHash2KeysTableOf<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
RefHash2KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, XMLSize_t& hashVal);
const RefHash2KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, XMLSize_t& hashVal) const;
void initialize(const XMLSize_t modulus);
void rehash();
// -----------------------------------------------------------------------
// Data members
//
// fAdoptedElems
// Indicates whether the values added are adopted or just referenced.
// If adopted, then they are deleted when they are removed from the
// hash table.
//
// fBucketList
// This is the array that contains the heads of all of the list
// buckets, one for each possible hash value.
//
// fHashModulus
// The modulus used for this hash table, to hash the keys. This is
// also the number of elements in the bucket list.
//
// fCount
// The number of elements currently in the map
//
// fHash
// The hasher for the key1 data type.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
bool fAdoptedElems;
RefHash2KeysTableBucketElem<TVal>** fBucketList;
XMLSize_t fHashModulus;
XMLSize_t fCount;
THasher fHasher;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TVal, class THasher>
class RefHash2KeysTableOfEnumerator : public XMLEnumerator<TVal>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal, THasher>* const toEnum
, const bool adopt = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~RefHash2KeysTableOfEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TVal& nextElement();
void Reset();
// -----------------------------------------------------------------------
// New interface
// -----------------------------------------------------------------------
void nextElementKey(void*&, int&);
void setPrimaryKey(const void* key);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHash2KeysTableOfEnumerator(const RefHash2KeysTableOfEnumerator<TVal, THasher>&);
RefHash2KeysTableOfEnumerator<TVal, THasher>& operator=(const RefHash2KeysTableOfEnumerator<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void findNext();
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurElem
// This is the current bucket bucket element that we are on.
//
// fCurHash
// The is the current hash buck that we are working on. Once we hit
// the end of the bucket that fCurElem is in, then we have to start
// working this one up to the next non-empty bucket.
//
// fToEnum
// The value array being enumerated.
//
// fLockPrimaryKey
// Indicates that we are requested to iterate over the secondary keys
// associated with the given primary key
//
// -----------------------------------------------------------------------
bool fAdopted;
RefHash2KeysTableBucketElem<TVal>* fCurElem;
XMLSize_t fCurHash;
RefHash2KeysTableOf<TVal, THasher>* fToEnum;
MemoryManager* const fMemoryManager;
const void* fLockPrimaryKey;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefHash2KeysTableOf.c>
#endif
#endif

View File

@@ -0,0 +1,279 @@
/*
* 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: RefHash3KeysIdPool.hpp 883368 2009-11-23 15:28:19Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFHASH3KEYSIDPOOL_HPP)
#define XERCESC_INCLUDE_GUARD_REFHASH3KEYSIDPOOL_HPP
#include <xercesc/util/Hashers.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// This hash table is a combination of RefHash2KeyTableOf (with an additional integer as key3)
// and NameIdPool with an id as index
// Forward declare the enumerator so it can be our friend.
//
template <class TVal, class THasher = StringHasher>
class RefHash3KeysIdPoolEnumerator;
//
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
template <class TVal>
struct RefHash3KeysTableBucketElem
{
RefHash3KeysTableBucketElem(
void* key1
, int key2
, int key3
, TVal* const value
, RefHash3KeysTableBucketElem<TVal>* next) :
fData(value)
, fNext(next)
, fKey1(key1)
, fKey2(key2)
, fKey3(key3)
{
}
RefHash3KeysTableBucketElem() {};
~RefHash3KeysTableBucketElem() {};
TVal* fData;
RefHash3KeysTableBucketElem<TVal>* fNext;
void* fKey1;
int fKey2;
int fKey3;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHash3KeysTableBucketElem(const RefHash3KeysTableBucketElem<TVal>&);
RefHash3KeysTableBucketElem<TVal>& operator=(const RefHash3KeysTableBucketElem<TVal>&);
};
template <class TVal, class THasher = StringHasher>
class RefHash3KeysIdPool : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefHash3KeysIdPool(
const XMLSize_t modulus,
const XMLSize_t initSize = 128,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHash3KeysIdPool(
const XMLSize_t modulus,
const THasher& hasher,
const XMLSize_t initSize = 128,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHash3KeysIdPool(
const XMLSize_t modulus,
const bool adoptElems,
const XMLSize_t initSize = 128,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHash3KeysIdPool(
const XMLSize_t modulus,
const bool adoptElems,
const THasher& hasher,
const XMLSize_t initSize = 128,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~RefHash3KeysIdPool();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool isEmpty() const;
bool containsKey(const void* const key1, const int key2, const int key3) const;
void removeAll();
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
TVal* getByKey(const void* const key1, const int key2, const int key3);
const TVal* getByKey(const void* const key1, const int key2, const int key3) const;
TVal* getById(const unsigned int elemId);
const TVal* getById(const unsigned int elemId) const;
MemoryManager* getMemoryManager() const;
XMLSize_t getHashModulus() const;
// -----------------------------------------------------------------------
// Putters
// -----------------------------------------------------------------------
XMLSize_t put(void* key1, int key2, int key3, TVal* const valueToAdopt);
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class RefHash3KeysIdPoolEnumerator<TVal, THasher>;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHash3KeysIdPool(const RefHash3KeysIdPool<TVal, THasher>&);
RefHash3KeysIdPool<TVal, THasher>& operator=(const RefHash3KeysIdPool<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
RefHash3KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, const int key3, XMLSize_t& hashVal);
const RefHash3KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, const int key3, XMLSize_t& hashVal) const;
void initialize(const XMLSize_t modulus);
// -----------------------------------------------------------------------
// Data members
//
// fAdoptedElems
// Indicates whether the values added are adopted or just referenced.
// If adopted, then they are deleted when they are removed from the
// hash table.
//
// fBucketList
// This is the array that contains the heads of all of the list
// buckets, one for each possible hash value.
//
// fHashModulus
// The modulus used for this hash table, to hash the keys. This is
// also the number of elements in the bucket list.
//
// fHash
// The hasher for the key1 data type.
//
// fIdPtrs
// fIdPtrsCount
// This is the array of pointers to the bucket elements in order of
// their assigned ids. So taking id N and referencing this array
// gives you the element with that id. The count field indicates
// the current size of this list. When fIdCounter+1 reaches this
// value the list must be expanded.
//
// fIdCounter
// This is used to give out unique ids to added elements. It starts
// at zero (which means empty), and is bumped up for each newly added
// element. So the first element is 1, the next is 2, etc... This
// means that this value is set to the top index of the fIdPtrs array.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
bool fAdoptedElems;
RefHash3KeysTableBucketElem<TVal>** fBucketList;
XMLSize_t fHashModulus;
TVal** fIdPtrs;
XMLSize_t fIdPtrsCount;
XMLSize_t fIdCounter;
THasher fHasher;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TVal, class THasher>
class RefHash3KeysIdPoolEnumerator : public XMLEnumerator<TVal>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal, THasher>* const toEnum
, const bool adopt = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~RefHash3KeysIdPoolEnumerator();
RefHash3KeysIdPoolEnumerator(const RefHash3KeysIdPoolEnumerator<TVal, THasher>&);
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TVal& nextElement();
void Reset();
XMLSize_t size() const;
// -----------------------------------------------------------------------
// New interface
// -----------------------------------------------------------------------
void resetKey();
void nextElementKey(void*&, int&, int&);
bool hasMoreKeys() const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHash3KeysIdPoolEnumerator<TVal, THasher>&
operator=(const RefHash3KeysIdPoolEnumerator<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void findNext();
// -----------------------------------------------------------------------
// Data Members
// fAdoptedElems
// Indicates whether the values added are adopted or just referenced.
// If adopted, then they are deleted when they are removed from the
// hash table
//
// fCurIndex
// This is the current index into the pool's id mapping array. This
// is now we enumerate it.
//
// fToEnum
// The name id pool that is being enumerated.
// -----------------------------------------------------------------------
bool fAdoptedElems;
XMLSize_t fCurIndex;
RefHash3KeysIdPool<TVal, THasher>* fToEnum;
RefHash3KeysTableBucketElem<TVal>* fCurElem;
XMLSize_t fCurHash;
MemoryManager* const fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefHash3KeysIdPool.c>
#endif
#endif

View File

@@ -0,0 +1,255 @@
/*
* 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: RefHashTableOf.hpp 679340 2008-07-24 10:28:29Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFHASHTABLEOF_HPP)
#define XERCESC_INCLUDE_GUARD_REFHASHTABLEOF_HPP
#include <xercesc/util/Hashers.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// Forward declare the enumerator so it can be our friend.
//
template <class TVal, class THasher = StringHasher>
class RefHashTableOfEnumerator;
//
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
template <class TVal>
struct RefHashTableBucketElem
{
RefHashTableBucketElem(void* key, TVal* const value, RefHashTableBucketElem<TVal>* next)
: fData(value), fNext(next), fKey(key)
{
}
RefHashTableBucketElem(){};
~RefHashTableBucketElem(){};
TVal* fData;
RefHashTableBucketElem<TVal>* fNext;
void* fKey;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHashTableBucketElem(const RefHashTableBucketElem<TVal>&);
RefHashTableBucketElem<TVal>& operator=(const RefHashTableBucketElem<TVal>&);
};
template <class TVal, class THasher = StringHasher>
class RefHashTableOf : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefHashTableOf(
const XMLSize_t modulus,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHashTableOf(
const XMLSize_t modulus,
const THasher& hasher,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHashTableOf(
const XMLSize_t modulus,
const bool adoptElems,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
RefHashTableOf(
const XMLSize_t modulus,
const bool adoptElems,
const THasher& hasher,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~RefHashTableOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool isEmpty() const;
bool containsKey(const void* const key) const;
void removeKey(const void* const key);
void removeAll();
void cleanup();
void reinitialize(const THasher& hasher);
void transferElement(const void* const key1, void* key2);
TVal* orphanKey(const void* const key);
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
TVal* get(const void* const key);
const TVal* get(const void* const key) const;
MemoryManager* getMemoryManager() const;
XMLSize_t getHashModulus() const;
XMLSize_t getCount() const;
// -----------------------------------------------------------------------
// Setters
// -----------------------------------------------------------------------
void setAdoptElements(const bool aValue);
// -----------------------------------------------------------------------
// Putters
// -----------------------------------------------------------------------
void put(void* key, TVal* const valueToAdopt);
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class RefHashTableOfEnumerator<TVal, THasher>;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHashTableOf(const RefHashTableOf<TVal, THasher>&);
RefHashTableOf<TVal, THasher>& operator=(const RefHashTableOf<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
RefHashTableBucketElem<TVal>* findBucketElem(const void* const key, XMLSize_t& hashVal);
const RefHashTableBucketElem<TVal>* findBucketElem(const void* const key, XMLSize_t& hashVal) const;
void initialize(const XMLSize_t modulus);
void rehash();
// -----------------------------------------------------------------------
// Data members
//
// fAdoptedElems
// Indicates whether the values added are adopted or just referenced.
// If adopted, then they are deleted when they are removed from the
// hash table.
//
// fBucketList
// This is the array that contains the heads of all of the list
// buckets, one for each possible hash value.
//
// fHashModulus
// The modulus used for this hash table, to hash the keys. This is
// also the number of elements in the bucket list.
//
// fHash
// The hasher for the key data type.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
bool fAdoptedElems;
RefHashTableBucketElem<TVal>** fBucketList;
XMLSize_t fHashModulus;
XMLSize_t fInitialModulus;
XMLSize_t fCount;
THasher fHasher;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TVal, class THasher>
class RefHashTableOfEnumerator : public XMLEnumerator<TVal>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefHashTableOfEnumerator(RefHashTableOf<TVal, THasher>* const toEnum
, const bool adopt = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~RefHashTableOfEnumerator();
RefHashTableOfEnumerator(const RefHashTableOfEnumerator<TVal, THasher>&);
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TVal& nextElement();
void Reset();
// -----------------------------------------------------------------------
// New interface specific for key used in RefHashable
// -----------------------------------------------------------------------
void* nextElementKey();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefHashTableOfEnumerator<TVal, THasher>&
operator=(const RefHashTableOfEnumerator<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void findNext();
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurElem
// This is the current bucket bucket element that we are on.
//
// fCurHash
// The current hash buck that we are working on. Once we hit the
// end of the bucket that fCurElem is in, then we have to start
// working this one up to the next non-empty bucket.
//
// fToEnum
// The value array being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
RefHashTableBucketElem<TVal>* fCurElem;
XMLSize_t fCurHash;
RefHashTableOf<TVal, THasher>* fToEnum;
MemoryManager* const fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefHashTableOf.c>
#endif
#endif

View File

@@ -0,0 +1,152 @@
/*
* 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: RefStackOf.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFSTACKOF_HPP)
#define XERCESC_INCLUDE_GUARD_REFSTACKOF_HPP
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/EmptyStackException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// Forward declare the enumerator so he can be our friend. Can you say
// friend? Sure...
//
template <class TElem> class RefStackEnumerator;
template <class TElem> class RefStackOf : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefStackOf(const XMLSize_t initElems,
const bool adoptElems = true,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~RefStackOf();
// -----------------------------------------------------------------------
// Element management methods
// -----------------------------------------------------------------------
const TElem* elementAt(const XMLSize_t index) const;
TElem* popAt(const XMLSize_t index);
void push(TElem* const toPush);
const TElem* peek() const;
TElem* pop();
void removeAllElements();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool empty();
XMLSize_t curCapacity();
XMLSize_t size();
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class RefStackEnumerator<TElem>;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefStackOf(const RefStackOf<TElem>&);
RefStackOf<TElem>& operator=(const RefStackOf<TElem>&);
// -----------------------------------------------------------------------
// Data Members
//
// fVector
// The vector that is used as the backing data structure for the
// stack.
// -----------------------------------------------------------------------
RefVectorOf<TElem> fVector;
};
//
// An enumerator for a value stack. It derives from the basic enumerator
// class, so that value stacks can be generically enumerated.
//
template <class TElem> class RefStackEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
RefStackEnumerator
(
RefStackOf<TElem>* const toEnum
, const bool adopt = false
);
virtual ~RefStackEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefStackEnumerator(const RefStackEnumerator<TElem>&);
RefStackEnumerator<TElem>& operator=(const RefStackEnumerator<TElem>&);
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed stack. If so then
// we delete the stack when we are destroyed.
//
// fCurIndex
// This is the current index into the vector inside the stack being
// enumerated.
//
// fToEnum
// The stack that is being enumerated. This is just kept for
// adoption purposes, since we really are enumerating the vector
// inside of it.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fCurIndex;
RefVectorOf<TElem>* fVector;
RefStackOf<TElem>* fToEnum;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefStackOf.c>
#endif
#endif

View File

@@ -0,0 +1,62 @@
/*
* 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: RefVectorOf.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_REFVECTOROF_HPP)
#define XERCESC_INCLUDE_GUARD_REFVECTOROF_HPP
#include <xercesc/util/BaseRefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Class with implementation for vectors of References - implements from the
* Abstract class Vector
*/
template <class TElem> class RefVectorOf : public BaseRefVectorOf<TElem>
{
public :
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
RefVectorOf(const XMLSize_t maxElems,
const bool adoptElems = true,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// -----------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------
~RefVectorOf();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RefVectorOf(const RefVectorOf<TElem>&);
RefVectorOf<TElem>& operator=(const RefVectorOf<TElem>&);
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/RefVectorOf.c>
#endif
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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: RuntimeException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_RUNTIMEEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_RUNTIMEEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(RuntimeException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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: SchemaDateTimeException.hpp 471747 2006-11-06 14:31:56Z amassari $
*/
#if !defined(SCHEMA_DATETIME_EXCEPTION_HPP)
#define SCHEMA_DATETIME_EXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(SchemaDateTimeException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,116 @@
/*
* 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: SecurityManager.hpp 673960 2008-07-04 08:50:12Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SECURITYMANAGER_HPP)
#define XERCESC_INCLUDE_GUARD_SECURITYMANAGER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Allow application to force the parser to behave in a security-conscious
* way.
*
* <p> There are cases in which an XML- or XmL-schema-
* conformant processor can be presented with documents the
* processing of which can involve the consumption of
* prohibitive amounts of system resources. Applications can
* attach instances of this class to parsers that they've
* created, via the
* http://apache.org/xml/properties/security-manager property.
* </p>
*
* <p> Defaults will be provided for all known security holes.
* Setter methods will be provided on this class to ensure that
* an application can customize each limit as it chooses.
* Components that are vulnerable to any given hole need to be
* written to act appropriately when an instance of this class
* has been set on the calling parser.
* </p>
*/
class XMLUTIL_EXPORT SecurityManager
{
public:
enum { ENTITY_EXPANSION_LIMIT = 50000};
/** @name default Constructors */
//@{
/** Default constructor */
SecurityManager()
: fEntityExpansionLimit((XMLSize_t)ENTITY_EXPANSION_LIMIT)
{
}
/** Destructor */
virtual ~SecurityManager(){};
//@}
/** @name The Security Manager */
//@{
/**
* An application should call this method when it wishes to specify a particular
* limit to the number of entity expansions the parser will permit in a
* particular document. The default behaviour should allow the parser
* to validate nearly all XML non-malicious XML documents; if an
* application knows that it is operating in a domain where entities are
* uncommon, for instance, it may wish to provide a limit lower than the
* parser's default.
*
* @param newLimit the new entity expansion limit
*
*/
virtual void setEntityExpansionLimit(XMLSize_t newLimit)
{
fEntityExpansionLimit = newLimit;
}
/**
* Permits the application or a parser component to query the current
* limit for entity expansions.
*
* @return the current setting of the entity expansion limit
*
*/
virtual XMLSize_t getEntityExpansionLimit() const
{
return fEntityExpansionLimit;
}
//@}
protected:
XMLSize_t fEntityExpansionLimit;
private:
/* Unimplemented Constructors and operators */
/* Copy constructor */
SecurityManager(const SecurityManager&);
/** Assignment operator */
SecurityManager& operator=(const SecurityManager&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,175 @@
/*
* 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: StringPool.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_STRINGPOOL_HPP)
#define XERCESC_INCLUDE_GUARD_STRINGPOOL_HPP
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class implements a string pool, in which strings can be added and
// given a unique id by which they can be referred. It has to provide fast
// access both mapping from a string to its id and mapping from an id to
// its string. This requires that it provide two separate data structures.
// The map one is a hash table for quick storage and look up by name. The
// other is an array ordered by unique id which maps to the element in the
// hash table.
//
// This works because strings cannot be removed from the pool once added,
// other than flushing it completely, and because ids are assigned
// sequentially from 1.
//
class XMLUTIL_EXPORT XMLStringPool : public XSerializable, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLStringPool
(
const unsigned int modulus = 109
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLStringPool();
// -----------------------------------------------------------------------
// Pool management methods
// -----------------------------------------------------------------------
virtual unsigned int addOrFind(const XMLCh* const newString);
virtual bool exists(const XMLCh* const newString) const;
virtual bool exists(const unsigned int id) const;
virtual void flushAll();
virtual unsigned int getId(const XMLCh* const toFind) const;
virtual const XMLCh* getValueForId(const unsigned int id) const;
virtual unsigned int getStringCount() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLStringPool)
XMLStringPool(MemoryManager* const manager);
private :
// -----------------------------------------------------------------------
// Private data types
// -----------------------------------------------------------------------
struct PoolElem
{
unsigned int fId;
XMLCh* fString;
};
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLStringPool(const XMLStringPool&);
XMLStringPool& operator=(const XMLStringPool&);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
unsigned int addNewEntry(const XMLCh* const newString);
// -----------------------------------------------------------------------
// Private data members
//
// fIdMap
// This is an array of pointers to the pool elements. It is ordered
// by unique id, so using an id to index it gives instant access to
// the string of that id. This is grown as required.
//
// fHashTable
// This is the hash table used to store and quickly access the
// strings.
//
// fMapCapacity
// The current capacity of the id map. When the current id hits this
// value the map must must be expanded.
//
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
PoolElem** fIdMap;
RefHashTableOf<PoolElem>* fHashTable;
unsigned int fMapCapacity;
protected:
// protected data members
// fCurId
// This is the counter used to assign unique ids. It is just bumped
// up one for each new string added.
unsigned int fCurId;
};
// Provide inline versions of some of the simple functions to improve performance.
inline unsigned int XMLStringPool::addOrFind(const XMLCh* const newString)
{
PoolElem* elemToFind = fHashTable->get(newString);
if (elemToFind)
return elemToFind->fId;
return addNewEntry(newString);
}
inline unsigned int XMLStringPool::getId(const XMLCh* const toFind) const
{
PoolElem* elemToFind = fHashTable->get(toFind);
if (elemToFind)
return elemToFind->fId;
// Not found, so return zero, which is never a legal id
return 0;
}
inline bool XMLStringPool::exists(const XMLCh* const newString) const
{
return fHashTable->containsKey(newString);
}
inline bool XMLStringPool::exists(const unsigned int id) const
{
return (id > 0 && (id < fCurId));
}
inline const XMLCh* XMLStringPool::getValueForId(const unsigned int id) const
{
if (!id || (id >= fCurId))
ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::StrPool_IllegalId, fMemoryManager);
// Just index the id map and return that element's string
return fIdMap[id]->fString;
}
inline unsigned int XMLStringPool::getStringCount() const
{
return fCurId-1;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,86 @@
/*
* 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: SynchronizedStringPool.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP)
#define XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP
#include <xercesc/framework/MemoryManager.hpp>
#include <xercesc/util/StringPool.hpp>
#include <xercesc/util/Mutexes.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides a synchronized string pool implementation.
// This will necessarily be slower than the regular XMLStringPool, so it
// should only be used when updates need to be made in a thread-safe
// way. Updates will be made on datastructures local to this object;
// all queries that don't involve mutation will first be directed at
// the XMLStringPool implementation with which this object is
// constructed.
class XMLUTIL_EXPORT XMLSynchronizedStringPool : public XMLStringPool
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLSynchronizedStringPool
(
const XMLStringPool * constPool
, const unsigned int modulus = 109
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLSynchronizedStringPool();
// -----------------------------------------------------------------------
// Pool management methods
// -----------------------------------------------------------------------
virtual unsigned int addOrFind(const XMLCh* const newString);
virtual bool exists(const XMLCh* const newString) const;
virtual bool exists(const unsigned int id) const;
virtual void flushAll();
virtual unsigned int getId(const XMLCh* const toFind) const;
virtual const XMLCh* getValueForId(const unsigned int id) const;
virtual unsigned int getStringCount() const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLSynchronizedStringPool(const XMLSynchronizedStringPool&);
XMLSynchronizedStringPool& operator=(const XMLSynchronizedStringPool&);
// -----------------------------------------------------------------------
// private data members
// fConstPool
// the pool whose immutability we're protecting
// fMutex
// mutex to permit synchronous updates of our StringPool
const XMLStringPool* fConstPool;
XMLMutex fMutex;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,166 @@
/*
* 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: TransENameMap.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_TRANSENAMEMAP_HPP)
#define XERCESC_INCLUDE_GUARD_TRANSENAMEMAP_HPP
#include <xercesc/util/TransService.hpp>
#include <xercesc/util/XMLString.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class is really private to the TransService class. However, some
// compilers are too dumb to allow us to hide this class there in the Cpp
// file that uses it.
//
class ENameMap : public XMemory
{
public :
// -----------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------
virtual ~ENameMap()
{
//delete [] fEncodingName;
XMLPlatformUtils::fgMemoryManager->deallocate(fEncodingName);
}
// -----------------------------------------------------------------------
// Virtual factory method
// -----------------------------------------------------------------------
virtual XMLTranscoder* makeNew
(
const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const = 0;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const XMLCh* getKey() const
{
return fEncodingName;
}
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
ENameMap(const XMLCh* const encodingName) :
fEncodingName(XMLString::replicate(encodingName, XMLPlatformUtils::fgMemoryManager))
{
}
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ENameMap();
ENameMap(const ENameMap&);
ENameMap& operator=(const ENameMap&);
// -----------------------------------------------------------------------
// Private data members
//
// fEncodingName
// This is the encoding name for the transcoder that is controlled
// by this map instance.
// -----------------------------------------------------------------------
XMLCh* fEncodingName;
};
template <class TType> class ENameMapFor : public ENameMap
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ENameMapFor(const XMLCh* const encodingName);
~ENameMapFor();
// -----------------------------------------------------------------------
// Implementation of virtual factory method
// -----------------------------------------------------------------------
virtual XMLTranscoder* makeNew(const XMLSize_t blockSize,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ENameMapFor();
ENameMapFor(const ENameMapFor<TType>&);
ENameMapFor<TType>& operator=(const ENameMapFor<TType>&);
};
template <class TType> class EEndianNameMapFor : public ENameMap
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
EEndianNameMapFor(const XMLCh* const encodingName, const bool swapped);
~EEndianNameMapFor();
// -----------------------------------------------------------------------
// Implementation of virtual factory method
// -----------------------------------------------------------------------
virtual XMLTranscoder* makeNew(const XMLSize_t blockSize,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
EEndianNameMapFor(const EEndianNameMapFor<TType>&);
EEndianNameMapFor<TType>& operator=(const EEndianNameMapFor<TType>&);
// -----------------------------------------------------------------------
// Private data members
//
// fSwapped
// Indicates whether the endianness of the encoding is opposite of
// that of the local host.
// -----------------------------------------------------------------------
bool fSwapped;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/TransENameMap.c>
#endif
#endif

View File

@@ -0,0 +1,708 @@
/*
* 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: TransService.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_TRANSSERVICE_HPP)
#define XERCESC_INCLUDE_GUARD_TRANSSERVICE_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/XMLRecognizer.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// Forward references
//class XMLPlatformUtils;
class XMLLCPTranscoder;
class XMLTranscoder;
class ENameMap;
//
// This class is an abstract base class which are used to abstract the
// transcoding services that Xerces uses. The parser's actual transcoding
// needs are small so it is desirable to allow different implementations
// to be provided.
//
// The transcoding service has to provide a couple of required string
// and character operations, but its most important service is the creation
// of transcoder objects. There are two types of transcoders, which are
// discussed below in the XMLTranscoder class' description.
//
class XMLUTIL_EXPORT XMLTransService : public XMemory
{
public :
// -----------------------------------------------------------------------
// Class specific types
// -----------------------------------------------------------------------
enum Codes
{
Ok
, UnsupportedEncoding
, InternalFailure
, SupportFilesNotFound
};
struct TransRec
{
XMLCh intCh;
XMLByte extCh;
};
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
virtual ~XMLTransService();
// -----------------------------------------------------------------------
// Non-virtual API
// -----------------------------------------------------------------------
XMLTranscoder* makeNewTranscoderFor
(
const XMLCh* const encodingName
, XMLTransService::Codes& resValue
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLTranscoder* makeNewTranscoderFor
(
const char* const encodingName
, XMLTransService::Codes& resValue
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLTranscoder* makeNewTranscoderFor
(
XMLRecognizer::Encodings encodingEnum
, XMLTransService::Codes& resValue
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// The virtual transcoding service API
// -----------------------------------------------------------------------
virtual int compareIString
(
const XMLCh* const comp1
, const XMLCh* const comp2
) = 0;
virtual int compareNIString
(
const XMLCh* const comp1
, const XMLCh* const comp2
, const XMLSize_t maxChars
) = 0;
virtual const XMLCh* getId() const = 0;
// -----------------------------------------------------------------------
// Create a new transcoder for the local code page.
//
// @param manager The memory manager to use.
// -----------------------------------------------------------------------
virtual XMLLCPTranscoder* makeNewLCPTranscoder(MemoryManager* manager) = 0;
virtual bool supportsSrcOfs() const = 0;
virtual void upperCase(XMLCh* const toUpperCase) = 0;
virtual void lowerCase(XMLCh* const toLowerCase) = 0;
// -----------------------------------------------------------------------
// Allow users to add their own encodings to the intrinsic mapping
// table
// Usage:
// XMLTransService::addEncoding (
// gMyEncodingNameString
// , new ENameMapFor<MyTransClassType>(gMyEncodingNameString)
// );
// -----------------------------------------------------------------------
static void addEncoding(const XMLCh* const encoding, ENameMap* const ownMapping);
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLTransService();
// -----------------------------------------------------------------------
// Protected virtual methods.
// -----------------------------------------------------------------------
#ifdef OS390
friend class Uniconv390TransService;
#endif
virtual XMLTranscoder* makeNewXMLTranscoder
(
const XMLCh* const encodingName
, XMLTransService::Codes& resValue
, const XMLSize_t blockSize
, MemoryManager* const manager
) = 0;
// -----------------------------------------------------------------------
// Protected init method for platform utils to call
// -----------------------------------------------------------------------
friend class XMLPlatformUtils;
virtual void initTransService();
// -----------------------------------------------------------------------
// protected static members
// gMappings
// This is a hash table of ENameMap objects. It is created and filled
// in when the platform init calls our initTransService() method.
//
// gMappingsRecognizer
// This is an array of ENameMap objects, predefined for those
// already recognized by XMLRecognizer::Encodings.
//
static RefHashTableOf<ENameMap>* gMappings;
static RefVectorOf<ENameMap>* gMappingsRecognizer;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLTransService(const XMLTransService&);
XMLTransService& operator=(const XMLTransService&);
// -----------------------------------------------------------------------
// Hidden method to enable/disable strict IANA encoding check
// Caller: XMLPlatformUtils
// -----------------------------------------------------------------------
void strictIANAEncoding(const bool newState);
bool isStrictIANAEncoding();
friend class XMLInitializer;
};
/**
* <code>XMLTranscoder</code> is for transcoding non-local code
* page encodings, i.e. named encodings. These are used internally
* by the scanner to internalize raw XML into the internal Unicode
* format, and by writer classes to convert that internal Unicode
* format (which comes out of the parser) back out to a format that
* the receiving client code wants to use.
*/
class XMLUTIL_EXPORT XMLTranscoder : public XMemory
{
public :
/**
* This enum is used by the <code>transcodeTo()</code> method
* to indicate how to react to unrepresentable characters. The
* <code>transcodeFrom()</code> method always works the
* same. It will consider any invalid data to be an error and
* throw.
*/
enum UnRepOpts
{
UnRep_Throw /**< Throw an exception */
, UnRep_RepChar /**< Use the replacement char */
};
/** @name Destructor. */
//@{
/**
* Destructor for XMLTranscoder
*
*/
virtual ~XMLTranscoder();
//@}
/** @name The virtual transcoding interface */
//@{
/** Converts from the encoding of the service to the internal XMLCh* encoding
*
* @param srcData the source buffer to be transcoded
* @param srcCount number of bytes in the source buffer
* @param toFill the destination buffer
* @param maxChars the max number of characters in the destination buffer
* @param bytesEaten after transcoding, this will hold the number of bytes
* that were processed from the source buffer
* @param charSizes an array which must be at least as big as maxChars
* into which will be inserted values that indicate how many
* bytes from the input went into each XMLCh that was created
* into toFill. Since many encodings use variable numbers of
* byte per character, this provides a means to find out what
* bytes in the input went into making a particular output
* UTF-16 character.
* @return Returns the number of chars put into the target buffer
*/
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
) = 0;
/** Converts from the internal XMLCh* encoding to the encoding of the service
*
* @param srcData the source buffer to be transcoded
* @param srcCount number of characters in the source buffer
* @param toFill the destination buffer
* @param maxBytes the max number of bytes in the destination buffer
* @param charsEaten after transcoding, this will hold the number of chars
* that were processed from the source buffer
* @param options options to pass to the transcoder that explain how to
* respond to an unrepresentable character
* @return Returns the number of chars put into the target buffer
*/
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
) = 0;
/** Query whether the transcoder can handle a given character
*
* @param toCheck the character code point to check
*/
virtual bool canTranscodeTo
(
const unsigned int toCheck
) = 0;
//@}
/** @name Getter methods */
//@{
/** Get the internal block size
*
* @return The block size indicated in the constructor.
*/
XMLSize_t getBlockSize() const;
/** Get the encoding name
*
* @return the name of the encoding that this
* <code>XMLTranscoder</code> object is for
*/
const XMLCh* getEncodingName() const;
//@}
/** @name Getter methods*/
//@{
/** Get the plugged-in memory manager
*
* This method returns the plugged-in memory manager user for dynamic
* memory allocation/deallocation.
*
* @return the plugged-in memory manager
*/
MemoryManager* getMemoryManager() const;
//@}
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLTranscoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Protected helper methods
// -----------------------------------------------------------------------
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLTranscoder(const XMLTranscoder&);
XMLTranscoder& operator=(const XMLTranscoder&);
// -----------------------------------------------------------------------
// Private data members
//
// fBlockSize
// This is the block size indicated in the constructor.
//
// fEncodingName
// This is the name of the encoding this encoder is for. All basic
// XML transcoder's are for named encodings.
// -----------------------------------------------------------------------
XMLSize_t fBlockSize;
XMLCh* fEncodingName;
MemoryManager* fMemoryManager;
};
//
// This class is a specialized transcoder that only transcodes between
// the internal XMLCh format and the local code page. It is specialized
// for the very common job of translating data from the client app's
// native code page to the internal format and vice versa.
//
class XMLUTIL_EXPORT XMLLCPTranscoder : public XMemory
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
virtual ~XMLLCPTranscoder();
// -----------------------------------------------------------------------
// The virtual transcoder API
//
// NOTE: All these APIs don't include null terminator characters in
// their parameters. So calcRequiredSize() returns the number
// of actual chars, not including the null. maxBytes and maxChars
// parameters refer to actual chars, not including the null so
// its assumed that the buffer is physically one char or byte
// larger.
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// The 'normal' way to transcode a XMLCh-string from/to local string
// representation
//
// NOTE: Both methods return a string allocated via the MemoryManager.
// It is the responsibility of the calling environment to
// release this string after use.
// -----------------------------------------------------------------------
virtual char* transcode(const XMLCh* const toTranscode,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
virtual XMLCh* transcode(const char* const toTranscode,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
// -----------------------------------------------------------------------
// DEPRECATED old transcode interface
// -----------------------------------------------------------------------
virtual XMLSize_t calcRequiredSize(const char* const srcText
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
virtual XMLSize_t calcRequiredSize(const XMLCh* const srcText
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
virtual bool transcode
(
const char* const toTranscode
, XMLCh* const toFill
, const XMLSize_t maxChars
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) = 0;
virtual bool transcode
(
const XMLCh* const toTranscode
, char* const toFill
, const XMLSize_t maxBytes
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) = 0;
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLLCPTranscoder();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLLCPTranscoder(const XMLLCPTranscoder&);
XMLLCPTranscoder& operator=(const XMLLCPTranscoder&);
};
//
// This class can be used to transcode to a target encoding. It manages the
// memory allocated for the transcode in an exception safe manner, automatically
// deleting it when the class goes out of scope.
//
class XMLUTIL_EXPORT TranscodeToStr
{
public:
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
/** Converts from the internal XMLCh* encoding to the specified encoding
*
* @param in the null terminated source buffer to be transcoded
* @param encoding the name of the encoding to transcode to
* @param manager the memory manager to use
*/
TranscodeToStr(const XMLCh *in, const char *encoding,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager);
/** Converts from the internal XMLCh* encoding to the specified encoding
*
* @param in the source buffer to be transcoded
* @param length the length of the source buffer
* @param encoding the name of the encoding to transcode to
* @param manager the memory manager to use
*/
TranscodeToStr(const XMLCh *in, XMLSize_t length, const char *encoding,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager);
/** Converts from the internal XMLCh* encoding to the specified encoding
*
* @param in the null terminated source buffer to be transcoded
* @param trans the transcoder to use
* @param manager the memory manager to use
*/
TranscodeToStr(const XMLCh *in, XMLTranscoder* trans,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager);
/** Converts from the internal XMLCh* encoding to the specified encoding
*
* @param in the source buffer to be transcoded
* @param length the length of the source buffer
* @param trans the transcoder to use
* @param manager the memory manager to use
*/
TranscodeToStr(const XMLCh *in, XMLSize_t length, XMLTranscoder* trans,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager);
~TranscodeToStr();
/** @name Getter methods */
//@{
/** Returns the transcoded, null terminated string
* @return the transcoded string
*/
const XMLByte *str() const;
/** Returns the transcoded, null terminated string - adopting
* the memory allocated to it from the TranscodeToStr object
* @return the transcoded string
*/
XMLByte *adopt();
/** Returns the length of the transcoded string in bytes. The length
* does not include the null terminator.
* @return the length of the transcoded string in bytes
*/
XMLSize_t length () const;
//@}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
TranscodeToStr(const TranscodeToStr &);
TranscodeToStr &operator=(const TranscodeToStr &);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void transcode(const XMLCh *in, XMLSize_t len, XMLTranscoder* trans);
// -----------------------------------------------------------------------
// Private data members
//
// fString
// The transcoded string
//
// fBytesWritten
// The length of the transcoded string in bytes
// -----------------------------------------------------------------------
XMLByte *fString;
XMLSize_t fBytesWritten;
MemoryManager *fMemoryManager;
};
//
// This class can be used to transcode from a source encoding. It manages the
// memory allocated for the transcode in an exception safe manner, automatically
// deleting it when the class goes out of scope.
//
class XMLUTIL_EXPORT TranscodeFromStr
{
public:
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
/** Converts from the specified encoding to the internal XMLCh* encoding
*
* @param data the source buffer to be transcoded
* @param length the length of the source buffer
* @param encoding the name of the encoding to transcode to
* @param manager the memory manager to use
*/
TranscodeFromStr(const XMLByte *data, XMLSize_t length, const char *encoding,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager);
/** Converts from the specified encoding to the internal XMLCh* encoding
*
* @param data the source buffer to be transcoded
* @param length the length of the source buffer
* @param trans the transcoder to use
* @param manager the memory manager to use
*/
TranscodeFromStr(const XMLByte *data, XMLSize_t length, XMLTranscoder *trans,
MemoryManager *manager = XMLPlatformUtils::fgMemoryManager);
~TranscodeFromStr();
/** @name Getter methods */
//@{
/** Returns the transcoded, null terminated string
* @return the transcoded string
*/
const XMLCh *str() const;
/** Returns the transcoded, null terminated string - adopting
* the memory allocated to it from the TranscodeFromStr object
* @return the transcoded string
*/
XMLCh *adopt();
/** Returns the length of the transcoded string in characters. The length
* does not include the null terminator.
* @return the length of the transcoded string in characters
*/
XMLSize_t length() const;
//@}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
TranscodeFromStr(const TranscodeFromStr &);
TranscodeFromStr &operator=(const TranscodeFromStr &);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void transcode(const XMLByte *in, XMLSize_t length, XMLTranscoder *trans);
// -----------------------------------------------------------------------
// Private data members
//
// fString
// The transcoded string
//
// fBytesWritten
// The length of the transcoded string in characters
// -----------------------------------------------------------------------
XMLCh *fString;
XMLSize_t fCharsWritten;
MemoryManager *fMemoryManager;
};
// ---------------------------------------------------------------------------
// XMLTranscoder: Getter methods
// ---------------------------------------------------------------------------
inline MemoryManager* XMLTranscoder::getMemoryManager() const
{
return fMemoryManager;
}
// ---------------------------------------------------------------------------
// XMLTranscoder: Protected helper methods
// ---------------------------------------------------------------------------
inline XMLSize_t XMLTranscoder::getBlockSize() const
{
return fBlockSize;
}
inline const XMLCh* XMLTranscoder::getEncodingName() const
{
return fEncodingName;
}
// ---------------------------------------------------------------------------
// TranscodeToStr: Getter methods
// ---------------------------------------------------------------------------
inline const XMLByte *TranscodeToStr::str() const
{
return fString;
}
inline XMLByte *TranscodeToStr::adopt()
{
XMLByte *tmp = fString;
fString = 0;
return tmp;
}
inline XMLSize_t TranscodeToStr::length () const
{
return fBytesWritten;
}
// ---------------------------------------------------------------------------
// TranscodeFromStr: Getter methods
// ---------------------------------------------------------------------------
inline const XMLCh *TranscodeFromStr::str() const
{
return fString;
}
inline XMLCh *TranscodeFromStr::adopt()
{
XMLCh *tmp = fString;
fString = 0;
return tmp;
}
inline XMLSize_t TranscodeFromStr::length() const
{
return fCharsWritten;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,359 @@
/*
* 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: IconvGNUTransService.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ICONVGNUTRANSSERVICE_HPP)
#define XERCESC_INCLUDE_GUARD_ICONVGNUTRANSSERVICE_HPP
#include <xercesc/util/TransService.hpp>
#include <xercesc/util/Mutexes.hpp>
#include <iconv/iconv.h>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Libiconv wrapper (low-level conversion utilities collection)
// ---------------------------------------------------------------------------
class XMLUTIL_EXPORT IconvGNUWrapper
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
IconvGNUWrapper
(
iconv_t cd_from,
iconv_t cd_to,
size_t uchsize,
unsigned int ubo,
MemoryManager* manager
);
virtual ~IconvGNUWrapper();
// Convert "native unicode" character into XMLCh
void mbcToXMLCh (const char *mbc, XMLCh *toRet) const;
// Convert XMLCh into "native unicode" character
void xmlChToMbc (XMLCh xch, char *mbc) const;
// Fill array of XMLCh characters with data, supplied in the array
// of "native unicode" characters.
XMLCh* mbsToXML (
const char* mbs_str,
XMLCh* xml_str,
size_t cnt
) const;
// Fill array of "native unicode" characters with data, supplied
// in the array of XMLCh characters.
char* xmlToMbs
(
const XMLCh* xml_str,
char* mbs_str,
size_t cnt
) const;
// Private data accessors
inline iconv_t cdTo () const { return fCDTo; }
inline iconv_t cdFrom () const { return fCDFrom; }
inline size_t uChSize () const { return fUChSize; }
inline unsigned int UBO () const { return fUBO; }
protected:
// The following four functions should called with the fMutex
// locked.
//
// Return uppercase equivalent for XMLCh
XMLCh toUpper (const XMLCh ch);
// Return uppercase equivalent for XMLCh
XMLCh toLower (const XMLCh ch);
// Wrapper around the iconv() for transcoding from the local charset
size_t iconvFrom
(
const char *fromPtr,
size_t *fromLen,
char **toPtr,
size_t toLen
);
// Wrapper around the iconv() for transcoding to the local charset
size_t iconvTo
(
const char *fromPtr,
size_t *fromLen,
char **toPtr,
size_t toLen
);
protected:
// Hidden constructor
IconvGNUWrapper(MemoryManager* manager);
// Private data accessors
inline void setCDTo (iconv_t cd) { fCDTo = cd; }
inline void setCDFrom (iconv_t cd) { fCDFrom = cd; }
inline void setUChSize (size_t sz) { fUChSize = sz; }
inline void setUBO (unsigned int u) { fUBO = u; }
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IconvGNUWrapper(const IconvGNUWrapper&);
IconvGNUWrapper& operator=(const IconvGNUWrapper&);
// -----------------------------------------------------------------------
// Private data members
//
// fCDTo
// Characterset conversion descriptor TO the local-host encoding
// fCDFrom
// Characterset conversion descriptor FROM the local-host encoding
// fUChSize
// Sizeof the "native unicode" character in bytes
// fUBO
// "Native unicode" characters byte order
// -----------------------------------------------------------------------
size_t fUChSize;
unsigned int fUBO;
iconv_t fCDTo;
iconv_t fCDFrom;
protected:
XMLMutex fMutex;
};
// ---------------------------------------------------------------------------
// FreeBSD-specific Transcoding Service implementation
// ---------------------------------------------------------------------------
class XMLUTIL_EXPORT IconvGNUTransService : public XMLTransService, IconvGNUWrapper
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
IconvGNUTransService(MemoryManager* manager);
~IconvGNUTransService();
// -----------------------------------------------------------------------
// Implementation of the virtual transcoding service API
// -----------------------------------------------------------------------
virtual int compareIString
(
const XMLCh* const comp1
, const XMLCh* const comp2
);
virtual int compareNIString
(
const XMLCh* const comp1
, const XMLCh* const comp2
, const XMLSize_t maxChars
);
virtual const XMLCh* getId() const;
virtual XMLLCPTranscoder* makeNewLCPTranscoder(MemoryManager* manager);
virtual bool supportsSrcOfs() const;
virtual void upperCase(XMLCh* const toUpperCase);
virtual void lowerCase(XMLCh* const toUpperCase);
protected :
// -----------------------------------------------------------------------
// Protected virtual methods
// -----------------------------------------------------------------------
virtual XMLTranscoder* makeNewXMLTranscoder
(
const XMLCh* const encodingName
, XMLTransService::Codes& resValue
, const XMLSize_t blockSize
, MemoryManager* const manager
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IconvGNUTransService(const IconvGNUTransService&);
IconvGNUTransService& operator=(const IconvGNUTransService&);
// -----------------------------------------------------------------------
// Private data members
//
// fUnicodeCP
// Unicode encoding schema name
// -----------------------------------------------------------------------
const char* fUnicodeCP;
};
//----------------------------------------------------------------------------
// Implementation of the transcoders for arbitrary input characterset is
// supported ONLY through libiconv interface
//----------------------------------------------------------------------------
class XMLUTIL_EXPORT IconvGNUTranscoder : public XMLTranscoder, IconvGNUWrapper
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
IconvGNUTranscoder(const XMLCh* const encodingName
, const XMLSize_t blockSize
, iconv_t cd_from
, iconv_t cd_to
, size_t uchsize
, unsigned int ubo
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~IconvGNUTranscoder();
// -----------------------------------------------------------------------
// Implementation of the virtual transcoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IconvGNUTranscoder();
IconvGNUTranscoder(const IconvGNUTranscoder&);
IconvGNUTranscoder& operator=(const IconvGNUTranscoder&);
};
// ---------------------------------------------------------------------------
// GNU-specific XMLCh <-> local (host) characterset transcoder
// ---------------------------------------------------------------------------
class XMLUTIL_EXPORT IconvGNULCPTranscoder : public XMLLCPTranscoder, IconvGNUWrapper
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
IconvGNULCPTranscoder
(
iconv_t from,
iconv_t to,
size_t uchsize,
unsigned int ubo,
MemoryManager* manager
);
protected:
IconvGNULCPTranscoder(); // Unimplemented
public:
~IconvGNULCPTranscoder();
// -----------------------------------------------------------------------
// Implementation of the virtual transcoder interface
// -----------------------------------------------------------------------
virtual char* transcode(const XMLCh* const toTranscode,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual XMLCh* transcode(const char* const toTranscode,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// -----------------------------------------------------------------------
// DEPRECATED old transcode interface
// -----------------------------------------------------------------------
virtual XMLSize_t calcRequiredSize(const char* const srcText
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual XMLSize_t calcRequiredSize(const XMLCh* const srcText
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual bool transcode
(
const char* const toTranscode
, XMLCh* const toFill
, const XMLSize_t maxChars
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual bool transcode
(
const XMLCh* const toTranscode
, char* const toFill
, const XMLSize_t maxChars
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IconvGNULCPTranscoder(const IconvGNULCPTranscoder&);
IconvGNULCPTranscoder& operator=(const IconvGNULCPTranscoder&);
};
XERCES_CPP_NAMESPACE_END
#endif /* ICONVGNUTRANSSERVICE */

View File

@@ -0,0 +1,34 @@
/*
* 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: TranscodingException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_TRANSCODINGEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_TRANSCODINGEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(TranscodingException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,35 @@
/*
* 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: UTFDataFormatException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_UTFDATAFORMATEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_UTFDATAFORMATEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(UTFDataFormatException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: UnexpectedEOFException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_UNEXPECTEDEOFEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_UNEXPECTEDEOFEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(UnexpectedEOFException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,34 @@
/*
* 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: UnsupportedEncodingException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_UNSUPPORTEDENCODINGEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_UNSUPPORTEDENCODINGEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(UnsupportedEncodingException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,150 @@
/*
* 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: ValueArrayOf.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_VALUEARRAY_HPP)
#define XERCESC_INCLUDE_GUARD_VALUEARRAY_HPP
#include <xercesc/util/XMLEnumerator.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class TElem> class ValueArrayOf : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueArrayOf
(
const XMLSize_t size
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ValueArrayOf
(
const TElem* values
, const XMLSize_t size
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ValueArrayOf(const ValueArrayOf<TElem>& source);
~ValueArrayOf();
// -----------------------------------------------------------------------
// Public operators
// -----------------------------------------------------------------------
TElem& operator[](const XMLSize_t index);
const TElem& operator[](const XMLSize_t index) const;
ValueArrayOf<TElem>& operator=(const ValueArrayOf<TElem>& toAssign);
bool operator==(const ValueArrayOf<TElem>& toCompare) const;
bool operator!=(const ValueArrayOf<TElem>& toCompare) const;
// -----------------------------------------------------------------------
// Copy operations
// -----------------------------------------------------------------------
XMLSize_t copyFrom(const ValueArrayOf<TElem>& srcArray);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLSize_t length() const;
TElem* rawData() const;
// -----------------------------------------------------------------------
// Miscellaneous methods
// -----------------------------------------------------------------------
void resize(const XMLSize_t newSize);
private :
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
XMLSize_t fSize;
TElem* fArray;
MemoryManager* fMemoryManager;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TElem> class ValueArrayEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueArrayEnumerator
(
ValueArrayOf<TElem>* const toEnum
, const bool adopt = false
);
virtual ~ValueArrayEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueArrayEnumerator(const ValueArrayEnumerator<TElem>&);
ValueArrayEnumerator<TElem>& operator=(const ValueArrayEnumerator<TElem>&);
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurIndex
// This is the current index into the vector.
//
// fToEnum
// The value array being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fCurIndex;
ValueArrayOf<TElem>* fToEnum;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/ValueArrayOf.c>
#endif
#endif

View File

@@ -0,0 +1,229 @@
/*
* 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: ValueHashTableOf.hpp 679340 2008-07-24 10:28:29Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_VALUEHASHTABLEOF_HPP)
#define XERCESC_INCLUDE_GUARD_VALUEHASHTABLEOF_HPP
#include <xercesc/util/Hashers.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// Forward declare the enumerator so it can be our friend.
//
template <class TVal, class THasher = StringHasher>
class ValueHashTableOfEnumerator;
//
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
template <class TVal>
struct ValueHashTableBucketElem
{
ValueHashTableBucketElem(void* key, const TVal& value, ValueHashTableBucketElem<TVal>* next)
: fData(value), fNext(next), fKey(key)
{
}
ValueHashTableBucketElem(){};
~ValueHashTableBucketElem(){};
TVal fData;
ValueHashTableBucketElem<TVal>* fNext;
void* fKey;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueHashTableBucketElem(const ValueHashTableBucketElem<TVal>&);
ValueHashTableBucketElem<TVal>& operator=(const ValueHashTableBucketElem<TVal>&);
};
template <class TVal, class THasher = StringHasher>
class ValueHashTableOf : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueHashTableOf(
const XMLSize_t modulus,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
ValueHashTableOf(
const XMLSize_t modulus,
const THasher& hasher,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~ValueHashTableOf();
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
bool isEmpty() const;
bool containsKey(const void* const key) const;
void removeKey(const void* const key);
void removeAll();
// -----------------------------------------------------------------------
// Getters
// -----------------------------------------------------------------------
TVal& get(const void* const key, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
const TVal& get(const void* const key) const;
// -----------------------------------------------------------------------
// Putters
// -----------------------------------------------------------------------
void put(void* key, const TVal& valueToAdopt);
private :
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class ValueHashTableOfEnumerator<TVal, THasher>;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueHashTableOf(const ValueHashTableOf<TVal, THasher>&);
ValueHashTableOf<TVal, THasher>& operator=(const ValueHashTableOf<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
ValueHashTableBucketElem<TVal>* findBucketElem(const void* const key, XMLSize_t& hashVal);
const ValueHashTableBucketElem<TVal>* findBucketElem(const void* const key, XMLSize_t& hashVal) const;
void removeBucketElem(const void* const key, XMLSize_t& hashVal);
void initialize(const XMLSize_t modulus);
void rehash();
// -----------------------------------------------------------------------
// Data members
//
// fBucketList
// This is the array that contains the heads of all of the list
// buckets, one for each possible hash value.
//
// fHashModulus
// The modulus used for this hash table, to hash the keys. This is
// also the number of elements in the bucket list.
//
// fHash
// The hasher for the key data type.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
ValueHashTableBucketElem<TVal>** fBucketList;
XMLSize_t fHashModulus;
XMLSize_t fInitialModulus;
XMLSize_t fCount;
THasher fHasher;
};
//
// An enumerator for a value array. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TVal, class THasher>
class ValueHashTableOfEnumerator : public XMLEnumerator<TVal>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueHashTableOfEnumerator(ValueHashTableOf<TVal, THasher>* const toEnum
, const bool adopt = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~ValueHashTableOfEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TVal& nextElement();
void Reset();
// -----------------------------------------------------------------------
// New interface specific for key used in ValueHashable
// -----------------------------------------------------------------------
void* nextElementKey();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueHashTableOfEnumerator(const ValueHashTableOfEnumerator<TVal, THasher>&);
ValueHashTableOfEnumerator<TVal, THasher>& operator=(const ValueHashTableOfEnumerator<TVal, THasher>&);
// -----------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------
void findNext();
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurElem
// This is the current bucket bucket element that we are on.
//
// fCurHash
// The is the current hash buck that we are working on. Once we hit
// the end of the bucket that fCurElem is in, then we have to start
// working this one up to the next non-empty bucket.
//
// fToEnum
// The value array being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
ValueHashTableBucketElem<TVal>* fCurElem;
XMLSize_t fCurHash;
ValueHashTableOf<TVal, THasher>* fToEnum;
MemoryManager* const fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/ValueHashTableOf.c>
#endif
#endif

View File

@@ -0,0 +1,155 @@
/*
* 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: ValueStackOf.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_VALUESTACKOF_HPP)
#define XERCESC_INCLUDE_GUARD_VALUESTACKOF_HPP
#include <xercesc/util/EmptyStackException.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// Forward declare the enumerator so he can be our friend. Can you say
// friend? Sure...
//
template <class TElem> class ValueStackEnumerator;
template <class TElem> class ValueStackOf : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueStackOf
(
const XMLSize_t fInitCapacity
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, const bool toCallDestructor = false
);
~ValueStackOf();
// -----------------------------------------------------------------------
// Element management methods
// -----------------------------------------------------------------------
void push(const TElem& toPush);
const TElem& peek() const;
TElem pop();
void removeAllElements();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool empty();
XMLSize_t curCapacity();
XMLSize_t size();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueStackOf(const ValueStackOf<TElem>&);
ValueStackOf<TElem>& operator=(const ValueStackOf<TElem>&);
// -----------------------------------------------------------------------
// Declare our friends
// -----------------------------------------------------------------------
friend class ValueStackEnumerator<TElem>;
// -----------------------------------------------------------------------
// Data Members
//
// fVector
// The vector that is used as the backing data structure for the
// stack.
// -----------------------------------------------------------------------
ValueVectorOf<TElem> fVector;
};
//
// An enumerator for a value stack. It derives from the basic enumerator
// class, so that value stacks can be generically enumerated.
//
template <class TElem> class ValueStackEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueStackEnumerator
(
ValueStackOf<TElem>* const toEnum
, const bool adopt = false
);
virtual ~ValueStackEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueStackEnumerator(const ValueStackEnumerator<TElem>&);
ValueStackEnumerator<TElem>& operator=(const ValueStackEnumerator<TElem>&);
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed stack. If so then
// we delete the stack when we are destroyed.
//
// fCurIndex
// This is the current index into the vector inside the stack being
// enumerated.
//
// fToEnum
// The stack that is being enumerated. This is just kept for
// adoption purposes, since we really are enumerating the vector
// inside of it.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fCurIndex;
ValueVectorOf<TElem>* fVector;
ValueStackOf<TElem>* fToEnum;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/ValueStackOf.c>
#endif
#endif

View File

@@ -0,0 +1,162 @@
/*
* 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: ValueVectorOf.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_VALUEVECTOROF_HPP)
#define XERCESC_INCLUDE_GUARD_VALUEVECTOROF_HPP
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/util/XMLEnumerator.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class TElem> class ValueVectorOf : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueVectorOf
(
const XMLSize_t maxElems
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, const bool toCallDestructor = false
);
ValueVectorOf(const ValueVectorOf<TElem>& toCopy);
~ValueVectorOf();
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
ValueVectorOf<TElem>& operator=(const ValueVectorOf<TElem>& toAssign);
// -----------------------------------------------------------------------
// Element management
// -----------------------------------------------------------------------
void addElement(const TElem& toAdd);
void setElementAt(const TElem& toSet, const XMLSize_t setAt);
void insertElementAt(const TElem& toInsert, const XMLSize_t insertAt);
void removeElementAt(const XMLSize_t removeAt);
void removeAllElements();
bool containsElement(const TElem& toCheck, const XMLSize_t startIndex = 0);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const TElem& elementAt(const XMLSize_t getAt) const;
TElem& elementAt(const XMLSize_t getAt);
XMLSize_t curCapacity() const;
XMLSize_t size() const;
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Miscellaneous
// -----------------------------------------------------------------------
void ensureExtraCapacity(const XMLSize_t length);
const TElem* rawData() const;
private:
// -----------------------------------------------------------------------
// Data members
//
// fCurCount
// The count of values current added to the vector, which may be
// less than the internal capacity.
//
// fMaxCount
// The current capacity of the vector.
//
// fElemList
// The list of elements, which is dynamically allocated to the needed
// size.
// -----------------------------------------------------------------------
bool fCallDestructor;
XMLSize_t fCurCount;
XMLSize_t fMaxCount;
TElem* fElemList;
MemoryManager* fMemoryManager;
};
//
// An enumerator for a value vector. It derives from the basic enumerator
// class, so that value vectors can be generically enumerated.
//
template <class TElem> class ValueVectorEnumerator : public XMLEnumerator<TElem>, public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ValueVectorEnumerator
(
ValueVectorOf<TElem>* const toEnum
, const bool adopt = false
);
virtual ~ValueVectorEnumerator();
// -----------------------------------------------------------------------
// Enum interface
// -----------------------------------------------------------------------
bool hasMoreElements() const;
TElem& nextElement();
void Reset();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueVectorEnumerator(const ValueVectorEnumerator<TElem>&);
ValueVectorEnumerator<TElem>& operator=(const ValueVectorEnumerator<TElem>&);
// -----------------------------------------------------------------------
// Data Members
//
// fAdopted
// Indicates whether we have adopted the passed vector. If so then
// we delete the vector when we are destroyed.
//
// fCurIndex
// This is the current index into the vector.
//
// fToEnum
// The value vector being enumerated.
// -----------------------------------------------------------------------
bool fAdopted;
XMLSize_t fCurIndex;
ValueVectorOf<TElem>* fToEnum;
};
XERCES_CPP_NAMESPACE_END
#if !defined(XERCES_TMPLSINC)
#include <xercesc/util/ValueVectorOf.c>
#endif
#endif

View File

@@ -0,0 +1,146 @@
/*
* 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: XML256TableTranscoder.hpp 635560 2008-03-10 14:10:09Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML256TABLETRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XML256TABLETRANSCODER_HPP
#include <xercesc/util/TransService.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class implements the functionality of a common type of transcoder
// for an 8 bit, single byte encoding based on a set of 'to' and 'from'
// translation tables. Actual derived classes are trivial and just have to
// provide us with pointers to their tables and we do all the work.
//
class XMLUTIL_EXPORT XML256TableTranscoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
virtual ~XML256TableTranscoder();
// -----------------------------------------------------------------------
// The virtual transcoding interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XML256TableTranscoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, const XMLCh* const fromTable
, const XMLTransService::TransRec* const toTable
, const XMLSize_t toTableSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Protected helper methods
// -----------------------------------------------------------------------
XMLByte xlatOneTo
(
const XMLCh toXlat
) const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XML256TableTranscoder();
XML256TableTranscoder(const XML256TableTranscoder&);
XML256TableTranscoder& operator=(const XML256TableTranscoder&);
// -----------------------------------------------------------------------
// Private data members
//
// fFromTable
// This is the 'from' table that we were given during construction.
// It is a 256 entry table of XMLCh chars. Each entry is the
// Unicode code point for the external encoding point of that value.
// So fFromTable[N] is the Unicode translation of code point N of
// the source encoding.
//
// We don't own this table, we just refer to it. It is assumed that
// the table is static, for performance reasons.
//
// fToSize
// The 'to' table is variable sized. This indicates how many records
// are in it.
//
// fToTable
// This is a variable sized table of TransRec structures. It must
// be sorted by the intCh field, i.e. the XMLCh field. It is searched
// binarily to find the record for a particular Unicode char. Then
// that record's extch field is the translation record.
//
// We don't own this table, we just refer to it. It is assumed that
// the table is static, for performance reasons.
//
// NOTE: There may be dups of the extCh field, since there might be
// multiple Unicode code points which map to the same external code
// point. Normally this won't happen, since the parser assumes that
// internalization is normalized, but we have to be prepared to do
// the right thing if some client code gives us non-normalized data
// itself.
// -----------------------------------------------------------------------
const XMLCh* fFromTable;
XMLSize_t fToSize;
const XMLTransService::TransRec* fToTable;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,93 @@
/*
* 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: XML88591Transcoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML88591TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XML88591TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/TransService.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple 8859-1 transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
class XMLUTIL_EXPORT XML88591Transcoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XML88591Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XML88591Transcoder();
// -----------------------------------------------------------------------
// Implementation of the XMLTranscoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XML88591Transcoder(const XML88591Transcoder&);
XML88591Transcoder& operator=(const XML88591Transcoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,93 @@
/*
* 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: XMLASCIITranscoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLASCIITRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLASCIITRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/TransService.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple ASCII transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
class XMLUTIL_EXPORT XMLASCIITranscoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Constructors and destructor
// -----------------------------------------------------------------------
XMLASCIITranscoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLASCIITranscoder();
// -----------------------------------------------------------------------
// Implementation of the XMLTranscoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLASCIITranscoder(const XMLASCIITranscoder&);
XMLASCIITranscoder& operator=(const XMLASCIITranscoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,221 @@
/*
* 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: XMLAbstractDoubleFloat.hpp 605828 2007-12-20 08:05:47Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_ABSTRACT_DOUBLE_FLOAT_HPP)
#define XERCESC_INCLUDE_GUARD_XML_ABSTRACT_DOUBLE_FLOAT_HPP
#include <xercesc/util/XMLNumber.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/***
* 3.2.5.1 Lexical representation
*
* double values have a lexical representation consisting of a mantissa followed,
* optionally, by the character "E" or "e", followed by an exponent.
*
* The exponent must be an integer.
* The mantissa must be a decimal number.
* The representations for exponent and mantissa must follow the lexical rules
* for integer and decimal.
*
* If the "E" or "e" and the following exponent are omitted,
* an exponent value of 0 is assumed.
***/
/***
* 3.2.4.1 Lexical representation
*
* float values have a lexical representation consisting of a mantissa followed,
* optionally, by the character "E" or "e", followed by an exponent.
*
* The exponent must be an integer.
* The mantissa must be a decimal number.
* The representations for exponent and mantissa must follow the lexical rules
* for integer and decimal.
*
* If the "E" or "e" and the following exponent are omitted,
* an exponent value of 0 is assumed.
***/
class XMLUTIL_EXPORT XMLAbstractDoubleFloat : public XMLNumber
{
public:
enum LiteralType
{
NegINF,
PosINF,
NaN,
SpecialTypeNum,
Normal
};
virtual ~XMLAbstractDoubleFloat();
static XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
);
virtual XMLCh* getRawData() const;
virtual const XMLCh* getFormattedString() const;
virtual int getSign() const;
MemoryManager* getMemoryManager() const;
inline bool isDataConverted() const;
inline bool isDataOverflowed() const;
inline double getValue() const;
inline LiteralType getType() const;
/***
*
* The decimal point delimiter for the schema double/float type is
* defined to be a period and is not locale-specific. So, it must
* be replaced with the local-specific delimiter before converting
* from string to double/float.
*
***/
static void normalizeDecimalPoint(char* const toNormal);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLAbstractDoubleFloat)
protected:
//
// To be used by derived class exclusively
//
XMLAbstractDoubleFloat(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
void init(const XMLCh* const strValue);
/**
* Compares this object to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is an <code>XMLAbstractDoubleFloat</code> object that contains
* the same <code>int</code> value as this object.
*
* @param lValue the object to compare with.
* @param rValue the object to compare against.
* @param manager The MemoryManager to use to allocate objects
* @return <code>true</code> if the objects are the same;
* <code>false</code> otherwise.
*/
static int compareValues(const XMLAbstractDoubleFloat* const lValue
, const XMLAbstractDoubleFloat* const rValue
, MemoryManager* const manager);
//
// to be overridden by derived class
//
virtual void checkBoundary(char* const strValue) = 0;
void
convert(char* const strValue);
private:
//
// Unimplemented
//
// copy ctor
// assignment ctor
//
XMLAbstractDoubleFloat(const XMLAbstractDoubleFloat& toCopy);
XMLAbstractDoubleFloat& operator=(const XMLAbstractDoubleFloat& toAssign);
void normalizeZero(XMLCh* const);
inline bool isSpecialValue() const;
static int compareSpecial(const XMLAbstractDoubleFloat* const specialValue
, MemoryManager* const manager);
void formatString();
protected:
double fValue;
LiteralType fType;
bool fDataConverted;
bool fDataOverflowed;
private:
int fSign;
XMLCh* fRawData;
//
// If the original string is not lexcially the same as the five
// special value notations, and the value is converted to
// special value due underlying platform restriction on data
// representation, then this string is constructed and
// takes the form "original_string (special_value_notation)",
// otherwise it is empty.
//
XMLCh* fFormattedString;
MemoryManager* fMemoryManager;
};
inline bool XMLAbstractDoubleFloat::isSpecialValue() const
{
return (fType < SpecialTypeNum);
}
inline MemoryManager* XMLAbstractDoubleFloat::getMemoryManager() const
{
return fMemoryManager;
}
inline bool XMLAbstractDoubleFloat::isDataConverted() const
{
return fDataConverted;
}
inline bool XMLAbstractDoubleFloat::isDataOverflowed() const
{
return fDataOverflowed;
}
inline double XMLAbstractDoubleFloat::getValue() const
{
return fValue;
}
inline XMLAbstractDoubleFloat::LiteralType XMLAbstractDoubleFloat::getType() const
{
return fType;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,206 @@
/*
* 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: XMLBigDecimal.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_BIGDECIMAL_HPP)
#define XERCESC_INCLUDE_GUARD_XML_BIGDECIMAL_HPP
#include <xercesc/util/XMLNumber.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLBigDecimal : public XMLNumber
{
public:
/**
* Constructs a newly allocated <code>XMLBigDecimal</code> object that
* represents the value represented by the string.
*
* @param strValue the <code>String</code> to be converted to an
* <code>XMLBigDecimal</code>.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
* @exception NumberFormatException if the <code>String</code> does not
* contain a parsable XMLBigDecimal.
*/
XMLBigDecimal
(
const XMLCh* const strValue
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~XMLBigDecimal();
static int compareValues(const XMLBigDecimal* const lValue
, const XMLBigDecimal* const rValue
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
static XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
);
static void parseDecimal
(
const XMLCh* const toParse
, XMLCh* const retBuffer
, int& sign
, int& totalDigits
, int& fractDigits
, MemoryManager* const manager
);
static void parseDecimal
(
const XMLCh* const toParse
, MemoryManager* const manager
);
virtual XMLCh* getRawData() const;
virtual const XMLCh* getFormattedString() const;
virtual int getSign() const;
const XMLCh* getValue() const;
unsigned int getScale() const;
unsigned int getTotalDigit() const;
inline XMLCh* getIntVal() const;
/**
* Compares this object to the specified object.
*
* @param other the object to compare with.
* @return <code>-1</code> value is less than other's
* <code>0</code> value equals to other's
* <code>+1</code> value is greater than other's
*/
int toCompare(const XMLBigDecimal& other) const;
/*
* Sets the value to be converted
*
* @param strValue the value to convert
*/
void setDecimalValue(const XMLCh* const strValue);
MemoryManager* getMemoryManager() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLBigDecimal)
XMLBigDecimal(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
void cleanUp();
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLBigDecimal(const XMLBigDecimal& other);
XMLBigDecimal& operator=(const XMLBigDecimal& other);
// -----------------------------------------------------------------------
// Private data members
//
// fSign
// sign
//
// fTotalDigits
// the total number of digits
//
// fScale
// the number of digits to the right of the decimal point
//
// fIntVal
// The value of this BigDecimal, w/o
// leading whitespace, leading zero
// decimal point
// trailing zero, trailing whitespace
//
// fRawData
// to preserve the original string used to construct this object,
// needed for pattern matching.
//
// -----------------------------------------------------------------------
int fSign;
unsigned int fTotalDigits;
unsigned int fScale;
XMLSize_t fRawDataLen;
XMLCh* fRawData;
XMLCh* fIntVal;
MemoryManager* fMemoryManager;
};
inline int XMLBigDecimal::getSign() const
{
return fSign;
}
inline const XMLCh* XMLBigDecimal::getValue() const
{
return fIntVal;
}
inline unsigned int XMLBigDecimal::getScale() const
{
return fScale;
}
inline unsigned int XMLBigDecimal::getTotalDigit() const
{
return fTotalDigits;
}
inline XMLCh* XMLBigDecimal::getRawData() const
{
return fRawData;
}
inline const XMLCh* XMLBigDecimal::getFormattedString() const
{
return fRawData;
}
inline MemoryManager* XMLBigDecimal::getMemoryManager() const
{
return fMemoryManager;
}
inline XMLCh* XMLBigDecimal::getIntVal() const
{
return fIntVal;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,175 @@
/*
* 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: XMLBigInteger.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_BIGINTEGER_HPP)
#define XERCESC_INCLUDE_GUARD_XML_BIGINTEGER_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/XMLString.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLBigInteger : public XMemory
{
public:
/**
* Constructs a newly allocated <code>XMLBigInteger</code> object that
* represents the value represented by the string. The string is
* converted to an int value as if by the <code>valueOf</code> method.
*
* @param strValue the <code>String</code> to be converted to an
* <code>XMLBigInteger</code>.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
* @exception NumberFormatException if the <code>String</code> does not
* contain a parsable XMLBigInteger.
*/
XMLBigInteger
(
const XMLCh* const strValue
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~XMLBigInteger();
XMLBigInteger(const XMLBigInteger& toCopy);
static XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
, bool isNonPositiveInteger = false
);
static void parseBigInteger(const XMLCh* const toConvert
, XMLCh* const retBuffer
, int& signValue
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
static int compareValues(const XMLBigInteger* const lValue
,const XMLBigInteger* const rValue
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
static int compareValues(const XMLCh* const lString
, const int& lSign
, const XMLCh* const rString
, const int& rSign
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
void multiply(const unsigned int byteToShift);
void divide(const unsigned int byteToShift);
unsigned int getTotalDigit() const;
/**
* Return a copy of the fMagnitude.
* This is similar to toString, except the internal buffer is returned directly
* Caller is not required to delete the returned memory.
*/
inline XMLCh* getRawData() const;
/**
* Compares this object to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is an <code>XMLBigInteger</code> object that contains
* the same <code>int</code> value as this object.
*
* @param toCompare the object to compare with.
* @return <code>true</code> if the objects are the same;
* <code>false</code> otherwise.
*/
bool operator==(const XMLBigInteger& toCompare) const;
/**
* Returns the signum function of this number (i.e., -1, 0 or 1 as
* the value of this number is negative, zero or positive).
*/
int getSign() const;
int intValue() const;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLBigInteger& operator=(const XMLBigInteger&);
void setSign(int);
/*
* The number is internally stored in "minimal" sign-fMagnitude format
* (i.e., no BigIntegers have a leading zero byte in their magnitudes).
* Zero is represented with a signum of 0 (and a zero-length fMagnitude).
* Thus, there is exactly one representation for each value.
*/
// -----------------------------------------------------------------------
// Private data members
//
// fSign
// to represent the sign of the number.
//
// fMagnitude
// the buffer holding the number.
//
// fRawData
// to preserve the original string used to construct this object,
// needed for pattern matching.
//
// -----------------------------------------------------------------------
int fSign;
XMLCh* fMagnitude; //null terminated
XMLCh* fRawData;
MemoryManager* fMemoryManager;
};
inline int XMLBigInteger::getSign() const
{
return fSign;
}
inline unsigned int XMLBigInteger::getTotalDigit() const
{
return ((getSign() ==0) ? 0 : (unsigned int)XMLString::stringLen(fMagnitude));
}
inline bool XMLBigInteger::operator==(const XMLBigInteger& toCompare) const
{
return ( compareValues(this, &toCompare, fMemoryManager) ==0 ? true : false);
}
inline void XMLBigInteger::setSign(int newSign)
{
fSign = newSign;
}
inline XMLCh* XMLBigInteger::getRawData() const
{
return fRawData;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,90 @@
/*
* 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: XMLChTranscoder.hpp 635560 2008-03-10 14:10:09Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLCHTRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLCHTRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/TransService.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple XMLCh transcoder. This is used for internal entities, which
// are already in the native XMLCh format.
//
class XMLUTIL_EXPORT XMLChTranscoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLChTranscoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLChTranscoder();
// -----------------------------------------------------------------------
// Implementation of the XMLTranscoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLChTranscoder(const XMLChTranscoder&);
XMLChTranscoder& operator=(const XMLChTranscoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,442 @@
/*
* 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: XMLChar.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLCHAR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLCHAR_HPP
#include <xercesc/util/XMLUniDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// This file defines Char and utility that conforms to XML 1.0 and XML 1.1
// ---------------------------------------------------------------------------
// Masks for the fgCharCharsTable1_0 array
const XMLByte gNCNameCharMask = 0x1;
const XMLByte gFirstNameCharMask = 0x2;
const XMLByte gNameCharMask = 0x4;
const XMLByte gPlainContentCharMask = 0x8;
const XMLByte gSpecialStartTagCharMask = 0x10;
const XMLByte gControlCharMask = 0x20;
const XMLByte gXMLCharMask = 0x40;
const XMLByte gWhitespaceCharMask = 0x80;
// ---------------------------------------------------------------------------
// This class is for XML 1.0
// ---------------------------------------------------------------------------
class XMLUTIL_EXPORT XMLChar1_0
{
public:
// -----------------------------------------------------------------------
// Public, static methods, check the string
// -----------------------------------------------------------------------
static bool isAllSpaces
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool containsWhiteSpace
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidNmtoken
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidName
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidName
(
const XMLCh* const toCheck
);
static bool isValidNCName
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidQName
(
const XMLCh* const toCheck
, const XMLSize_t count
);
// -----------------------------------------------------------------------
// Public, static methods, check the XMLCh
// surrogate pair is assumed if second parameter is not null
// -----------------------------------------------------------------------
static bool isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isXMLChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isWhitespace(const XMLCh toCheck);
static bool isWhitespace(const XMLCh toCheck, const XMLCh toCheck2);
static bool isControlChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isPublicIdChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isFirstNCNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isNCNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
// -----------------------------------------------------------------------
// Special Non-conformant Public, static methods
// -----------------------------------------------------------------------
/**
* Return true if NEL (0x85) and LSEP (0x2028) to be treated as white space char.
*/
static bool isNELRecognized();
/**
* Method to enable NEL (0x85) and LSEP (0x2028) to be treated as white space char.
*/
static void enableNELWS();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLChar1_0();
// -----------------------------------------------------------------------
// Static data members
//
// fgCharCharsTable1_0
// The character characteristics table. Bits in each byte, represent
// the characteristics of each character. It is generated via some
// code and then hard coded into the cpp file for speed.
//
// fNEL
// Flag to represents whether NEL and LSEP newline recognition is enabled
// or disabled
// -----------------------------------------------------------------------
static XMLByte fgCharCharsTable1_0[0x10000];
static bool enableNEL;
friend class XMLReader;
};
// ---------------------------------------------------------------------------
// XMLReader: Public, static methods
// ---------------------------------------------------------------------------
inline bool XMLChar1_0::isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2)
{
// An XML letter is a FirstNameChar minus ':' and '_'.
if (!toCheck2) {
return (((fgCharCharsTable1_0[toCheck] & gFirstNameCharMask) != 0)
&& (toCheck != chColon) && (toCheck != chUnderscore));
}
return false;
}
inline bool XMLChar1_0::isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gFirstNameCharMask) != 0);
return false;
}
inline bool XMLChar1_0::isFirstNCNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2) {
return (((fgCharCharsTable1_0[toCheck] & gFirstNameCharMask) != 0) && (toCheck != chColon));
}
return false;
}
inline bool XMLChar1_0::isNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gNameCharMask) != 0);
return false;
}
inline bool XMLChar1_0::isNCNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gNCNameCharMask) != 0);
return false;
}
inline bool XMLChar1_0::isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gPlainContentCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_0::isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gSpecialStartTagCharMask) != 0);
return false;
}
inline bool XMLChar1_0::isXMLChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gXMLCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_0::isWhitespace(const XMLCh toCheck)
{
return ((fgCharCharsTable1_0[toCheck] & gWhitespaceCharMask) != 0);
}
inline bool XMLChar1_0::isWhitespace(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gWhitespaceCharMask) != 0);
return false;
}
inline bool XMLChar1_0::isControlChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_0[toCheck] & gControlCharMask) != 0);
return false;
}
inline bool XMLChar1_0::isNELRecognized() {
return enableNEL;
}
// ---------------------------------------------------------------------------
// This class is for XML 1.1
// ---------------------------------------------------------------------------
class XMLUTIL_EXPORT XMLChar1_1
{
public:
// -----------------------------------------------------------------------
// Public, static methods, check the string
// -----------------------------------------------------------------------
static bool isAllSpaces
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool containsWhiteSpace
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidNmtoken
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidName
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidName
(
const XMLCh* const toCheck
);
static bool isValidNCName
(
const XMLCh* const toCheck
, const XMLSize_t count
);
static bool isValidQName
(
const XMLCh* const toCheck
, const XMLSize_t count
);
// -----------------------------------------------------------------------
// Public, static methods, check the XMLCh
// -----------------------------------------------------------------------
static bool isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isXMLChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isWhitespace(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isControlChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isPublicIdChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isFirstNCNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
static bool isNCNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLChar1_1();
// -----------------------------------------------------------------------
// Static data members
//
// fgCharCharsTable1_1
// The character characteristics table. Bits in each byte, represent
// the characteristics of each character. It is generated via some
// code and then hard coded into the cpp file for speed.
//
// -----------------------------------------------------------------------
static XMLByte fgCharCharsTable1_1[0x10000];
friend class XMLReader;
};
// ---------------------------------------------------------------------------
// XMLReader: Public, static methods
// ---------------------------------------------------------------------------
inline bool XMLChar1_1::isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2)
{
/** XML 1.1 does not define a letter, so we use the 1.0 definition */
return XMLChar1_0::isXMLLetter(toCheck, toCheck2);
}
inline bool XMLChar1_1::isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gFirstNameCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDB7F))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_1::isFirstNCNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2) {
return (((fgCharCharsTable1_1[toCheck] & gFirstNameCharMask) != 0) && (toCheck != chColon));
}
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDB7F))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_1::isNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gNameCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDB7F))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_1::isNCNameChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gNCNameCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDB7F))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_1::isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gPlainContentCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_1::isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gSpecialStartTagCharMask) != 0);
return false;
}
inline bool XMLChar1_1::isXMLChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gXMLCharMask) != 0);
else {
if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
return true;
}
return false;
}
inline bool XMLChar1_1::isWhitespace(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gWhitespaceCharMask) != 0);
return false;
}
inline bool XMLChar1_1::isControlChar(const XMLCh toCheck, const XMLCh toCheck2)
{
if (!toCheck2)
return ((fgCharCharsTable1_1[toCheck] & gControlCharMask) != 0);
return false;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,104 @@
// This file is generated, don't edit it!!
#if !defined(XERCESC_INCLUDE_GUARD_ERRHEADER_XMLDOMMsg)
#define XERCESC_INCLUDE_GUARD_ERRHEADER_XMLDOMMsg
#include <xercesc/framework/XMLErrorReporter.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/dom/DOMError.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLDOMMsg
{
public :
enum Codes
{
NoError = 0
, F_LowBounds = 1
, DOMEXCEPTION_ERRX = 2
, INDEX_SIZE_ERR = 3
, DOMSTRING_SIZE_ERR = 4
, HIERARCHY_REQUEST_ERR = 5
, WRONG_DOCUMENT_ERR = 6
, INVALID_CHARACTER_ERR = 7
, NO_DATA_ALLOWED_ERR = 8
, NO_MODIFICATION_ALLOWED_ERR = 9
, NOT_FOUND_ERR = 10
, NOT_SUPPORTED_ERR = 11
, INUSE_ATTRIBUTE_ERR = 12
, INVALID_STATE_ERR = 13
, SYNTAX_ERR = 14
, INVALID_MODIFICATION_ERR = 15
, NAMESPACE_ERR = 16
, INVALID_ACCESS_ERR = 17
, VALIDATION_ERR = 18
, TYPE_MISMATCH_ERR = 19
, DOMRANGEEXCEPTION_ERRX = 20
, BAD_BOUNDARYPOINTS_ERR = 21
, INVALID_NODE_TYPE_ERR = 22
, DOMLSEXCEPTION_ERRX = 23
, PARSE_ERR = 24
, SERIALIZE_ERR = 25
, DOMXPATHEXCEPTION_ERRX = 26
, INVALID_EXPRESSION_ERR = 27
, TYPE_ERR = 28
, NO_RESULT_ERR = 29
, Writer_NestedCDATA = 30
, Writer_NotRepresentChar = 31
, Writer_NotRecognizedType = 32
, LSParser_ParseInProgress = 33
, LSParser_ParsingAborted = 34
, LSParser_ParsingFailed = 35
, F_HighBounds = 36
, W_LowBounds = 37
, W_HighBounds = 38
, E_LowBounds = 39
, E_HighBounds = 40
};
static bool isFatal(const XMLDOMMsg::Codes toCheck)
{
return ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds));
}
static bool isWarning(const XMLDOMMsg::Codes toCheck)
{
return ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds));
}
static bool isError(const XMLDOMMsg::Codes toCheck)
{
return ((toCheck >= E_LowBounds) && (toCheck <= E_HighBounds));
}
static XMLErrorReporter::ErrTypes errorType(const XMLDOMMsg::Codes toCheck)
{
if ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds))
return XMLErrorReporter::ErrType_Warning;
else if ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds))
return XMLErrorReporter::ErrType_Fatal;
else if ((toCheck >= E_LowBounds) && (toCheck <= E_HighBounds))
return XMLErrorReporter::ErrType_Error;
return XMLErrorReporter::ErrTypes_Unknown;
}
static DOMError::ErrorSeverity DOMErrorType(const XMLDOMMsg::Codes toCheck)
{
if ((toCheck >= W_LowBounds) && (toCheck <= W_HighBounds))
return DOMError::DOM_SEVERITY_WARNING;
else if ((toCheck >= F_LowBounds) && (toCheck <= F_HighBounds))
return DOMError::DOM_SEVERITY_FATAL_ERROR;
else return DOMError::DOM_SEVERITY_ERROR;
}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLDOMMsg();
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,366 @@
/*
* 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: XMLDateTime.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_DATETIME_HPP)
#define XERCESC_INCLUDE_GUARD_XML_DATETIME_HPP
#include <xercesc/util/XMLNumber.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/SchemaDateTimeException.hpp>
#include <xercesc/util/XMLChar.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XSValue;
class XMLUTIL_EXPORT XMLDateTime : public XMLNumber
{
public:
enum valueIndex
{
CentYear = 0,
Month ,
Day ,
Hour ,
Minute ,
Second ,
MiliSecond , //not to be used directly
utc ,
TOTAL_SIZE
};
enum utcType
{
UTC_UNKNOWN = 0,
UTC_STD , // set in parse() or normalize()
UTC_POS , // set in parse()
UTC_NEG // set in parse()
};
// -----------------------------------------------------------------------
// ctors and dtor
// -----------------------------------------------------------------------
XMLDateTime(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XMLDateTime(const XMLCh* const,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~XMLDateTime();
inline void setBuffer(const XMLCh* const);
// -----------------------------------------------------------------------
// Copy ctor and Assignment operators
// -----------------------------------------------------------------------
XMLDateTime(const XMLDateTime&);
XMLDateTime& operator=(const XMLDateTime&);
// -----------------------------------------------------------------------
// Implementation of Abstract Interface
// -----------------------------------------------------------------------
virtual XMLCh* getRawData() const;
virtual const XMLCh* getFormattedString() const;
virtual int getSign() const;
// -----------------------------------------------------------------------
// Canonical Representation
// -----------------------------------------------------------------------
XMLCh* getDateTimeCanonicalRepresentation(MemoryManager* const memMgr) const;
XMLCh* getTimeCanonicalRepresentation(MemoryManager* const memMgr) const;
XMLCh* getDateCanonicalRepresentation(MemoryManager* const memMgr) const;
// -----------------------------------------------------------------------
// parsers
// -----------------------------------------------------------------------
void parseDateTime(); //DateTime
void parseDate(); //Date
void parseTime(); //Time
void parseDay(); //gDay
void parseMonth(); //gMonth
void parseYear(); //gYear
void parseMonthDay(); //gMonthDay
void parseYearMonth(); //gYearMonth
void parseDuration(); //duration
// -----------------------------------------------------------------------
// Comparison
// -----------------------------------------------------------------------
static int compare(const XMLDateTime* const
, const XMLDateTime* const);
static int compare(const XMLDateTime* const
, const XMLDateTime* const
, bool );
static int compareOrder(const XMLDateTime* const
, const XMLDateTime* const);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLDateTime)
private:
// -----------------------------------------------------------------------
// Constant data
// -----------------------------------------------------------------------
//
enum timezoneIndex
{
hh = 0,
mm ,
TIMEZONE_ARRAYSIZE
};
// -----------------------------------------------------------------------
// Comparison
// -----------------------------------------------------------------------
static int compareResult(int
, int
, bool);
static void addDuration(XMLDateTime* pDuration
, const XMLDateTime* const pBaseDate
, int index);
static int compareResult(const XMLDateTime* const
, const XMLDateTime* const
, bool
, int);
static inline int getRetVal(int, int);
// -----------------------------------------------------------------------
// helper
// -----------------------------------------------------------------------
inline void reset();
inline void assertBuffer() const;
inline void copy(const XMLDateTime&);
// allow multiple parsing
inline bool initParser();
inline bool isNormalized() const;
// -----------------------------------------------------------------------
// scaners
// -----------------------------------------------------------------------
void getDate();
void getTime();
void getYearMonth();
void getTimeZone(const XMLSize_t);
void parseTimeZone();
// -----------------------------------------------------------------------
// locator and converter
// -----------------------------------------------------------------------
int findUTCSign(const XMLSize_t start);
int indexOf(const XMLSize_t start
, const XMLSize_t end
, const XMLCh ch) const;
int parseInt(const XMLSize_t start
, const XMLSize_t end) const;
int parseIntYear(const XMLSize_t end) const;
double parseMiliSecond(const XMLSize_t start
, const XMLSize_t end) const;
// -----------------------------------------------------------------------
// validator and normalizer
// -----------------------------------------------------------------------
void validateDateTime() const;
void normalize();
void fillString(XMLCh*& ptr, int value, XMLSize_t expLen) const;
int fillYearString(XMLCh*& ptr, int value) const;
void searchMiliSeconds(XMLCh*& miliStartPtr, XMLCh*& miliEndPtr) const;
// -----------------------------------------------------------------------
// Unimplemented operator ==
// -----------------------------------------------------------------------
bool operator==(const XMLDateTime& toCompare) const;
// -----------------------------------------------------------------------
// Private data members
//
// fValue[]
// object representation of date time.
//
// fTimeZone[]
// temporary storage for normalization
//
// fStart, fEnd
// pointers to the portion of fBuffer being parsed
//
// fBuffer
// raw data to be parsed, own it.
//
// -----------------------------------------------------------------------
int fValue[TOTAL_SIZE];
int fTimeZone[TIMEZONE_ARRAYSIZE];
XMLSize_t fStart;
XMLSize_t fEnd;
XMLSize_t fBufferMaxLen;
double fMilliSecond;
bool fHasTime;
XMLCh* fBuffer;
MemoryManager* fMemoryManager;
friend class XSValue;
};
inline void XMLDateTime::setBuffer(const XMLCh* const aString)
{
reset();
fEnd = XMLString::stringLen(aString);
for (; fEnd > 0; fEnd--)
{
if (!XMLChar1_0::isWhitespace(aString[fEnd - 1]))
break;
}
if (fEnd > 0) {
if (fEnd > fBufferMaxLen)
{
fMemoryManager->deallocate(fBuffer);
fBufferMaxLen = fEnd + 8;
fBuffer = (XMLCh*) fMemoryManager->allocate((fBufferMaxLen+1) * sizeof(XMLCh));
}
memcpy(fBuffer, aString, (fEnd) * sizeof(XMLCh));
fBuffer[fEnd] = '\0';
}
}
inline void XMLDateTime::reset()
{
for ( int i=0; i < TOTAL_SIZE; i++ )
fValue[i] = 0;
fMilliSecond = 0;
fHasTime = false;
fTimeZone[hh] = fTimeZone[mm] = 0;
fStart = fEnd = 0;
if (fBuffer)
*fBuffer = 0;
}
inline void XMLDateTime::copy(const XMLDateTime& rhs)
{
for ( int i = 0; i < TOTAL_SIZE; i++ )
fValue[i] = rhs.fValue[i];
fMilliSecond = rhs.fMilliSecond;
fHasTime = rhs.fHasTime;
fTimeZone[hh] = rhs.fTimeZone[hh];
fTimeZone[mm] = rhs.fTimeZone[mm];
fStart = rhs.fStart;
fEnd = rhs.fEnd;
if (fEnd > 0)
{
if (fEnd > fBufferMaxLen)
{
fMemoryManager->deallocate(fBuffer);//delete[] fBuffer;
fBufferMaxLen = rhs.fBufferMaxLen;
fBuffer = (XMLCh*) fMemoryManager->allocate((fBufferMaxLen+1) * sizeof(XMLCh));
}
memcpy(fBuffer, rhs.fBuffer, (fEnd+1) * sizeof(XMLCh));
}
}
inline bool XMLDateTime::initParser()
{
if (!fBuffer || fBuffer[0] == chNull)
return false;
fStart = 0; // to ensure scan from the very first beginning
// in case the pointer is updated accidentally by
// someone else.
return true;
}
inline bool XMLDateTime::isNormalized() const
{
return ( fValue[utc] == UTC_STD ? true : false );
}
inline int XMLDateTime::getRetVal(int c1, int c2)
{
if ((c1 == LESS_THAN && c2 == GREATER_THAN) ||
(c1 == GREATER_THAN && c2 == LESS_THAN) )
{
return INDETERMINATE;
}
return ( c1 != INDETERMINATE ) ? c1 : c2;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,99 @@
/*
* 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: XMLDouble.hpp 673155 2008-07-01 17:55:39Z dbertoni $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_DOUBLE_HPP)
#define XERCESC_INCLUDE_GUARD_XML_DOUBLE_HPP
#include <xercesc/util/XMLAbstractDoubleFloat.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLDouble : public XMLAbstractDoubleFloat
{
public:
/**
* Constructs a newly allocated <code>XMLDouble</code> object that
* represents the value represented by the string.
*
* @param strValue the <code>String</code> to be converted to an
* <code>XMLDouble</code>.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
* @exception NumberFormatException if the <code>String</code> does not
* contain a parsable XMLDouble.
*/
XMLDouble(const XMLCh* const strValue,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~XMLDouble();
/**
* Compares this object to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is an <code>XMLDouble</code> object that contains
* the same <code>int</code> value as this object.
*
* @param lValue the object to compare with.
* @param rValue the object to compare against.
* @return <code>true</code> if the objects are the same;
* <code>false</code> otherwise.
*/
inline static int compareValues(const XMLDouble* const lValue
, const XMLDouble* const rValue);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLDouble)
XMLDouble(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
protected:
virtual void checkBoundary(char* const strValue);
private:
//
// Unimplemented
//
// copy ctor
// assignment ctor
//
XMLDouble(const XMLDouble& toCopy);
XMLDouble& operator=(const XMLDouble& toAssign);
};
inline int XMLDouble::compareValues(const XMLDouble* const lValue
, const XMLDouble* const rValue)
{
return XMLAbstractDoubleFloat::compareValues((const XMLAbstractDoubleFloat*) lValue,
(const XMLAbstractDoubleFloat*) rValue
, ((XMLAbstractDoubleFloat*)lValue)->getMemoryManager());
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,73 @@
/*
* 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: XMLEBCDICTranscoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLEBCDICTRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLEBCDICTRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XML256TableTranscoder.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple EBCDIC-US transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
// EBCDIC-US is the same as IBM037, CP37, EBCDIC-CP-US, etc...
//
class XMLUTIL_EXPORT XMLEBCDICTranscoder : public XML256TableTranscoder
{
public :
// -----------------------------------------------------------------------
// Public, static methods
// -----------------------------------------------------------------------
static XMLCh xlatThisOne(const XMLByte toXlat);
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLEBCDICTranscoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLEBCDICTranscoder();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLEBCDICTranscoder();
XMLEBCDICTranscoder(const XMLEBCDICTranscoder&);
XMLEBCDICTranscoder& operator=(const XMLEBCDICTranscoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,178 @@
/*
* 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: XMLEntityResolver.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLENTITYRESOLVER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLENTITYRESOLVER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/XMLResourceIdentifier.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class InputSource;
/**
* Revised interface for resolving entities.
*
* <p>If an application needs to implement customized handling
* for external entities, it can implement this interface and
* register an instance with the parser using the parser's
* setXMLEntityResolver method or it can use the basic SAX interface
* (EntityResolver). The difference between the two interfaces is
* the arguments to the resolveEntity() method. With the SAX
* EntityResolve the arguments are systemId and publicId. With this
* interface the argument is a XMLResourceIdentifier object. <i>Only
* one EntityResolver can be set using setEntityResolver() or
* setXMLEntityResolver, if both are set the last one set is
* used.</i></p>
*
* <p>The parser will then allow the application to intercept any
* external entities (including the external DTD subset and external
* parameter entities, if any) before including them.</p>
*
* <p>Many applications will not need to implement this interface,
* but it will be especially useful for applications that build
* XML documents from databases or other specialised input sources,
* or for applications that use URI types other than URLs.</p>
*
* <p>The following resolver would provide the application
* with a special character stream for the entity with the system
* identifier "http://www.myhost.com/today":</p>
*
*<code>
* \#include <xercesc/util/XMLEntityResolver.hpp><br>
* \#include <xercesc/sax/InputSource.hpp><br>
*<br>
*&nbsp;class MyResolver : public XMLEntityResolver {<br>
*&nbsp;&nbsp;public:<br>
*&nbsp;&nbsp;&nbsp;InputSource resolveEntity (XMLResourceIdentifier* xmlri);<br>
*&nbsp;&nbsp;&nbsp;...<br>
*&nbsp;&nbsp;};<br>
*<br>
*&nbsp;MyResolver::resolveEntity(XMLResourceIdentifier* xmlri) {<br>
*&nbsp;&nbsp;switch(xmlri->getResourceIdentifierType()) {<br>
*&nbsp;&nbsp;&nbsp;case XMLResourceIdentifier::SystemId:<br>
*&nbsp;&nbsp;&nbsp;&nbsp;if (XMLString::compareString(xmlri->getSystemId(), "http://www.myhost.com/today")) {<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyReader* reader = new MyReader();<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return new InputSource(reader);<br>
*&nbsp;&nbsp;&nbsp;&nbsp;} else {<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<br>
*&nbsp;&nbsp;&nbsp;&nbsp;}<br>
*&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
*&nbsp;&nbsp;&nbsp;default:<br>
*&nbsp;&nbsp;&nbsp;&nbsp;return null;<br>
*&nbsp;&nbsp;}<br>
*&nbsp;}</code>
*
* <p>The application can also use this interface to redirect system
* identifiers to local URIs or to look up replacements in a catalog
* (possibly by using the public identifier).</p>
*
* <p>The HandlerBase class implements the default behaviour for
* this interface, which is simply always to return null (to request
* that the parser use the default system identifier).</p>
*
* @see XMLResourceIdentifier
* @see Parser#setXMLEntityResolver
* @see InputSource#InputSource
* @see HandlerBase#HandlerBase
*/
class XMLUTIL_EXPORT XMLEntityResolver
{
public:
/** @name Constructors and Destructor */
//@{
/** Destructor */
virtual ~XMLEntityResolver()
{
}
//@}
/** @name The XMLEntityResolver interface */
//@{
/**
* Allow the application to resolve external entities.
*
* <p>The Parser will call this method before opening any external
* entity except the top-level document entity (including the
* external DTD subset, external entities referenced within the
* DTD, and external entities referenced within the document
* element): the application may request that the parser resolve
* the entity itself, that it use an alternative URI, or that it
* use an entirely different input source.</p>
*
* <p>Application writers can use this method to redirect external
* system identifiers to secure and/or local URIs, to look up
* public identifiers in a catalogue, or to read an entity from a
* database or other input source (including, for example, a dialog
* box).</p>
*
* <p>If the system identifier is a URL, the SAX parser must
* resolve it fully before reporting it to the application.</p>
*
* @param resourceIdentifier An object containing the type of
* resource to be resolved and the associated data members
* corresponding to this type.
* @return An InputSource object describing the new input source,
* or null to request that the parser open a regular
* URI connection to the system identifier.
* The returned InputSource is owned by the parser which is
* responsible to clean up the memory.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception IOException An IO exception,
* possibly the result of creating a new InputStream
* or Reader for the InputSource.
*
* @see InputSource#InputSource
* @see XMLResourceIdentifier
*/
virtual InputSource* resolveEntity
(
XMLResourceIdentifier* resourceIdentifier
) = 0;
//@}
protected:
/** Default Constructor */
XMLEntityResolver()
{
}
private :
/* Unimplemented constructors and operators */
/* Copy constructor */
XMLEntityResolver(const XMLEntityResolver&);
/* Assignment operator */
XMLEntityResolver& operator=(const XMLEntityResolver&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,56 @@
/*
* 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: XMLEnumerator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLENUMERATOR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLENUMERATOR_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
template <class TElem> class XMLEnumerator
{
public :
// -----------------------------------------------------------------------
// Destructor
// -----------------------------------------------------------------------
virtual ~XMLEnumerator() {};
// -----------------------------------------------------------------------
// XMLEnumerator interface
// -----------------------------------------------------------------------
virtual bool hasMoreElements() const = 0;
virtual TElem& nextElement() = 0;
virtual void Reset() = 0;
XMLEnumerator() {}
XMLEnumerator(const XMLEnumerator<TElem>&) {}
private:
// -----------------------------------------------------------------------
// Unimplemented operators
// -----------------------------------------------------------------------
XMLEnumerator<TElem>& operator=(const XMLEnumerator<TElem>&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,398 @@
// This file is generated, don't edit it!!
#if !defined(XERCESC_INCLUDE_GUARD_ERRHEADER_XMLExcepts)
#define XERCESC_INCLUDE_GUARD_ERRHEADER_XMLExcepts
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/dom/DOMError.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLExcepts
{
public :
enum Codes
{
NoError = 0
, W_LowBounds = 1
, Scan_CouldNotOpenSource_Warning = 2
, W_HighBounds = 3
, F_LowBounds = 4
, Array_BadIndex = 5
, Array_BadNewSize = 6
, AttrList_BadIndex = 7
, AttDef_BadAttType = 8
, AttDef_BadDefAttType = 9
, Bitset_BadIndex = 10
, Bitset_NotEqualSize = 11
, BufMgr_NoMoreBuffers = 12
, BufMgr_BufferNotInPool = 13
, CPtr_PointerIsZero = 14
, CM_BinOpHadUnaryType = 15
, CM_MustBeMixedOrChildren = 16
, CM_NoPCDATAHere = 17
, CM_UnaryOpHadBinType = 18
, CM_UnknownCMType = 19
, CM_UnknownCMSpecType = 20
, CM_NoParentCSN = 21
, CM_NotValidSpecTypeForNode = 22
, DTD_UnknownCreateReason = 23
, ElemStack_EmptyStack = 24
, ElemStack_StackUnderflow = 25
, ElemStack_NoParentPushed = 26
, Enum_NoMoreElements = 27
, File_CouldNotOpenFile = 28
, File_CouldNotGetCurPos = 29
, File_CouldNotCloseFile = 30
, File_CouldNotSeekToEnd = 31
, File_CouldNotSeekToPos = 32
, File_CouldNotDupHandle = 33
, File_CouldNotReadFromFile = 34
, File_CouldNotWriteToFile = 35
, File_CouldNotResetFile = 36
, File_CouldNotGetSize = 37
, File_CouldNotGetBasePathName = 38
, Gen_ParseInProgress = 39
, Gen_NoDTDValidator = 40
, Gen_CouldNotOpenDTD = 41
, Gen_CouldNotOpenExtEntity = 42
, Gen_UnexpectedEOF = 43
, HshTbl_ZeroModulus = 44
, HshTbl_BadHashFromKey = 45
, HshTbl_NoSuchKeyExists = 46
, Mutex_CouldNotDestroy = 47
, NetAcc_InternalError = 48
, NetAcc_LengthError = 49
, NetAcc_InitFailed = 50
, NetAcc_TargetResolution = 51
, NetAcc_CreateSocket = 52
, NetAcc_ConnSocket = 53
, NetAcc_WriteSocket = 54
, NetAcc_ReadSocket = 55
, NetAcc_UnsupportedMethod = 56
, Pool_ElemAlreadyExists = 57
, Pool_InvalidId = 58
, Pool_ZeroModulus = 59
, RdrMgr_ReaderIdNotFound = 60
, Reader_BadAutoEncoding = 61
, Reader_CouldNotDecodeFirstLine = 62
, Reader_NelLsepinDecl = 63
, Reader_SrcOfsNotSupported = 64
, Reader_EncodingStrRequired = 65
, Scan_CouldNotOpenSource = 66
, Scan_UnbalancedStartEnd = 67
, Scan_BadPScanToken = 68
, Stack_BadIndex = 69
, Stack_EmptyStack = 70
, Str_ZeroSizedTargetBuf = 71
, Str_UnknownRadix = 72
, Str_TargetBufTooSmall = 73
, Str_StartIndexPastEnd = 74
, Str_ConvertOverflow = 75
, StrPool_IllegalId = 76
, Trans_Unrepresentable = 77
, Trans_BadSrcSeq = 78
, Trans_BadSrcCP = 79
, Trans_BadTrailingSurrogate = 80
, Trans_CantCreateCvtrFor = 81
, URL_MalformedURL = 82
, URL_UnsupportedProto = 83
, URL_UnsupportedProto1 = 84
, URL_NoProtocolPresent = 85
, URL_ExpectingTwoSlashes = 86
, URL_RelativeBaseURL = 87
, URL_BadPortField = 88
, UTF8_FormatError = 89
, UTF8_Invalid_3BytesSeq = 90
, UTF8_Irregular_3BytesSeq = 91
, UTF8_Invalid_4BytesSeq = 92
, UTF8_Exceeds_BytesLimit = 93
, Vector_BadIndex = 94
, Val_InvalidElemId = 95
, Val_CantHaveIntSS = 96
, XMLRec_UnknownEncoding = 97
, Parser_Parse1 = 98
, Parser_Parse2 = 99
, Parser_Next1 = 100
, Parser_Next2 = 101
, Parser_Next3 = 102
, Parser_Next4 = 103
, Parser_Factor1 = 104
, Parser_Factor2 = 105
, Parser_Factor3 = 106
, Parser_Factor4 = 107
, Parser_Factor5 = 108
, Parser_Factor6 = 109
, Parser_Atom1 = 110
, Parser_Atom2 = 111
, Parser_Atom3 = 112
, Parser_Atom4 = 113
, Parser_Atom5 = 114
, Parser_CC1 = 115
, Parser_CC2 = 116
, Parser_CC3 = 117
, Parser_CC5 = 118
, Parser_CC6 = 119
, Parser_Ope1 = 120
, Parser_Ope2 = 121
, Parser_Ope3 = 122
, Parser_Descape1 = 123
, Parser_Descape3 = 124
, Parser_Descape4 = 125
, Parser_Descape5 = 126
, Parser_Process2 = 127
, Parser_Quantifier1 = 128
, Parser_Quantifier2 = 129
, Parser_Quantifier3 = 130
, Parser_Quantifier4 = 131
, Parser_Quantifier5 = 132
, Gen_NoSchemaValidator = 133
, SubGrpComparator_NGR = 134
, FACET_Invalid_Len = 135
, FACET_Invalid_maxLen = 136
, FACET_Invalid_minLen = 137
, FACET_NonNeg_Len = 138
, FACET_NonNeg_maxLen = 139
, FACET_NonNeg_minLen = 140
, FACET_Len_maxLen = 141
, FACET_Len_minLen = 142
, FACET_maxLen_minLen = 143
, FACET_Invalid_Tag = 144
, FACET_Len_baseLen = 145
, FACET_minLen_baseminLen = 146
, FACET_minLen_basemaxLen = 147
, FACET_maxLen_basemaxLen = 148
, FACET_maxLen_baseminLen = 149
, FACET_Len_baseMinLen = 150
, FACET_Len_baseMaxLen = 151
, FACET_minLen_baseLen = 152
, FACET_maxLen_baseLen = 153
, FACET_enum_base = 154
, FACET_Invalid_WS = 155
, FACET_WS_collapse = 156
, FACET_WS_replace = 157
, FACET_Invalid_MaxIncl = 158
, FACET_Invalid_MaxExcl = 159
, FACET_Invalid_MinIncl = 160
, FACET_Invalid_MinExcl = 161
, FACET_Invalid_TotalDigit = 162
, FACET_Invalid_FractDigit = 163
, FACET_PosInt_TotalDigit = 164
, FACET_NonNeg_FractDigit = 165
, FACET_max_Incl_Excl = 166
, FACET_min_Incl_Excl = 167
, FACET_maxExcl_minExcl = 168
, FACET_maxExcl_minIncl = 169
, FACET_maxIncl_minExcl = 170
, FACET_maxIncl_minIncl = 171
, FACET_TotDigit_FractDigit = 172
, FACET_maxIncl_base_maxExcl = 173
, FACET_maxIncl_base_maxIncl = 174
, FACET_maxIncl_base_minIncl = 175
, FACET_maxIncl_base_minExcl = 176
, FACET_maxExcl_base_maxExcl = 177
, FACET_maxExcl_base_maxIncl = 178
, FACET_maxExcl_base_minIncl = 179
, FACET_maxExcl_base_minExcl = 180
, FACET_minExcl_base_maxExcl = 181
, FACET_minExcl_base_maxIncl = 182
, FACET_minExcl_base_minIncl = 183
, FACET_minExcl_base_minExcl = 184
, FACET_minIncl_base_maxExcl = 185
, FACET_minIncl_base_maxIncl = 186
, FACET_minIncl_base_minIncl = 187
, FACET_minIncl_base_minExcl = 188
, FACET_maxIncl_notFromBase = 189
, FACET_maxExcl_notFromBase = 190
, FACET_minIncl_notFromBase = 191
, FACET_minExcl_notFromBase = 192
, FACET_totalDigit_base_totalDigit = 193
, FACET_fractDigit_base_totalDigit = 194
, FACET_fractDigit_base_fractDigit = 195
, FACET_maxIncl_base_fixed = 196
, FACET_maxExcl_base_fixed = 197
, FACET_minIncl_base_fixed = 198
, FACET_minExcl_base_fixed = 199
, FACET_totalDigit_base_fixed = 200
, FACET_fractDigit_base_fixed = 201
, FACET_maxLen_base_fixed = 202
, FACET_minLen_base_fixed = 203
, FACET_whitespace_base_fixed = 204
, FACET_internalError_fixed = 205
, FACET_List_Null_baseValidator = 206
, FACET_Union_Null_memberTypeValidators = 207
, FACET_Union_Null_baseValidator = 208
, FACET_Union_invalid_baseValidatorType = 209
, VALUE_NotMatch_Pattern = 210
, VALUE_Not_Base64 = 211
, VALUE_Not_HexBin = 212
, VALUE_GT_maxLen = 213
, VALUE_LT_minLen = 214
, VALUE_NE_Len = 215
, VALUE_NotIn_Enumeration = 216
, VALUE_exceed_totalDigit = 217
, VALUE_exceed_fractDigit = 218
, VALUE_exceed_maxIncl = 219
, VALUE_exceed_maxExcl = 220
, VALUE_exceed_minIncl = 221
, VALUE_exceed_minExcl = 222
, VALUE_WS_replaced = 223
, VALUE_WS_collapsed = 224
, VALUE_Invalid_NCName = 225
, VALUE_Invalid_Name = 226
, VALUE_ID_Not_Unique = 227
, VALUE_ENTITY_Invalid = 228
, VALUE_QName_Invalid = 229
, VALUE_NOTATION_Invalid = 230
, VALUE_no_match_memberType = 231
, VALUE_URI_Malformed = 232
, XMLNUM_emptyString = 233
, XMLNUM_WSString = 234
, XMLNUM_2ManyDecPoint = 235
, XMLNUM_Inv_chars = 236
, XMLNUM_null_ptr = 237
, XMLNUM_URI_Component_Empty = 238
, XMLNUM_URI_Component_for_GenURI_Only = 239
, XMLNUM_URI_Component_Invalid_EscapeSequence = 240
, XMLNUM_URI_Component_Invalid_Char = 241
, XMLNUM_URI_Component_Set_Null = 242
, XMLNUM_URI_Component_Not_Conformant = 243
, XMLNUM_URI_No_Scheme = 244
, XMLNUM_URI_NullHost = 245
, XMLNUM_URI_NullPath = 246
, XMLNUM_URI_PortNo_Invalid = 247
, XMLNUM_DBL_FLT_InvalidType = 248
, Regex_Result_Not_Set = 249
, Regex_CompactRangesError = 250
, Regex_MergeRangesTypeMismatch = 251
, Regex_SubtractRangesError = 252
, Regex_IntersectRangesError = 253
, Regex_ComplementRangesInvalidArg = 254
, Regex_InvalidCategoryName = 255
, Regex_KeywordNotFound = 256
, Regex_BadRefNo = 257
, Regex_UnknownOption = 258
, Regex_UnknownTokenType = 259
, Regex_RangeTokenGetError = 260
, Regex_NotSupported = 261
, Regex_InvalidChildIndex = 262
, Regex_RepPatMatchesZeroString = 263
, Regex_InvalidRepPattern = 264
, NEL_RepeatedCalls = 265
, Out_Of_Memory = 266
, DV_InvalidOperation = 267
, XPath_NoAttrSelector = 268
, XPath_NoUnionAtStart = 269
, XPath_NoMultipleUnion = 270
, XPath_MissingAttr = 271
, XPath_ExpectedToken1 = 272
, XPath_PrefixNoURI = 273
, XPath_NoDoubleColon = 274
, XPath_ExpectedStep1 = 275
, XPath_ExpectedStep2 = 276
, XPath_ExpectedStep3 = 277
, XPath_NoForwardSlash = 278
, XPath_NoDoubleForwardSlash = 279
, XPath_NoForwardSlashAtStart = 280
, XPath_NoSelectionOfRoot = 281
, XPath_EmptyExpr = 282
, XPath_NoUnionAtEnd = 283
, XPath_InvalidChar = 284
, XPath_TokenNotSupported = 285
, XPath_FindSolution = 286
, DateTime_dt_invalid = 287
, DateTime_dt_missingT = 288
, DateTime_gDay_invalid = 289
, DateTime_gMth_invalid = 290
, DateTime_gMthDay_invalid = 291
, DateTime_dur_invalid = 292
, DateTime_dur_Start_dashP = 293
, DateTime_dur_noP = 294
, DateTime_dur_DashNotFirst = 295
, DateTime_dur_inv_b4T = 296
, DateTime_dur_NoTimeAfterT = 297
, DateTime_dur_NoElementAtAll = 298
, DateTime_dur_inv_seconds = 299
, DateTime_date_incomplete = 300
, DateTime_date_invalid = 301
, DateTime_time_incomplete = 302
, DateTime_time_invalid = 303
, DateTime_ms_noDigit = 304
, DateTime_ym_incomplete = 305
, DateTime_ym_invalid = 306
, DateTime_year_invalid = 307
, DateTime_year_tooShort = 308
, DateTime_year_leadingZero = 309
, DateTime_ym_noMonth = 310
, DateTime_tz_noUTCsign = 311
, DateTime_tz_stuffAfterZ = 312
, DateTime_tz_invalid = 313
, DateTime_year_zero = 314
, DateTime_mth_invalid = 315
, DateTime_day_invalid = 316
, DateTime_hour_invalid = 317
, DateTime_min_invalid = 318
, DateTime_second_invalid = 319
, DateTime_tz_hh_invalid = 320
, PD_EmptyBase = 321
, PD_NSCompat1 = 322
, PD_OccurRangeE = 323
, PD_NameTypeOK1 = 324
, PD_NameTypeOK2 = 325
, PD_NameTypeOK3 = 326
, PD_NameTypeOK4 = 327
, PD_NameTypeOK5 = 328
, PD_NameTypeOK6 = 329
, PD_NameTypeOK7 = 330
, PD_Recurse1 = 331
, PD_Recurse2 = 332
, PD_ForbiddenRes1 = 333
, PD_ForbiddenRes2 = 334
, PD_ForbiddenRes3 = 335
, PD_ForbiddenRes4 = 336
, PD_NSSubset1 = 337
, PD_NSSubset2 = 338
, PD_NSRecurseCheckCardinality1 = 339
, PD_RecurseUnordered = 340
, PD_MapAndSum = 341
, PD_InvalidContentType = 342
, NodeIDMap_GrowErr = 343
, XSer_ProtoType_Null_ClassName = 344
, XSer_ProtoType_NameLen_Dif = 345
, XSer_ProtoType_Name_Dif = 346
, XSer_InStream_Read_LT_Req = 347
, XSer_InStream_Read_OverFlow = 348
, XSer_Storing_Violation = 349
, XSer_StoreBuffer_Violation = 350
, XSer_LoadPool_UppBnd_Exceed = 351
, XSer_LoadPool_NoTally_ObjCnt = 352
, XSer_Loading_Violation = 353
, XSer_LoadBuffer_Violation = 354
, XSer_Inv_ClassIndex = 355
, XSer_Inv_checkFillBuffer_Size = 356
, XSer_Inv_checkFlushBuffer_Size = 357
, XSer_Inv_Null_Pointer = 358
, XSer_CreateObject_Fail = 359
, XSer_ObjCount_UppBnd_Exceed = 360
, XSer_GrammarPool_Empty = 361
, XSer_GrammarPool_NotEmpty = 362
, XSer_StringPool_NotEmpty = 363
, XSer_Storer_Loader_Mismatch = 364
, VALUE_QName_Invalid2 = 365
, F_HighBounds = 366
, E_LowBounds = 367
, E_HighBounds = 368
};
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLExcepts();
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,276 @@
/*
* 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: XMLException.hpp 673960 2008-07-04 08:50:12Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_XMLEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/XMLExceptMsgs.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/framework/XMLErrorReporter.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// This is the base class from which all the XML parser exceptions are
// derived. The virtual interface is very simple and most of the functionality
// is in this class.
//
// Because all derivatives are EXACTLY the same except for the static
// string that is used to hold the name of the class, a macro is provided
// below via which they are all created.
// ---------------------------------------------------------------------------
class XMLUTIL_EXPORT XMLException : public XMemory
{
public:
// -----------------------------------------------------------------------
// Virtual Destructor
// -----------------------------------------------------------------------
virtual ~XMLException();
// -----------------------------------------------------------------------
// The XML exception virtual interface
// -----------------------------------------------------------------------
virtual const XMLCh* getType() const = 0;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLExcepts::Codes getCode() const;
const XMLCh* getMessage() const;
const char* getSrcFile() const;
XMLFileLoc getSrcLine() const;
XMLErrorReporter::ErrTypes getErrorType() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setPosition(const char* const file, const XMLFileLoc line);
// -----------------------------------------------------------------------
// Hidden constructors and operators
//
// NOTE: Technically, these should be protected, since this is a
// base class that is never used directly. However, VC++ 6.0 will
// fail to catch via a reference to base class if the ctors are
// not public!! This seems to have been caused by the install
// of IE 5.0.
// -----------------------------------------------------------------------
XMLException();
XMLException(const char* const srcFile, const XMLFileLoc srcLine, MemoryManager* const memoryManager = 0);
XMLException(const XMLException& toCopy);
XMLException& operator=(const XMLException& toAssign);
protected :
// -----------------------------------------------------------------------
// Protected methods
// -----------------------------------------------------------------------
void loadExceptText
(
const XMLExcepts::Codes toLoad
);
void loadExceptText
(
const XMLExcepts::Codes toLoad
, const XMLCh* const text1
, const XMLCh* const text2 = 0
, const XMLCh* const text3 = 0
, const XMLCh* const text4 = 0
);
void loadExceptText
(
const XMLExcepts::Codes toLoad
, const char* const text1
, const char* const text2 = 0
, const char* const text3 = 0
, const char* const text4 = 0
);
private :
// -----------------------------------------------------------------------
// Data members
//
// fCode
// The error code that this exception represents.
//
// fSrcFile
// fSrcLine
// These are the file and line information from the source where the
// exception was thrown from.
//
// fMsg
// The loaded message text for this exception.
// -----------------------------------------------------------------------
XMLExcepts::Codes fCode;
char* fSrcFile;
XMLFileLoc fSrcLine;
XMLCh* fMsg;
protected:
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XMLException: Getter methods
// ---------------------------------------------------------------------------
inline XMLExcepts::Codes XMLException::getCode() const
{
return fCode;
}
inline const XMLCh* XMLException::getMessage() const
{
return fMsg;
}
inline const char* XMLException::getSrcFile() const
{
if (!fSrcFile)
return "";
return fSrcFile;
}
inline XMLFileLoc XMLException::getSrcLine() const
{
return fSrcLine;
}
inline XMLErrorReporter::ErrTypes XMLException::getErrorType() const
{
if ((fCode >= XMLExcepts::W_LowBounds) && (fCode <= XMLExcepts::W_HighBounds))
return XMLErrorReporter::ErrType_Warning;
else if ((fCode >= XMLExcepts::F_LowBounds) && (fCode <= XMLExcepts::F_HighBounds))
return XMLErrorReporter::ErrType_Fatal;
else if ((fCode >= XMLExcepts::E_LowBounds) && (fCode <= XMLExcepts::E_HighBounds))
return XMLErrorReporter::ErrType_Error;
return XMLErrorReporter::ErrTypes_Unknown;
}
// ---------------------------------------------------------------------------
// This macro is used to create derived classes. They are all identical
// except the name of the exception, so it crazy to type them in over and
// over.
// ---------------------------------------------------------------------------
#define MakeXMLException(theType, expKeyword) \
class expKeyword theType : public XMLException \
{ \
public: \
\
theType(const char* const srcFile \
, const XMLFileLoc srcLine \
, const XMLExcepts::Codes toThrow \
, MemoryManager* memoryManager = 0) : \
XMLException(srcFile, srcLine, memoryManager) \
{ \
loadExceptText(toThrow); \
} \
\
theType(const theType& toCopy) : \
\
XMLException(toCopy) \
{ \
} \
\
theType(const char* const srcFile \
, const XMLFileLoc srcLine \
, const XMLExcepts::Codes toThrow \
, const XMLCh* const text1 \
, const XMLCh* const text2 = 0 \
, const XMLCh* const text3 = 0 \
, const XMLCh* const text4 = 0 \
, MemoryManager* memoryManager = 0) : \
XMLException(srcFile, srcLine, memoryManager) \
{ \
loadExceptText(toThrow, text1, text2, text3, text4); \
} \
\
theType(const char* const srcFile \
, const XMLFileLoc srcLine \
, const XMLExcepts::Codes toThrow \
, const char* const text1 \
, const char* const text2 = 0 \
, const char* const text3 = 0 \
, const char* const text4 = 0 \
, MemoryManager* memoryManager = 0) : \
XMLException(srcFile, srcLine, memoryManager) \
{ \
loadExceptText(toThrow, text1, text2, text3, text4); \
} \
\
virtual ~theType() {} \
\
theType& operator=(const theType& toAssign) \
{ \
XMLException::operator=(toAssign); \
return *this; \
} \
\
virtual XMLException* duplicate() const \
{ \
return new (fMemoryManager) theType(*this); \
} \
\
virtual const XMLCh* getType() const \
{ \
return XMLUni::fg##theType##_Name; \
} \
\
private : \
theType(); \
};
// ---------------------------------------------------------------------------
// This macros is used to actually throw an exception. It is used in order
// to make sure that source code line/col info is stored correctly, and to
// give flexibility for other stuff in the future.
// ---------------------------------------------------------------------------
#define ThrowXML(type,code) throw type(__FILE__, __LINE__, code)
#define ThrowXML1(type,code,p1) throw type(__FILE__, __LINE__, code, p1)
#define ThrowXML2(type,code,p1,p2) throw type(__FILE__, __LINE__, code, p1, p2)
#define ThrowXML3(type,code,p1,p2,p3) throw type(__FILE__, __LINE__, code, p1, p2, p3)
#define ThrowXML4(type,code,p1,p2,p3,p4) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4)
#define ThrowXMLwithMemMgr(type,code,memMgr) throw type(__FILE__, __LINE__, code, memMgr)
#define ThrowXMLwithMemMgr1(type,code,p1,memMgr) throw type(__FILE__, __LINE__, code, p1, 0, 0, 0, memMgr)
#define ThrowXMLwithMemMgr2(type,code,p1,p2,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, 0, 0, memMgr)
#define ThrowXMLwithMemMgr3(type,code,p1,p2,p3,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, p3, 0, memMgr)
#define ThrowXMLwithMemMgr4(type,code,p1,p2,p3,p4,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4, memMgr)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,63 @@
/*
* 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: XMLFileMgr.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLFILEMGR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLFILEMGR_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef void* FileHandle;
#define XERCES_Invalid_File_Handle 0
// Abstract class for files. This is be used to allow multiple file handling implementations.
class XMLFileMgr : public XMemory
{
public:
XMLFileMgr() {}
virtual ~XMLFileMgr() {}
// File access
virtual FileHandle fileOpen(const XMLCh* path, bool toWrite, MemoryManager* const manager) = 0;
virtual FileHandle fileOpen(const char* path, bool toWrite, MemoryManager* const manager) = 0;
virtual FileHandle openStdIn(MemoryManager* const manager) = 0;
virtual void fileClose(FileHandle f, MemoryManager* const manager) = 0;
virtual void fileReset(FileHandle f, MemoryManager* const manager) = 0;
virtual XMLFilePos curPos(FileHandle f, MemoryManager* const manager) = 0;
virtual XMLFilePos fileSize(FileHandle f, MemoryManager* const manager) = 0;
virtual XMLSize_t fileRead(FileHandle f, XMLSize_t byteCount, XMLByte* buffer, MemoryManager* const manager) = 0;
virtual void fileWrite(FileHandle f, XMLSize_t byteCount, const XMLByte* buffer, MemoryManager* const manager) = 0;
// Ancillary path handling routines
virtual XMLCh* getFullPath(const XMLCh* const srcPath, MemoryManager* const manager) = 0;
virtual XMLCh* getCurrentDirectory(MemoryManager* const manager) = 0;
virtual bool isRelative(const XMLCh* const toCheck, MemoryManager* const manager) = 0;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,97 @@
/*
* 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: XMLFloat.hpp 673155 2008-07-01 17:55:39Z dbertoni $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_FLOAT_HPP)
#define XERCESC_INCLUDE_GUARD_XML_FLOAT_HPP
#include <xercesc/util/XMLAbstractDoubleFloat.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLFloat : public XMLAbstractDoubleFloat
{
public:
/**
* Constructs a newly allocated <code>XMLFloat</code> object that
* represents the value represented by the string.
*
* @param strValue the <code>String</code> to be converted to an
* <code>XMLFloat</code>.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
* @exception NumberFormatException if the <code>String</code> does not
* contain a parsable XMLFloat.
*/
XMLFloat(const XMLCh* const strValue,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~XMLFloat();
/**
* Compares the two specified XMLFloat objects.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and that contains the same <code>int</code> value.
*
* @param lValue the object to compare with.
* @param rValue the object to compare against.
* @return <code>true</code> if the objects are the same;
* <code>false</code> otherwise.
*/
inline static int compareValues(const XMLFloat* const lValue
, const XMLFloat* const rValue);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLFloat)
XMLFloat(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
protected:
virtual void checkBoundary(char* const strValue);
private:
//
// Unimplemented
//
// copy ctor
// assignment ctor
//
XMLFloat(const XMLFloat& toCopy);
XMLFloat& operator=(const XMLFloat& toAssign);
};
inline int XMLFloat::compareValues(const XMLFloat* const lValue
, const XMLFloat* const rValue)
{
return XMLAbstractDoubleFloat::compareValues((const XMLAbstractDoubleFloat*) lValue,
(const XMLAbstractDoubleFloat*) rValue
, ((XMLAbstractDoubleFloat*)lValue)->getMemoryManager());
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,72 @@
/*
* 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: XMLIBM1047Transcoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLIBM1047TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLIBM1047TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XML256TableTranscoder.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple 1047-US transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
//
class XMLUTIL_EXPORT XMLIBM1047Transcoder : public XML256TableTranscoder
{
public :
// -----------------------------------------------------------------------
// Public, static methods
// -----------------------------------------------------------------------
static XMLCh xlatThisOne(const XMLByte toXlat);
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLIBM1047Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLIBM1047Transcoder();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLIBM1047Transcoder();
XMLIBM1047Transcoder(const XMLIBM1047Transcoder&);
void operator=(const XMLIBM1047Transcoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,71 @@
/*
* 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: XMLIBM1140Transcoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLIBM1140TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLIBM1140TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XML256TableTranscoder.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple IBM-1140 transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
class XMLUTIL_EXPORT XMLIBM1140Transcoder : public XML256TableTranscoder
{
public :
// -----------------------------------------------------------------------
// Public, static methods
// -----------------------------------------------------------------------
static XMLCh xlatThisOne(const XMLByte toXlat);
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLIBM1140Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLIBM1140Transcoder();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLIBM1140Transcoder();
XMLIBM1140Transcoder(const XMLIBM1140Transcoder&);
XMLIBM1140Transcoder& operator=(const XMLIBM1140Transcoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,157 @@
/*
* 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: XMLInitializer.hpp 695427 2008-09-15 11:05:36Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLINITIALIZER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLINITIALIZER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Utilities that must be implemented in a class-specific way.
*
* This class contains methods that must be implemented by different
* classes that have static data (class or local) that they need
* to initialize when XMLPlatformUtils::Initialize is invoked.
*/
class XMLUTIL_EXPORT XMLInitializer
{
protected :
/** @name Initialization methods */
//@{
/** Perform per-class allocationa and initialization of static data
*
* These functions should be called from XMLPlatformUtils::Initialize.
*/
static void initializeTransService();
static void initializeStaticData();
/** Perform per-class release of static data
*
* These functions should be called from XMLPlatformUtils::Terminate.
*/
static void terminateStaticData();
static void terminateTransService();
//@}
friend class XMLPlatformUtils;
private :
XMLInitializer();
XMLInitializer(const XMLInitializer& toCopy);
XMLInitializer& operator=(const XMLInitializer&);
private:
// Note: The name of each function should be in the form
// initialize<class-name>.
//
// Note: In some cases order of initialization is important.
//
//
// Initialize
//
// Core
//
static void initializeEncodingValidator();
static void initializeXMLException();
static void initializeXMLScanner();
static void initializeXMLValidator();
// Regex
//
static void initializeRangeTokenMap();
static void initializeRegularExpression();
// DTD
//
static void initializeDTDGrammar();
// Schema
//
static void initializeXSDErrorReporter();
static void initializeDatatypeValidatorFactory();
static void initializeGeneralAttributeCheck();
static void initializeXSValue();
static void initializeComplexTypeInfo();
// DOM
//
static void initializeDOMImplementationRegistry();
static void initializeDOMImplementationImpl();
static void initializeDOMDocumentTypeImpl();
static void initializeDOMNodeListImpl();
static void initializeDOMNormalizer();
//
// Terminate
//
// Core
//
static void terminateEncodingValidator();
static void terminateXMLException();
static void terminateXMLScanner();
static void terminateXMLValidator();
// Regex
//
static void terminateRangeTokenMap();
static void terminateRegularExpression();
// DTD
//
static void terminateDTDGrammar();
// Schema
//
static void terminateXSDErrorReporter();
static void terminateDatatypeValidatorFactory();
static void terminateGeneralAttributeCheck();
static void terminateXSValue();
static void terminateComplexTypeInfo();
// DOM
//
static void terminateDOMImplementationRegistry();
static void terminateDOMImplementationImpl();
static void terminateDOMDocumentTypeImpl();
static void terminateDOMNodeListImpl();
static void terminateDOMNormalizer();
//
// Extra initialization.
//
static void initializeDOMHeap (XMLSize_t initialHeapAllocSize,
XMLSize_t maxHeapAllocSize,
XMLSize_t maxSubAllocationSize);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,82 @@
/*
* 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: XMLInteger.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XML_INTEGER_HPP)
#define XERCESC_INCLUDE_GUARD_XML_INTEGER_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLInteger : public XMemory
{
public:
/**
* Constructs a newly allocated <code>XMLInteger</code> object
*
* @param intVal the <code>integer</code>
*/
XMLInteger(const int intVal);
~XMLInteger();
/**
* Returns the built in integer value.
*/
int intValue() const;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLInteger(const XMLInteger&);
XMLInteger& operator=(const XMLInteger&);
// -----------------------------------------------------------------------
// Private data members
//
// fData
// the value
//
// -----------------------------------------------------------------------
int fData;
};
inline XMLInteger::XMLInteger(const int intVal)
:fData(intVal)
{
}
inline XMLInteger::~XMLInteger()
{
}
inline int XMLInteger::intValue() const
{
return fData;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,182 @@
/*
* 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: XMLMsgLoader.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLMSGLOADER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLMSGLOADER_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This header defines an abstract message loading API. This is the API via
// which the parser system loads translatable text, and there can be multiple
// actual implementations of this mechanism. The API is very simple because
// there can be many kinds of underlying systems on which implementations are
// based and we don't want to get into portability trouble by being overly
// smart.
//
// Each instance of the message loader loads a file of messages, which are
// accessed by key and which are associated with a particular language. The
// actual source information may be in many forms, but by the time it is
// extracted for use it will be in Unicode format. The language is always
// the default language for the local machine.
//
// Msg loader derivatives are not required to be thread safe. The parser will
// never use a single instance in more than one thread.
//
class XMLUTIL_EXPORT XMLMsgLoader : public XMemory
{
public :
// -----------------------------------------------------------------------
// Class specific types
//
// XMLMsgId
// A simple typedef to give us flexibility about the representation
// of a message id.
// -----------------------------------------------------------------------
typedef unsigned int XMLMsgId;
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
virtual ~XMLMsgLoader();
// -----------------------------------------------------------------------
// The virtual message loader API
// -----------------------------------------------------------------------
virtual bool loadMsg
(
const XMLMsgId msgToLoad
, XMLCh* const toFill
, const XMLSize_t maxChars
) = 0;
virtual bool loadMsg
(
const XMLMsgId msgToLoad
, XMLCh* const toFill
, const XMLSize_t maxChars
, const XMLCh* const repText1
, const XMLCh* const repText2 = 0
, const XMLCh* const repText3 = 0
, const XMLCh* const repText4 = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) = 0;
virtual bool loadMsg
(
const XMLMsgId msgToLoad
, XMLCh* const toFill
, const XMLSize_t maxChars
, const char* const repText1
, const char* const repText2 = 0
, const char* const repText3 = 0
, const char* const repText4 = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) = 0;
/** @name Locale Handling */
//@{
/**
* This function enables set the locale information which
* all concrete message loaders shall refer to during instantiation.
*
* Note: for detailed discussion, refer to PlatformUtils::initialize()
*/
static void setLocale(const char* const localeToAdopt);
/**
* For the derived to retrieve locale info during construction
*/
static const char* getLocale();
//@}
/** @name NLSHome Handling */
//@{
/**
* This function enables set the NLSHome information which
* all concrete message loaders shall refer to during instantiation.
*
* Note: for detailed discussion, refer to PlatformUtils::initialize()
*/
static void setNLSHome(const char* const nlsHomeToAdopt);
/**
* For the derived to retrieve NLSHome info during construction
*/
static const char* getNLSHome();
//@}
protected :
// -----------------------------------------------------------------------
// Hidden Constructors
// -----------------------------------------------------------------------
XMLMsgLoader();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLMsgLoader(const XMLMsgLoader&);
XMLMsgLoader& operator=(const XMLMsgLoader&);
// -----------------------------------------------------------------------
// Private data members
//
// fLocale
// Locale info set through PlatformUtils::init().
// The derived class may refer to this for locale information.
//
// fPath
// NLSHome info set through PlatformUtils::init().
// The derived class may refer to this for NLSHome information.
//
// -----------------------------------------------------------------------
static char* fLocale;
static char* fPath;
};
// ---------------------------------------------------------------------------
// XMLMsgLoader: Public Constructors and Destructor
// ---------------------------------------------------------------------------
inline XMLMsgLoader::~XMLMsgLoader()
{
}
// ---------------------------------------------------------------------------
// XMLMsgLoader: Hidden Constructors
// ---------------------------------------------------------------------------
inline XMLMsgLoader::XMLMsgLoader()
{
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,50 @@
/*
* 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: XMLMutexMgr.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLMUTEXMGR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLMUTEXMGR_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef void* XMLMutexHandle;
// Abstract class for mutex implementation.
// This is be used to allow multiple mutex handling implementations.
class XMLMutexMgr : public XMemory
{
public:
XMLMutexMgr() {}
virtual ~XMLMutexMgr() {}
// Mutex operations
virtual XMLMutexHandle create(MemoryManager* const manager) = 0;
virtual void destroy(XMLMutexHandle mtx, MemoryManager* const manager) = 0;
virtual void lock(XMLMutexHandle mtx) = 0;
virtual void unlock(XMLMutexHandle mtx) = 0;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,139 @@
/*
* 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: XMLNetAccessor.hpp 673960 2008-07-04 08:50:12Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLNETACCESSOR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLNETACCESSOR_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLURL.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class BinInputStream;
// This class holds advanced informations about the HTTP connection
class XMLUTIL_EXPORT XMLNetHTTPInfo
{
public:
XMLNetHTTPInfo();
typedef enum {
GET,
PUT,
POST
} HTTPMethod;
// -----------------------------------------------------------------------
// Data members
//
// fHTTPMethod
// The type of the HTTP request
//
// fHeaders
// The extra headers that will be sent as part of the request; the format is
// Header1: Value\r\nHeader2: Value\r\n
//
// fHeadersLen
// The length of the string pointed by fHeaders, in bytes
//
// fPayload
// The extra data that will be sent after the headers; in the case of a PUT
// operation, this is the content of the resource being posted. It can be binary data
//
// fPayloadLen
// The length of the binary buffer pointed by fPayload, in bytes
//
HTTPMethod fHTTPMethod;
const char* fHeaders;
XMLSize_t fHeadersLen;
const char* fPayload;
XMLSize_t fPayloadLen;
};
inline XMLNetHTTPInfo::XMLNetHTTPInfo()
:fHTTPMethod(XMLNetHTTPInfo::GET),
fHeaders(0),
fHeadersLen(0),
fPayload(0),
fPayloadLen(0)
{
}
//
// This class is an abstract interface via which the URL class accesses
// net access services. When any source URL is not in effect a local file
// path, then the URL class is used to look at it. Then the URL class can
// be asked to make a binary input stream via which the referenced resource
// can be read in.
//
// The URL class will use an object derived from this class to create a
// binary stream for the URL to return. The object it uses is provided by
// the platform utils, and is actually provided by the per-platform init
// code so each platform can decide what actual implementation it wants to
// use.
//
class XMLUTIL_EXPORT XMLNetAccessor : public XMemory
{
public :
// -----------------------------------------------------------------------
// Virtual destructor
// -----------------------------------------------------------------------
virtual ~XMLNetAccessor()
{
}
// -----------------------------------------------------------------------
// The virtual net accessor interface
// -----------------------------------------------------------------------
virtual const XMLCh* getId() const = 0;
virtual BinInputStream* makeNew
(
const XMLURL& urlSrc,
const XMLNetHTTPInfo* httpInfo=0
) = 0;
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
XMLNetAccessor()
{
}
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLNetAccessor(const XMLNetAccessor&);
XMLNetAccessor& operator=(const XMLNetAccessor&);
};
MakeXMLException(NetAccessorException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,102 @@
/*
* 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: XMLNumber.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLNUMBER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLNUMBER_HPP
#include <xercesc/internal/XSerializable.hpp>
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLNumber : public XSerializable, public XMemory
{
public:
enum
{
LESS_THAN = -1,
EQUAL = 0,
GREATER_THAN = 1,
INDETERMINATE = 2
};
enum NumberType {
Float,
Double,
BigDecimal,
DateTime,
UnKnown
};
virtual ~XMLNumber();
/**
* Return string representation of the decimal value.
* A decimal point will be included as necessary.
* Similar to toString above, but the internal buffer is
* returned directly, user is not required to delete
* the returned buffer
*/
virtual XMLCh* getRawData() const = 0;
/**
* Return the original and converted value of the original data.
* (applicable to double/float)
*
* The internal buffer is returned directly, user is not required
* to delete the returned buffer
*/
virtual const XMLCh* getFormattedString() const = 0;
/**
* Returns the sign of this number
*
* -1 negative
* 0 zero
* 1 positive
*
*/
virtual int getSign() const = 0;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLNumber)
static XMLNumber* loadNumber(XMLNumber::NumberType numType
, XSerializeEngine& serEng);
protected:
XMLNumber();
XMLNumber(const XMLNumber&);
private:
// -----------------------------------------------------------------------
// Unimplemented operators
// -----------------------------------------------------------------------
XMLNumber& operator=(const XMLNumber&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,214 @@
/*
* 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: XMLResourceIdentifier.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLRESOURCEIDENTIFIER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLRESOURCEIDENTIFIER_HPP
XERCES_CPP_NAMESPACE_BEGIN
class Locator;
/**
* <p>This class is used along with XMLEntityResolver to resolve entities.
* Instead of passing publicId and systemId on the resolveEntity call,
* as is done with the SAX entity resolver, an object of type XMLResourceIdentifier
* is passed. By calling the getResourceIdentifierType() method the user can
* determine which data members are available for inspection:</p>
*
* <table border='1'>
* <tr>
* <td>ResourceIdentifierType</td>
* <td>Available Data Members</td>
* </tr>
* <tr>
* <td>SchemaGrammar</td>
* <td>schemaLocation, nameSpace & baseURI (current document)</td>
* </tr>
* <tr>
* <td>SchemaImport</td>
* <td>schemaLocation, nameSpace & baseURI (current document)</td>
* </tr>
* <tr>
* <td>SchemaInclude</td>
* <td>schemaLocation & baseURI (current document)</td>
* </tr>
* <tr>
* <td>SchemaRedefine</td>
* <td>schemaLocation & baseURI (current document)</td>
* </tr>
* <tr>
* <td>ExternalEntity</td>
* <td>systemId, publicId & baseURI (some items may be NULL)</td>
* </tr>
* </table>
*
* <p>The following resolver would provide the application
* with a special character stream for the entity with the system
* identifier "http://www.myhost.com/today":</p>
*
*<code>
* \#include <xercesc/util/XMLEntityResolver.hpp><br>
* \#include <xercesc/sax/InputSource.hpp><br>
*<br>
*&nbsp;class MyResolver : public XMLEntityResolver {<br>
*&nbsp;&nbsp;public:<br>
*&nbsp;&nbsp;&nbsp;InputSource resolveEntity (XMLResourceIdentifier* xmlri);<br>
*&nbsp;&nbsp;&nbsp;...<br>
*&nbsp;&nbsp;};<br>
*<br>
*&nbsp;&nbsp;MyResolver::resolveEntity(XMLResourceIdentifier* xmlri) {<br>
*&nbsp;&nbsp;&nbsp;switch(xmlri->getResourceIdentifierType()) {<br>
*&nbsp;&nbsp;&nbsp;&nbsp;case XMLResourceIdentifier::SystemId:<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (XMLString::compareString(xmlri->getSystemId(), "http://www.myhost.com/today")) {<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyReader* reader = new MyReader();<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return new InputSource(reader);<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
*&nbsp;&nbsp;&nbsp;&nbsp;default:<br>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<br>
*&nbsp;&nbsp;&nbsp;}<br>
*&nbsp;&nbsp;}</code>
*
* @see SAXParser#setXMLEntityResolver
* @see InputSource#InputSource
*/
class XMLUTIL_EXPORT XMLResourceIdentifier
{
public:
/** @name Public Constants */
//@{
enum ResourceIdentifierType {
SchemaGrammar = 0,
SchemaImport,
SchemaInclude,
SchemaRedefine ,
ExternalEntity,
UnKnown = 255
};
//@}
/** @name Constructors and Destructor */
//@{
/** Constructor */
XMLResourceIdentifier(const ResourceIdentifierType resourceIdentitiferType
, const XMLCh* const systemId
, const XMLCh* const nameSpace = 0
, const XMLCh* const publicId = 0
, const XMLCh* const baseURI = 0
, const Locator* locator = 0);
/** Destructor */
~XMLResourceIdentifier()
{
}
//@}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/** @name Public Methods */
//@{
ResourceIdentifierType getResourceIdentifierType() const;
const XMLCh* getPublicId() const;
const XMLCh* getSystemId() const;
const XMLCh* getSchemaLocation() const;
const XMLCh* getBaseURI() const;
const XMLCh* getNameSpace() const;
const Locator* getLocator() const;
//@}
private :
const ResourceIdentifierType fResourceIdentifierType;
const XMLCh* fPublicId;
const XMLCh* fSystemId;
const XMLCh* fBaseURI;
const XMLCh* fNameSpace;
const Locator* fLocator;
/* Unimplemented constructors and operators */
/* Copy constructor */
XMLResourceIdentifier(const XMLResourceIdentifier&);
/* Assignment operator */
XMLResourceIdentifier& operator=(const XMLResourceIdentifier&);
};
inline XMLResourceIdentifier::ResourceIdentifierType XMLResourceIdentifier::getResourceIdentifierType() const
{
return fResourceIdentifierType;
}
inline const XMLCh* XMLResourceIdentifier::getPublicId() const
{
return fPublicId;
}
inline const XMLCh* XMLResourceIdentifier::getSystemId() const
{
return fSystemId;
}
inline const XMLCh* XMLResourceIdentifier::getSchemaLocation() const
{
return fSystemId;
}
inline const XMLCh* XMLResourceIdentifier::getBaseURI() const
{
return fBaseURI;
}
inline const XMLCh* XMLResourceIdentifier::getNameSpace() const
{
return fNameSpace;
}
inline const Locator* XMLResourceIdentifier::getLocator() const
{
return fLocator;
}
inline XMLResourceIdentifier::XMLResourceIdentifier(const ResourceIdentifierType resourceIdentifierType
, const XMLCh* const systemId
, const XMLCh* const nameSpace
, const XMLCh* const publicId
, const XMLCh* const baseURI
, const Locator* locator )
: fResourceIdentifierType(resourceIdentifierType)
, fPublicId(publicId)
, fSystemId(systemId)
, fBaseURI(baseURI)
, fNameSpace(nameSpace)
, fLocator(locator)
{
}
XERCES_CPP_NAMESPACE_END
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,218 @@
/*
* 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: XMLStringTokenizer.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLSTRINGTOKENIZER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLSTRINGTOKENIZER_HPP
#include <xercesc/util/RefArrayVectorOf.hpp>
#include <xercesc/util/XMLString.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* The string tokenizer class breaks a string into tokens.
*
* The XMLStringTokenizer methods do not distinguish among identifiers,
* numbers, and quoted strings, nor do they recognize and skip comments
*
* A XMLStringTokenizer object internally maintains a current position within
* the string to be tokenized. Some operations advance this current position
* past the characters processed.
*/
class XMLUTIL_EXPORT XMLStringTokenizer :public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructors
// -----------------------------------------------------------------------
/** @name Constructors */
//@{
/**
* Constructs a string tokenizer for the specified string. The tokenizer
* uses the default delimiter set, which is "\t\n\r\f": the space
* character, the tab character, the newline character, the
* carriage-return character, and the form-feed character. Delimiter
* characters themselves will not be treated as tokens.
*
* @param srcStr The string to be parsed.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*
*/
XMLStringTokenizer(const XMLCh* const srcStr,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Constructs a string tokenizer for the specified string. The characters
* in the delim argument are the delimiters for separating tokens.
* Delimiter characters themselves will not be treated as tokens.
*
* @param srcStr The string to be parsed.
* @param delim The set of delimiters.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
XMLStringTokenizer(const XMLCh* const srcStr
, const XMLCh* const delim
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@}
// -----------------------------------------------------------------------
// Public Destructor
// -----------------------------------------------------------------------
/** @name Destructor. */
//@{
~XMLStringTokenizer();
//@}
// -----------------------------------------------------------------------
// Management methods
// -----------------------------------------------------------------------
/** @name Management Function */
//@{
/**
* Tests if there are more tokens available from this tokenizer's string.
*
* Returns true if and only if there is at least one token in the string
* after the current position; false otherwise.
*/
bool hasMoreTokens();
/**
* Calculates the number of times that this tokenizer's nextToken method
* can be called to return a valid token. The current position is not
* advanced.
*
* Returns the number of tokens remaining in the string using the current
* delimiter set.
*/
unsigned int countTokens();
/**
* Returns the next token from this string tokenizer.
*
* Function allocated, function managed (fafm). The calling function
* does not need to worry about deleting the returned pointer.
*/
XMLCh* nextToken();
//@}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLStringTokenizer(const XMLStringTokenizer&);
XMLStringTokenizer& operator=(const XMLStringTokenizer&);
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
bool isDelimeter(const XMLCh ch);
// -----------------------------------------------------------------------
// Private data members
//
// fOffset
// The current position in the parsed string.
//
// fStringLen
// The length of the string parsed (for convenience).
//
// fString
// The string to be parsed
//
// fDelimeters
// A set of delimiter characters
//
// fTokens
// A vector of the token strings
// -----------------------------------------------------------------------
XMLSize_t fOffset;
XMLSize_t fStringLen;
XMLCh* fString;
const XMLCh* fDelimeters;
RefArrayVectorOf<XMLCh>* fTokens;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XMLStringTokenizer: Helper methods
// ---------------------------------------------------------------------------
inline bool XMLStringTokenizer::isDelimeter(const XMLCh ch) {
return XMLString::indexOf(fDelimeters, ch) == -1 ? false : true;
}
// ---------------------------------------------------------------------------
// XMLStringTokenizer: Management methods
// ---------------------------------------------------------------------------
inline unsigned int XMLStringTokenizer::countTokens() {
if (fStringLen == 0)
return 0;
unsigned int tokCount = 0;
bool inToken = false;
for (XMLSize_t i= fOffset; i< fStringLen; i++) {
if (isDelimeter(fString[i])) {
if (inToken) {
inToken = false;
}
continue;
}
if (!inToken) {
tokCount++;
inToken = true;
}
} // end for
return tokCount;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XMLStringTokenizer.hpp
*/

View File

@@ -0,0 +1,104 @@
/*
* 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: XMLUCS4Transcoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLUCS4TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLUCS4TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/TransService.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple UCS4 transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
class XMLUTIL_EXPORT XMLUCS4Transcoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLUCS4Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, const bool swapped
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLUCS4Transcoder();
// -----------------------------------------------------------------------
// Implementation of the XMLTranscoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLUCS4Transcoder(const XMLUCS4Transcoder&);
XMLUCS4Transcoder& operator=(const XMLUCS4Transcoder&);
// -----------------------------------------------------------------------
// Private data members
//
// fSwapped
// This tells us if our input is going to be in the same endianness
// as the local host or swapped.
// -----------------------------------------------------------------------
bool fSwapped;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,292 @@
/*
* 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: XMLURL.hpp 536133 2007-05-08 09:05:14Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLURL_HPP)
#define XERCESC_INCLUDE_GUARD_XMLURL_HPP
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class BinInputStream;
//
// This class supports file, http, and ftp style URLs. All others are
// rejected
//
class XMLUTIL_EXPORT XMLURL : public XMemory
{
public:
// -----------------------------------------------------------------------
// Class types
//
// And they must remain in this order because they are indexes into an
// array internally!
// -----------------------------------------------------------------------
enum Protocols
{
File
, HTTP
, FTP
, HTTPS
, Protocols_Count
, Unknown
};
// -----------------------------------------------------------------------
// Public static methods
// -----------------------------------------------------------------------
static Protocols lookupByName(const XMLCh* const protoName);
static bool parse(const XMLCh* const urlText, XMLURL& xmlURL);
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLURL(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XMLURL
(
const XMLCh* const baseURL
, const XMLCh* const relativeURL
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLURL
(
const XMLCh* const baseURL
, const char* const relativeURL
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLURL
(
const XMLURL& baseURL
, const XMLCh* const relativeURL
);
XMLURL
(
const XMLURL& baseURL
, const char* const relativeURL
);
XMLURL
(
const XMLCh* const urlText
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLURL
(
const char* const urlText
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
XMLURL(const XMLURL& toCopy);
virtual ~XMLURL();
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
XMLURL& operator=(const XMLURL& toAssign);
bool operator==(const XMLURL& toCompare) const;
bool operator!=(const XMLURL& toCompare) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const XMLCh* getFragment() const;
const XMLCh* getHost() const;
const XMLCh* getPassword() const;
const XMLCh* getPath() const;
unsigned int getPortNum() const;
Protocols getProtocol() const;
const XMLCh* getProtocolName() const;
const XMLCh* getQuery() const;
const XMLCh* getURLText() const;
const XMLCh* getUser() const;
MemoryManager* getMemoryManager() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setURL(const XMLCh* const urlText);
void setURL
(
const XMLCh* const baseURL
, const XMLCh* const relativeURL
);
void setURL
(
const XMLURL& baseURL
, const XMLCh* const relativeURL
);
// a version of setURL that doesn't throw malformed url exceptions
bool setURL(
const XMLCh* const baseURL
, const XMLCh* const relativeURL
, XMLURL& xmlURL);
// -----------------------------------------------------------------------
// Miscellaneous methods
// -----------------------------------------------------------------------
bool isRelative() const;
bool hasInvalidChar() const;
BinInputStream* makeNewStream() const;
void makeRelativeTo(const XMLCh* const baseURLText);
void makeRelativeTo(const XMLURL& baseURL);
private:
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void buildFullText();
void cleanUp();
bool conglomerateWithBase(const XMLURL& baseURL, bool useExceptions=true);
void parse
(
const XMLCh* const urlText
);
// -----------------------------------------------------------------------
// Data members
//
// fFragment
// The fragment part of the URL, if any. If none, its a null.
//
// fHost
// The host part of the URL that was parsed out. This one will often
// be null (or "localhost", which also means the current machine.)
//
// fPassword
// The password found, if any. If none then its a null.
//
// fPath
// The path part of the URL that was parsed out, if any. If none,
// then its a null.
//
// fPortNum
// The port that was indicated in the URL. If no port was provided
// explicitly, then its left zero.
//
// fProtocol
// Indicates the type of the URL's source. The text of the prefix
// can be gotten from this.
//
// fQuery
// The query part of the URL, if any. If none, then its a null.
//
// fUser
// The username found, if any. If none, then its a null.
//
// fURLText
// This is a copy of the URL text, after it has been taken apart,
// made relative if needed, canonicalized, and then put back
// together. Its only created upon demand.
//
// fHasInvalidChar
// This indicates if the URL Text contains invalid characters as per
// RFC 2396 standard.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
XMLCh* fFragment;
XMLCh* fHost;
XMLCh* fPassword;
XMLCh* fPath;
unsigned int fPortNum;
Protocols fProtocol;
XMLCh* fQuery;
XMLCh* fUser;
XMLCh* fURLText;
bool fHasInvalidChar;
};
// ---------------------------------------------------------------------------
// XMLURL: Public operators
// ---------------------------------------------------------------------------
inline bool XMLURL::operator!=(const XMLURL& toCompare) const
{
return !operator==(toCompare);
}
// ---------------------------------------------------------------------------
// XMLURL: Getter methods
// ---------------------------------------------------------------------------
inline const XMLCh* XMLURL::getFragment() const
{
return fFragment;
}
inline const XMLCh* XMLURL::getHost() const
{
return fHost;
}
inline const XMLCh* XMLURL::getPassword() const
{
return fPassword;
}
inline const XMLCh* XMLURL::getPath() const
{
return fPath;
}
inline XMLURL::Protocols XMLURL::getProtocol() const
{
return fProtocol;
}
inline const XMLCh* XMLURL::getQuery() const
{
return fQuery;
}
inline const XMLCh* XMLURL::getUser() const
{
return fUser;
}
inline const XMLCh* XMLURL::getURLText() const
{
//
// Fault it in if not already. Since this is a const method and we
// can't use mutable members due the compilers we have to support,
// we have to cast off the constness.
//
if (!fURLText)
((XMLURL*)this)->buildFullText();
return fURLText;
}
inline MemoryManager* XMLURL::getMemoryManager() const
{
return fMemoryManager;
}
MakeXMLException(MalformedURLException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,105 @@
/*
* 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: XMLUTF16Transcoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLUTF16TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLUTF16TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/TransService.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple UTF16 transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
class XMLUTIL_EXPORT XMLUTF16Transcoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLUTF16Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, const bool swapped
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLUTF16Transcoder();
// -----------------------------------------------------------------------
// Implementation of the XMLTranscoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLUTF16Transcoder(const XMLUTF16Transcoder&);
XMLUTF16Transcoder& operator=(const XMLUTF16Transcoder&);
// -----------------------------------------------------------------------
// Private data members
//
// fSwapped
// Indicates whether the encoding is of the opposite endianness from
// the local host.
// -----------------------------------------------------------------------
bool fSwapped;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,118 @@
/*
* 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: XMLUTF8Transcoder.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLUTF8TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLUTF8TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/TransService.hpp>
#include <xercesc/util/UTFDataFormatException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for a simple UTF8 transcoder. The parser does some encodings
// intrinsically without depending upon external transcoding services.
// To make everything more orthogonal, we implement these internal
// transcoders using the same transcoder abstraction as the pluggable
// transcoding services do.
//
class XMLUTIL_EXPORT XMLUTF8Transcoder : public XMLTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLUTF8Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLUTF8Transcoder();
// -----------------------------------------------------------------------
// Implementation of the XMLTranscoder interface
// -----------------------------------------------------------------------
virtual XMLSize_t transcodeFrom
(
const XMLByte* const srcData
, const XMLSize_t srcCount
, XMLCh* const toFill
, const XMLSize_t maxChars
, XMLSize_t& bytesEaten
, unsigned char* const charSizes
);
virtual XMLSize_t transcodeTo
(
const XMLCh* const srcData
, const XMLSize_t srcCount
, XMLByte* const toFill
, const XMLSize_t maxBytes
, XMLSize_t& charsEaten
, const UnRepOpts options
);
virtual bool canTranscodeTo
(
const unsigned int toCheck
);
private :
inline void checkTrailingBytes(
const XMLByte toCheck
, const unsigned int trailingBytes
, const unsigned int position
) const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLUTF8Transcoder(const XMLUTF8Transcoder&);
XMLUTF8Transcoder& operator=(const XMLUTF8Transcoder&);
};
inline
void XMLUTF8Transcoder::checkTrailingBytes(const XMLByte toCheck
, const unsigned int trailingBytes
, const unsigned int position) const
{
if((toCheck & 0xC0) != 0x80)
{
char len[2] = {(char)(trailingBytes+0x31), 0};
char pos[2] = {(char)(position+0x31), 0};
char byte[2] = {toCheck,0};
ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager());
}
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,332 @@
/*
* 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: XMLUni.hpp 833045 2009-11-05 13:21:27Z borisk $
*/
// ---------------------------------------------------------------------------
// This file contains the grunt work constants for Unicode characters and
// common Unicode constant strings. These cannot be created normally because
// we have to compile on systems that cannot do the L"" style prefix. So
// they must be created as constant values for Unicode code points and the
// strings built up as arrays of those constants.
// ---------------------------------------------------------------------------
#if !defined(XERCESC_INCLUDE_GUARD_XMLUNI_HPP)
#define XERCESC_INCLUDE_GUARD_XMLUNI_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLUni
{
public :
// -----------------------------------------------------------------------
// These are constant strings that are common in XML data. Because
// of the limitation of the compilers we have to work with, these are
// done as arrays of XMLCh characters, not as constant strings.
// -----------------------------------------------------------------------
static const XMLCh fgAnyString[];
static const XMLCh fgAttListString[];
static const XMLCh fgCommentString[];
static const XMLCh fgCDATAString[];
static const XMLCh fgDefaultString[];
static const XMLCh fgDocTypeString[];
static const XMLCh fgEBCDICEncodingString[];
static const XMLCh fgElemString[];
static const XMLCh fgEmptyString[];
static const XMLCh fgEncodingString[];
static const XMLCh fgEntitString[];
static const XMLCh fgEntityString[];
static const XMLCh fgEntitiesString[];
static const XMLCh fgEnumerationString[];
static const XMLCh fgExceptDomain[];
static const XMLCh fgFixedString[];
static const XMLCh fgIBM037EncodingString[];
static const XMLCh fgIBM037EncodingString2[];
static const XMLCh fgIBM1047EncodingString[];
static const XMLCh fgIBM1047EncodingString2[];
static const XMLCh fgIBM1140EncodingString[];
static const XMLCh fgIBM1140EncodingString2[];
static const XMLCh fgIBM1140EncodingString3[];
static const XMLCh fgIBM1140EncodingString4[];
static const XMLCh fgIESString[];
static const XMLCh fgIDString[];
static const XMLCh fgIDRefString[];
static const XMLCh fgIDRefsString[];
static const XMLCh fgImpliedString[];
static const XMLCh fgIgnoreString[];
static const XMLCh fgIncludeString[];
static const XMLCh fgISO88591EncodingString[];
static const XMLCh fgISO88591EncodingString2[];
static const XMLCh fgISO88591EncodingString3[];
static const XMLCh fgISO88591EncodingString4[];
static const XMLCh fgISO88591EncodingString5[];
static const XMLCh fgISO88591EncodingString6[];
static const XMLCh fgISO88591EncodingString7[];
static const XMLCh fgISO88591EncodingString8[];
static const XMLCh fgISO88591EncodingString9[];
static const XMLCh fgISO88591EncodingString10[];
static const XMLCh fgISO88591EncodingString11[];
static const XMLCh fgISO88591EncodingString12[];
static const XMLCh fgLocalHostString[];
static const XMLCh fgNoString[];
static const XMLCh fgNotationString[];
static const XMLCh fgNDATAString[];
static const XMLCh fgNmTokenString[];
static const XMLCh fgNmTokensString[];
static const XMLCh fgPCDATAString[];
static const XMLCh fgPIString[];
static const XMLCh fgPubIDString[];
static const XMLCh fgRefString[];
static const XMLCh fgRequiredString[];
static const XMLCh fgStandaloneString[];
static const XMLCh fgVersion1_0[];
static const XMLCh fgVersion1_1[];
static const XMLCh fgSysIDString[];
static const XMLCh fgUnknownURIName[];
static const XMLCh fgUCS4EncodingString[];
static const XMLCh fgUCS4EncodingString2[];
static const XMLCh fgUCS4EncodingString3[];
static const XMLCh fgUCS4EncodingString4[];
static const XMLCh fgUCS4EncodingString5[];
static const XMLCh fgUCS4BEncodingString[];
static const XMLCh fgUCS4BEncodingString2[];
static const XMLCh fgUCS4LEncodingString[];
static const XMLCh fgUCS4LEncodingString2[];
static const XMLCh fgUSASCIIEncodingString[];
static const XMLCh fgUSASCIIEncodingString2[];
static const XMLCh fgUSASCIIEncodingString3[];
static const XMLCh fgUSASCIIEncodingString4[];
static const XMLCh fgUTF8EncodingString[];
static const XMLCh fgUTF8EncodingString2[];
static const XMLCh fgUTF16EncodingString[];
static const XMLCh fgUTF16EncodingString2[];
static const XMLCh fgUTF16EncodingString3[];
static const XMLCh fgUTF16EncodingString4[];
static const XMLCh fgUTF16EncodingString5[];
static const XMLCh fgUTF16EncodingString6[];
static const XMLCh fgUTF16EncodingString7[];
static const XMLCh fgUTF16BEncodingString[];
static const XMLCh fgUTF16BEncodingString2[];
static const XMLCh fgUTF16LEncodingString[];
static const XMLCh fgUTF16LEncodingString2[];
static const XMLCh fgVersionString[];
static const XMLCh fgValidityDomain[];
static const XMLCh fgWin1252EncodingString[];
static const XMLCh fgXMLChEncodingString[];
static const XMLCh fgXMLDOMMsgDomain[];
static const XMLCh fgXMLString[];
static const XMLCh fgXMLStringSpace[];
static const XMLCh fgXMLStringHTab[];
static const XMLCh fgXMLStringCR[];
static const XMLCh fgXMLStringLF[];
static const XMLCh fgXMLStringSpaceU[];
static const XMLCh fgXMLStringHTabU[];
static const XMLCh fgXMLStringCRU[];
static const XMLCh fgXMLStringLFU[];
static const XMLCh fgXMLDeclString[];
static const XMLCh fgXMLDeclStringSpace[];
static const XMLCh fgXMLDeclStringHTab[];
static const XMLCh fgXMLDeclStringLF[];
static const XMLCh fgXMLDeclStringCR[];
static const XMLCh fgXMLDeclStringSpaceU[];
static const XMLCh fgXMLDeclStringHTabU[];
static const XMLCh fgXMLDeclStringLFU[];
static const XMLCh fgXMLDeclStringCRU[];
static const XMLCh fgXMLNSString[];
static const XMLCh fgXMLNSColonString[];
static const XMLCh fgXMLNSURIName[];
static const XMLCh fgXMLErrDomain[];
static const XMLCh fgXMLURIName[];
static const XMLCh fgInfosetURIName[];
static const XMLCh fgYesString[];
static const XMLCh fgZeroLenString[];
static const XMLCh fgDTDEntityString[];
static const XMLCh fgAmp[];
static const XMLCh fgLT[];
static const XMLCh fgGT[];
static const XMLCh fgQuot[];
static const XMLCh fgApos[];
static const XMLCh fgWFXMLScanner[];
static const XMLCh fgIGXMLScanner[];
static const XMLCh fgSGXMLScanner[];
static const XMLCh fgDGXMLScanner[];
static const XMLCh fgXSAXMLScanner[];
static const XMLCh fgCDataStart[];
static const XMLCh fgCDataEnd[];
// Exception Name
static const XMLCh fgArrayIndexOutOfBoundsException_Name[];
static const XMLCh fgEmptyStackException_Name[];
static const XMLCh fgIllegalArgumentException_Name[];
static const XMLCh fgInvalidCastException_Name[];
static const XMLCh fgIOException_Name[];
static const XMLCh fgNoSuchElementException_Name[];
static const XMLCh fgNullPointerException_Name[];
static const XMLCh fgXMLPlatformUtilsException_Name[];
static const XMLCh fgRuntimeException_Name[];
static const XMLCh fgTranscodingException_Name[];
static const XMLCh fgUnexpectedEOFException_Name[];
static const XMLCh fgUnsupportedEncodingException_Name[];
static const XMLCh fgUTFDataFormatException_Name[];
static const XMLCh fgNetAccessorException_Name[];
static const XMLCh fgMalformedURLException_Name[];
static const XMLCh fgNumberFormatException_Name[];
static const XMLCh fgParseException_Name[];
static const XMLCh fgInvalidDatatypeFacetException_Name[];
static const XMLCh fgInvalidDatatypeValueException_Name[];
static const XMLCh fgSchemaDateTimeException_Name[];
static const XMLCh fgXPathException_Name[];
static const XMLCh fgXSerializationException_Name[];
static const XMLCh fgXMLXIncludeException_Name[];
// Numerical String
static const XMLCh fgNegINFString[];
static const XMLCh fgNegZeroString[];
static const XMLCh fgPosZeroString[];
static const XMLCh fgPosINFString[];
static const XMLCh fgNaNString[];
static const XMLCh fgEString[];
static const XMLCh fgZeroString[];
static const XMLCh fgNullString[];
// Xerces features/properties names
static const XMLCh fgXercesDynamic[];
static const XMLCh fgXercesSchema[];
static const XMLCh fgXercesSchemaFullChecking[];
static const XMLCh fgXercesLoadSchema[];
static const XMLCh fgXercesIdentityConstraintChecking[];
static const XMLCh fgXercesSchemaExternalSchemaLocation[];
static const XMLCh fgXercesSchemaExternalNoNameSpaceSchemaLocation[];
static const XMLCh fgXercesSecurityManager[];
static const XMLCh fgXercesLoadExternalDTD[];
static const XMLCh fgXercesContinueAfterFatalError[];
static const XMLCh fgXercesValidationErrorAsFatal[];
static const XMLCh fgXercesUserAdoptsDOMDocument[];
static const XMLCh fgXercesCacheGrammarFromParse[];
static const XMLCh fgXercesUseCachedGrammarInParse[];
static const XMLCh fgXercesScannerName[];
static const XMLCh fgXercesParserUseDocumentFromImplementation[];
static const XMLCh fgXercesCalculateSrcOfs[];
static const XMLCh fgXercesStandardUriConformant[];
static const XMLCh fgXercesDOMHasPSVIInfo[];
static const XMLCh fgXercesGenerateSyntheticAnnotations[];
static const XMLCh fgXercesValidateAnnotations[];
static const XMLCh fgXercesIgnoreCachedDTD[];
static const XMLCh fgXercesIgnoreAnnotations[];
static const XMLCh fgXercesDisableDefaultEntityResolution[];
static const XMLCh fgXercesSkipDTDValidation[];
static const XMLCh fgXercesEntityResolver[];
static const XMLCh fgXercesHandleMultipleImports[];
static const XMLCh fgXercesDoXInclude[];
static const XMLCh fgXercesLowWaterMark[];
// SAX2 features/properties names
static const XMLCh fgSAX2CoreValidation[];
static const XMLCh fgSAX2CoreNameSpaces[];
static const XMLCh fgSAX2CoreNameSpacePrefixes[];
// Introduced in DOM Level 3
// DOMLSParser features
static const XMLCh fgDOMCanonicalForm[];
static const XMLCh fgDOMCDATASections[];
static const XMLCh fgDOMComments[];
static const XMLCh fgDOMCharsetOverridesXMLEncoding[];
static const XMLCh fgDOMCheckCharacterNormalization[];
static const XMLCh fgDOMDatatypeNormalization[];
static const XMLCh fgDOMDisallowDoctype[];
static const XMLCh fgDOMElementContentWhitespace[];
static const XMLCh fgDOMErrorHandler[];
static const XMLCh fgDOMEntities[];
static const XMLCh fgDOMIgnoreUnknownCharacterDenormalization[];
static const XMLCh fgDOMInfoset[];
static const XMLCh fgDOMNamespaces[];
static const XMLCh fgDOMNamespaceDeclarations[];
static const XMLCh fgDOMNormalizeCharacters[];
static const XMLCh fgDOMResourceResolver[];
static const XMLCh fgDOMSchemaLocation[];
static const XMLCh fgDOMSchemaType[];
static const XMLCh fgDOMSplitCDATASections[];
static const XMLCh fgDOMSupportedMediatypesOnly[];
static const XMLCh fgDOMValidate[];
static const XMLCh fgDOMValidateIfSchema[];
static const XMLCh fgDOMWellFormed[];
static const XMLCh fgDOMXMLSchemaType[];
static const XMLCh fgDOMDTDType[];
// Introduced in DOM Level 3
// DOMLSSerializer feature
static const XMLCh fgDOMWRTCanonicalForm[];
static const XMLCh fgDOMWRTDiscardDefaultContent[];
static const XMLCh fgDOMWRTEntities[];
static const XMLCh fgDOMWRTFormatPrettyPrint[];
static const XMLCh fgDOMWRTNormalizeCharacters[];
static const XMLCh fgDOMWRTSplitCdataSections[];
static const XMLCh fgDOMWRTValidation[];
static const XMLCh fgDOMWRTWhitespaceInElementContent[];
static const XMLCh fgDOMWRTBOM[];
static const XMLCh fgDOMXMLDeclaration[];
static const XMLCh fgDOMWRTXercesPrettyPrint[];
// Private interface names
static const XMLCh fgXercescInterfacePSVITypeInfo[];
static const XMLCh fgXercescInterfaceDOMDocumentTypeImpl[];
static const XMLCh fgXercescInterfaceDOMDocumentImpl[];
static const XMLCh fgXercescInterfaceDOMMemoryManager[];
// Locale
static const char fgXercescDefaultLocale[];
// Default Exception String
static const XMLCh fgDefErrMsg[];
// Datatype
static const XMLCh fgValueZero[];
static const XMLCh fgNegOne[];
static const XMLCh fgValueOne[];
static const XMLCh fgLongMaxInc[];
static const XMLCh fgLongMinInc[];
static const XMLCh fgIntMaxInc[];
static const XMLCh fgIntMinInc[];
static const XMLCh fgShortMaxInc[];
static const XMLCh fgShortMinInc[];
static const XMLCh fgByteMaxInc[];
static const XMLCh fgByteMinInc[];
static const XMLCh fgULongMaxInc[];
static const XMLCh fgUIntMaxInc[];
static const XMLCh fgUShortMaxInc[];
static const XMLCh fgUByteMaxInc[];
static const XMLCh fgLangPattern[];
static const XMLCh fgBooleanValueSpace[][8];
static const XMLSize_t fgBooleanValueSpaceArraySize;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLUni();
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,154 @@
/*
* 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: XMLUniDefs.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLUNIDEFS_HPP)
#define XERCESC_INCLUDE_GUARD_XMLUNIDEFS_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Constants for the Unicode characters of interest to us in an XML parser
// We don't put these inside the class because then they could not be const
// inline values, which would have significant performance ramifications.
//
// We cannot use a namespace because of the requirement to support old
// compilers.
// ---------------------------------------------------------------------------
const XMLCh chNull = 0x00;
const XMLCh chHTab = 0x09;
const XMLCh chLF = 0x0A;
const XMLCh chVTab = 0x0B;
const XMLCh chFF = 0x0C;
const XMLCh chCR = 0x0D;
const XMLCh chAmpersand = 0x26;
const XMLCh chAsterisk = 0x2A;
const XMLCh chAt = 0x40;
const XMLCh chBackSlash = 0x5C;
const XMLCh chBang = 0x21;
const XMLCh chCaret = 0x5E;
const XMLCh chCloseAngle = 0x3E;
const XMLCh chCloseCurly = 0x7D;
const XMLCh chCloseParen = 0x29;
const XMLCh chCloseSquare = 0x5D;
const XMLCh chColon = 0x3A;
const XMLCh chComma = 0x2C;
const XMLCh chDash = 0x2D;
const XMLCh chDollarSign = 0x24;
const XMLCh chDoubleQuote = 0x22;
const XMLCh chEqual = 0x3D;
const XMLCh chForwardSlash = 0x2F;
const XMLCh chGrave = 0x60;
const XMLCh chNEL = 0x85;
const XMLCh chOpenAngle = 0x3C;
const XMLCh chOpenCurly = 0x7B;
const XMLCh chOpenParen = 0x28;
const XMLCh chOpenSquare = 0x5B;
const XMLCh chPercent = 0x25;
const XMLCh chPeriod = 0x2E;
const XMLCh chPipe = 0x7C;
const XMLCh chPlus = 0x2B;
const XMLCh chPound = 0x23;
const XMLCh chQuestion = 0x3F;
const XMLCh chSingleQuote = 0x27;
const XMLCh chSpace = 0x20;
const XMLCh chSemiColon = 0x3B;
const XMLCh chTilde = 0x7E;
const XMLCh chUnderscore = 0x5F;
const XMLCh chSwappedUnicodeMarker = XMLCh(0xFFFE);
const XMLCh chUnicodeMarker = XMLCh(0xFEFF);
const XMLCh chDigit_0 = 0x30;
const XMLCh chDigit_1 = 0x31;
const XMLCh chDigit_2 = 0x32;
const XMLCh chDigit_3 = 0x33;
const XMLCh chDigit_4 = 0x34;
const XMLCh chDigit_5 = 0x35;
const XMLCh chDigit_6 = 0x36;
const XMLCh chDigit_7 = 0x37;
const XMLCh chDigit_8 = 0x38;
const XMLCh chDigit_9 = 0x39;
const XMLCh chLatin_A = 0x41;
const XMLCh chLatin_B = 0x42;
const XMLCh chLatin_C = 0x43;
const XMLCh chLatin_D = 0x44;
const XMLCh chLatin_E = 0x45;
const XMLCh chLatin_F = 0x46;
const XMLCh chLatin_G = 0x47;
const XMLCh chLatin_H = 0x48;
const XMLCh chLatin_I = 0x49;
const XMLCh chLatin_J = 0x4A;
const XMLCh chLatin_K = 0x4B;
const XMLCh chLatin_L = 0x4C;
const XMLCh chLatin_M = 0x4D;
const XMLCh chLatin_N = 0x4E;
const XMLCh chLatin_O = 0x4F;
const XMLCh chLatin_P = 0x50;
const XMLCh chLatin_Q = 0x51;
const XMLCh chLatin_R = 0x52;
const XMLCh chLatin_S = 0x53;
const XMLCh chLatin_T = 0x54;
const XMLCh chLatin_U = 0x55;
const XMLCh chLatin_V = 0x56;
const XMLCh chLatin_W = 0x57;
const XMLCh chLatin_X = 0x58;
const XMLCh chLatin_Y = 0x59;
const XMLCh chLatin_Z = 0x5A;
const XMLCh chLatin_a = 0x61;
const XMLCh chLatin_b = 0x62;
const XMLCh chLatin_c = 0x63;
const XMLCh chLatin_d = 0x64;
const XMLCh chLatin_e = 0x65;
const XMLCh chLatin_f = 0x66;
const XMLCh chLatin_g = 0x67;
const XMLCh chLatin_h = 0x68;
const XMLCh chLatin_i = 0x69;
const XMLCh chLatin_j = 0x6A;
const XMLCh chLatin_k = 0x6B;
const XMLCh chLatin_l = 0x6C;
const XMLCh chLatin_m = 0x6D;
const XMLCh chLatin_n = 0x6E;
const XMLCh chLatin_o = 0x6F;
const XMLCh chLatin_p = 0x70;
const XMLCh chLatin_q = 0x71;
const XMLCh chLatin_r = 0x72;
const XMLCh chLatin_s = 0x73;
const XMLCh chLatin_t = 0x74;
const XMLCh chLatin_u = 0x75;
const XMLCh chLatin_v = 0x76;
const XMLCh chLatin_w = 0x77;
const XMLCh chLatin_x = 0x78;
const XMLCh chLatin_y = 0x79;
const XMLCh chLatin_z = 0x7A;
const XMLCh chYenSign = 0xA5;
const XMLCh chWonSign = 0x20A9;
const XMLCh chLineSeparator = 0x2028;
const XMLCh chParagraphSeparator = 0x2029;
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,663 @@
/*
* 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: XMLUri.hpp 557254 2007-07-18 13:28:54Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLURI_HPP)
#define XERCESC_INCLUDE_GUARD_XMLURI_HPP
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/internal/XSerializable.hpp>
#include <xercesc/framework/XMLBuffer.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/*
* This class is a direct port of Java's URI class, to distinguish
* itself from the XMLURL, we use the name XMLUri instead of
* XMLURI.
*
* TODO: how to relate XMLUri and XMLURL since URL is part of URI.
*
*/
class XMLUTIL_EXPORT XMLUri : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
/**
* Construct a new URI from a URI specification string.
*
* If the specification follows the "generic URI" syntax, (two slashes
* following the first colon), the specification will be parsed
* accordingly - setting the
* scheme,
* userinfo,
* host,
* port,
* path,
* querystring and
* fragment
* fields as necessary.
*
* If the specification does not follow the "generic URI" syntax,
* the specification is parsed into a
* scheme and
* scheme-specific part (stored as the path) only.
*
* @param uriSpec the URI specification string (cannot be null or empty)
*
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*
* ctor# 2
*
*/
XMLUri(const XMLCh* const uriSpec,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Construct a new URI from a base URI and a URI specification string.
* The URI specification string may be a relative URI.
*
* @param baseURI the base URI (cannot be null if uriSpec is null or
* empty)
*
* @param uriSpec the URI specification string (cannot be null or
* empty if base is null)
*
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*
* ctor# 7 relative ctor
*
*/
XMLUri(const XMLUri* const baseURI
, const XMLCh* const uriSpec
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Copy constructor
*/
XMLUri(const XMLUri& toCopy);
XMLUri& operator=(const XMLUri& toAssign);
virtual ~XMLUri();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
const XMLCh* getUriText() const;
/**
* Get the scheme for this URI.
*
* @return the scheme for this URI
*/
const XMLCh* getScheme() const;
/**
* Get the userinfo for this URI.
*
* @return the userinfo for this URI (null if not specified).
*/
const XMLCh* getUserInfo() const;
/**
* Get the host for this URI.
*
* @return the host for this URI (null if not specified).
*/
const XMLCh* getHost() const;
/**
* Get the port for this URI.
*
* @return the port for this URI (-1 if not specified).
*/
int getPort() const;
/**
* Get the registry based authority for this URI.
*
* @return the registry based authority (null if not specified).
*/
const XMLCh* getRegBasedAuthority() const;
/**
* Get the path for this URI. Note that the value returned is the path
* only and does not include the query string or fragment.
*
* @return the path for this URI.
*/
const XMLCh* getPath() const;
/**
* Get the query string for this URI.
*
* @return the query string for this URI. Null is returned if there
* was no "?" in the URI spec, empty string if there was a
* "?" but no query string following it.
*/
const XMLCh* getQueryString() const;
/**
* Get the fragment for this URI.
*
* @return the fragment for this URI. Null is returned if there
* was no "#" in the URI spec, empty string if there was a
* "#" but no fragment following it.
*/
const XMLCh* getFragment() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
/**
* Set the scheme for this URI. The scheme is converted to lowercase
* before it is set.
*
* @param newScheme the scheme for this URI (cannot be null)
*
*/
void setScheme(const XMLCh* const newScheme);
/**
* Set the userinfo for this URI. If a non-null value is passed in and
* the host value is null, then an exception is thrown.
*
* @param newUserInfo the userinfo for this URI
*
*/
void setUserInfo(const XMLCh* const newUserInfo);
/**
* Set the host for this URI. If null is passed in, the userinfo
* field is also set to null and the port is set to -1.
*
* Note: This method overwrites registry based authority if it
* previously existed in this URI.
*
* @param newHost the host for this URI
*
*/
void setHost(const XMLCh* const newHost);
/**
* Set the port for this URI. -1 is used to indicate that the port is
* not specified, otherwise valid port numbers are between 0 and 65535.
* If a valid port number is passed in and the host field is null,
* an exception is thrown.
*
* @param newPort the port number for this URI
*
*/
void setPort(int newPort);
/**
* Sets the registry based authority for this URI.
*
* Note: This method overwrites server based authority
* if it previously existed in this URI.
*
* @param newRegAuth the registry based authority for this URI
*/
void setRegBasedAuthority(const XMLCh* const newRegAuth);
/**
* Set the path for this URI.
*
* If the supplied path is null, then the
* query string and fragment are set to null as well.
*
* If the supplied path includes a query string and/or fragment,
* these fields will be parsed and set as well.
*
* Note:
*
* For URIs following the "generic URI" syntax, the path
* specified should start with a slash.
*
* For URIs that do not follow the generic URI syntax, this method
* sets the scheme-specific part.
*
* @param newPath the path for this URI (may be null)
*
*/
void setPath(const XMLCh* const newPath);
/**
* Set the query string for this URI. A non-null value is valid only
* if this is an URI conforming to the generic URI syntax and
* the path value is not null.
*
* @param newQueryString the query string for this URI
*
*/
void setQueryString(const XMLCh* const newQueryString);
/**
* Set the fragment for this URI. A non-null value is valid only
* if this is a URI conforming to the generic URI syntax and
* the path value is not null.
*
* @param newFragment the fragment for this URI
*
*/
void setFragment(const XMLCh* const newFragment);
// -----------------------------------------------------------------------
// Miscellaneous methods
// -----------------------------------------------------------------------
/**
* Determine whether a given string contains only URI characters (also
* called "uric" in RFC 2396). uric consist of all reserved
* characters, unreserved characters and escaped characters.
*
* @return true if the string is comprised of uric, false otherwise
*/
static bool isURIString(const XMLCh* const uric);
/**
* Determine whether a given string is a valid URI
*/
static bool isValidURI( const XMLUri* const baseURI
, const XMLCh* const uriStr
, bool bAllowSpaces=false);
/**
* Determine whether a given string is a valid URI
*/
static bool isValidURI( bool haveBaseURI
, const XMLCh* const uriStr
, bool bAllowSpaces=false);
static void normalizeURI(const XMLCh* const systemURI,
XMLBuffer& normalizedURI);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLUri)
XMLUri(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
static const XMLCh MARK_OR_RESERVED_CHARACTERS[];
static const XMLCh RESERVED_CHARACTERS[];
static const XMLCh MARK_CHARACTERS[];
static const XMLCh SCHEME_CHARACTERS[];
static const XMLCh USERINFO_CHARACTERS[];
static const XMLCh REG_NAME_CHARACTERS[];
static const XMLCh PATH_CHARACTERS[];
//helper method for getUriText
void buildFullText();
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
/**
* Determine whether a character is a reserved character:
*
* @return true if the string contains any reserved characters
*/
static bool isReservedCharacter(const XMLCh theChar);
/**
* Determine whether a character is a path character:
*
* @return true if the character is path character
*/
static bool isPathCharacter(const XMLCh theChar);
/**
* Determine whether a char is an unreserved character.
*
* @return true if the char is unreserved, false otherwise
*/
static bool isUnreservedCharacter(const XMLCh theChar);
/**
* Determine whether a char is an reserved or unreserved character.
*
* @return true if the char is reserved or unreserved, false otherwise
*/
static bool isReservedOrUnreservedCharacter(const XMLCh theChar);
/**
* Determine whether a scheme conforms to the rules for a scheme name.
* A scheme is conformant if it starts with an alphanumeric, and
* contains only alphanumerics, '+','-' and '.'.
*
* @return true if the scheme is conformant, false otherwise
*/
static bool isConformantSchemeName(const XMLCh* const scheme);
/**
* Determine whether a userInfo conforms to the rules for a userinfo.
*
* @return true if the scheme is conformant, false otherwise
*/
static void isConformantUserInfo(const XMLCh* const userInfo
, MemoryManager* const manager);
/**
* Determines whether the components host, port, and user info
* are valid as a server authority.
*
* @return true if the given host, port, and userinfo compose
* a valid server authority
*/
static bool isValidServerBasedAuthority(const XMLCh* const host
, const XMLSize_t hostLen
, const int port
, const XMLCh* const userinfo
, const XMLSize_t userLen);
/**
* Determines whether the components host, port, and user info
* are valid as a server authority.
*
* @return true if the given host, port, and userinfo compose
* a valid server authority
*/
static bool isValidServerBasedAuthority(const XMLCh* const host
, const int port
, const XMLCh* const userinfo
, MemoryManager* const manager);
/**
* Determines whether the given string is a registry based authority.
*
* @param authority the authority component of a URI
*
* @return true if the given string is a registry based authority
*/
static bool isValidRegistryBasedAuthority(const XMLCh* const authority
, const XMLSize_t authLen);
/**
* Determines whether the given string is a registry based authority.
*
* @param authority the authority component of a URI
*
* @return true if the given string is a registry based authority
*/
static bool isValidRegistryBasedAuthority(const XMLCh* const authority);
/**
* Determine whether a string is syntactically capable of representing
* a valid IPv4 address, IPv6 reference or the domain name of a network host.
*
* A valid IPv4 address consists of four decimal digit groups
* separated by a '.'.
*
* See RFC 2732 Section 3, and RFC 2373 Section 2.2, for the
* definition of IPv6 references.
*
* A hostname consists of domain labels (each of which must begin and
* end with an alphanumeric but may contain '-') separated by a '.'.
* See RFC 2396 Section 3.2.2.
*
* @return true if the string is a syntactically valid IPv4 address
* or hostname
*/
static bool isWellFormedAddress(const XMLCh* const addr
, MemoryManager* const manager);
/**
* Determines whether a string is an IPv4 address as defined by
* RFC 2373, and under the further constraint that it must be a 32-bit
* address. Though not expressed in the grammar, in order to satisfy
* the 32-bit address constraint, each segment of the address cannot
* be greater than 255 (8 bits of information).
*
* @return true if the string is a syntactically valid IPv4 address
*/
static bool isWellFormedIPv4Address(const XMLCh* const addr, const XMLSize_t length);
/**
* Determines whether a string is an IPv6 reference as defined
* by RFC 2732, where IPv6address is defined in RFC 2373. The
* IPv6 address is parsed according to Section 2.2 of RFC 2373,
* with the additional constraint that the address be composed of
* 128 bits of information.
*
* Note: The BNF expressed in RFC 2373 Appendix B does not
* accurately describe section 2.2, and was in fact removed from
* RFC 3513, the successor of RFC 2373.
*
* @return true if the string is a syntactically valid IPv6 reference
*/
static bool isWellFormedIPv6Reference(const XMLCh* const addr, const XMLSize_t length);
/**
* Helper function for isWellFormedIPv6Reference which scans the
* hex sequences of an IPv6 address. It returns the index of the
* next character to scan in the address, or -1 if the string
* cannot match a valid IPv6 address.
*
* @param address the string to be scanned
* @param index the beginning index (inclusive)
* @param end the ending index (exclusive)
* @param counter a counter for the number of 16-bit sections read
* in the address
*
* @return the index of the next character to scan, or -1 if the
* string cannot match a valid IPv6 address
*/
static int scanHexSequence (const XMLCh* const addr, XMLSize_t index, XMLSize_t end, int& counter);
/**
* Get the indicator as to whether this URI uses the "generic URI"
* syntax.
*
* @return true if this URI uses the "generic URI" syntax, false
* otherwise
*/
bool isGenericURI();
// -----------------------------------------------------------------------
// Miscellaneous methods
// -----------------------------------------------------------------------
/**
* Initialize all fields of this URI from another URI.
*
* @param toCopy the URI to copy (cannot be null)
*/
void initialize(const XMLUri& toCopy);
/**
* Initializes this URI from a base URI and a URI specification string.
* See RFC 2396 Section 4 and Appendix B for specifications on parsing
* the URI and Section 5 for specifications on resolving relative URIs
* and relative paths.
*
* @param baseURI the base URI (may be null if uriSpec is an absolute
* URI)
*
* @param uriSpec the URI spec string which may be an absolute or
* relative URI (can only be null/empty if base
* is not null)
*
*/
void initialize(const XMLUri* const baseURI
, const XMLCh* const uriSpec);
/**
* Initialize the scheme for this URI from a URI string spec.
*
* @param uriSpec the URI specification (cannot be null)
*
*/
void initializeScheme(const XMLCh* const uriSpec);
/**
* Initialize the authority (userinfo, host and port) for this
* URI from a URI string spec.
*
* @param uriSpec the URI specification (cannot be null)
*
*/
void initializeAuthority(const XMLCh* const uriSpec);
/**
* Initialize the path for this URI from a URI string spec.
*
* @param uriSpec the URI specification (cannot be null)
*
*/
void initializePath(const XMLCh* const uriSpec);
/**
* cleanup the data variables
*
*/
void cleanUp();
static bool isConformantSchemeName(const XMLCh* const scheme,
const XMLSize_t schemeLen);
static bool processScheme(const XMLCh* const uriStr, XMLSize_t& index);
static bool processAuthority(const XMLCh* const uriStr, const XMLSize_t authLen);
static bool isWellFormedAddress(const XMLCh* const addr, const XMLSize_t addrLen);
static bool processPath(const XMLCh* const pathStr, const XMLSize_t pathStrLen,
const bool isSchemePresent, const bool bAllowSpaces=false);
// -----------------------------------------------------------------------
// Data members
//
// for all the data member, we own it,
// responsible for the creation and/or deletion for
// the memory allocated.
//
// -----------------------------------------------------------------------
int fPort;
XMLCh* fScheme;
XMLCh* fUserInfo;
XMLCh* fHost;
XMLCh* fRegAuth;
XMLCh* fPath;
XMLCh* fQueryString;
XMLCh* fFragment;
XMLCh* fURIText;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XMLUri: Getter methods
// ---------------------------------------------------------------------------
inline const XMLCh* XMLUri::getScheme() const
{
return fScheme;
}
inline const XMLCh* XMLUri::getUserInfo() const
{
return fUserInfo;
}
inline const XMLCh* XMLUri::getHost() const
{
return fHost;
}
inline int XMLUri::getPort() const
{
return fPort;
}
inline const XMLCh* XMLUri::getRegBasedAuthority() const
{
return fRegAuth;
}
inline const XMLCh* XMLUri::getPath() const
{
return fPath;
}
inline const XMLCh* XMLUri::getQueryString() const
{
return fQueryString;
}
inline const XMLCh* XMLUri::getFragment() const
{
return fFragment;
}
inline const XMLCh* XMLUri::getUriText() const
{
//
// Fault it in if not already. Since this is a const method and we
// can't use mutable members due the compilers we have to support,
// we have to cast off the constness.
//
if (!fURIText)
((XMLUri*)this)->buildFullText();
return fURIText;
}
// ---------------------------------------------------------------------------
// XMLUri: Helper methods
// ---------------------------------------------------------------------------
inline bool XMLUri::isReservedOrUnreservedCharacter(const XMLCh theChar)
{
return (XMLString::isAlphaNum(theChar) ||
XMLString::indexOf(MARK_OR_RESERVED_CHARACTERS, theChar) != -1);
}
inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
{
return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
}
inline bool XMLUri::isPathCharacter(const XMLCh theChar)
{
return (XMLString::indexOf(PATH_CHARACTERS, theChar) != -1);
}
inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
{
return (XMLString::isAlphaNum(theChar) ||
XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,63 @@
/*
* 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: XMLWin1252Transcoder.hpp 570552 2007-08-28 19:57:36Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLWIN1252TRANSCODER_HPP)
#define XERCESC_INCLUDE_GUARD_XMLWIN1252TRANSCODER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XML256TableTranscoder.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class provides an implementation of the XMLTranscoder interface
// for the Windows variant of Latin1, called Windows-1252. Its close to
// Latin1, but is somewhat different.
//
class XMLUTIL_EXPORT XMLWin1252Transcoder : public XML256TableTranscoder
{
public :
// -----------------------------------------------------------------------
// Public constructors and destructor
// -----------------------------------------------------------------------
XMLWin1252Transcoder
(
const XMLCh* const encodingName
, const XMLSize_t blockSize
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~XMLWin1252Transcoder();
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLWin1252Transcoder();
XMLWin1252Transcoder(const XMLWin1252Transcoder&);
XMLWin1252Transcoder& operator=(const XMLWin1252Transcoder&);
};
XERCES_CPP_NAMESPACE_END
#endif

Some files were not shown because too many files have changed in this diff Show More