You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/05/16 17:25:47 UTC
cvs commit: xml-xerces/c/src/util Base64.cpp Base64.hpp HexBin.cpp HexBin.hpp Makefile.in
tng 01/05/16 08:25:47
Modified: c/src/util Makefile.in
Added: c/src/util Base64.cpp Base64.hpp HexBin.cpp HexBin.hpp
Log:
Schema: Add Base64 and HexBin. By Pei Yong Zhang.
Revision Changes Path
1.35 +7 -0 xml-xerces/c/src/util/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/util/Makefile.in,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Makefile.in 2001/05/11 13:26:27 1.34
+++ Makefile.in 2001/05/16 15:25:40 1.35
@@ -55,6 +55,9 @@
#
#
# $Log: Makefile.in,v $
+# Revision 1.35 2001/05/16 15:25:40 tng
+# Schema: Add Base64 and HexBin. By Pei Yong Zhang.
+#
# Revision 1.34 2001/05/11 13:26:27 tng
# Copyright update.
#
@@ -251,6 +254,7 @@
UTIL_CPP_PUBHEADERS = \
ArrayIndexOutOfBoundsException.hpp \
AutoSense.hpp \
+ Base64.hpp \
BinFileInputStream.hpp \
BinInputStream.hpp \
BinMemInputStream.hpp \
@@ -262,6 +266,7 @@
HashBase.hpp \
HashXMLCh.hpp \
HashPtr.hpp \
+ HexBin.hpp \
IOException.hpp \
IllegalArgumentException.hpp \
InvalidCastException.hpp \
@@ -340,6 +345,7 @@
XMLDeleterFor.c
UTIL_CPP_OBJECTS = \
+ Base64.$(TO) \
BinFileInputStream.$(TO) \
BinInputStream.$(TO) \
BinMemInputStream.$(TO) \
@@ -347,6 +353,7 @@
HashXMLCh.$(TO) \
HashPtr.$(TO) \
HeaderDummy.$(TO) \
+ HexBin.$(TO) \
KVStringPair.$(TO) \
Mutexes.$(TO) \
PlatformUtils.$(TO) \
1.1 xml-xerces/c/src/util/Base64.cpp
Index: Base64.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: Base64.cpp,v $
* Revision 1.1 2001/05/16 15:25:36 tng
* Schema: Add Base64 and HexBin. By Pei Yong Zhang.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/Base64.hpp>
#include <util/XMLString.hpp>
#include <util/Janitor.hpp>
#include <util/PlatformUtils.hpp>
#include <util/TransService.hpp>
// ---------------------------------------------------------------------------
// constants
// ---------------------------------------------------------------------------
static const int BASELENGTH = 255;
static const int FOURBYTE = 4;
// ---------------------------------------------------------------------------
// class data member
// ---------------------------------------------------------------------------
bool Base64::isInitialized = false;
XMLCh Base64::base64Alphabet[BASELENGTH];
//
// delete the buffer allocated by decode() if
// decoding is successfully done.
//
int Base64::getDataLength(const XMLCh* const base64Data)
{
XMLCh* decodedData = decode(base64Data);
if ( !decodedData )
return -1;
int base64Len = XMLString::stringLen(decodedData);
delete[] decodedData;
return base64Len;
}
//
// return 0(null) if invalid data found.
// return the buffer containning decoded data otherwise
// the caller is responsible for the de-allocation of the
// buffer returned.
//
// temporary data, normalizedBase64Data, is ALWAYS released by this function.
//
XMLCh* Base64::decode(const XMLCh* const base64Data)
{
if (!isInitialized)
init();
if (( base64Data == 0 ) || ( *base64Data == 0 ))
return 0;
//
// remove whitespaces from the base64Data
//
XMLCh* normalizedBase64Data = XMLString::replicate(base64Data);
XMLString::trim(normalizedBase64Data);
ArrayJanitor<XMLCh> jan(normalizedBase64Data);
//
// check the length: should be divisible by four
//
int strLen = XMLString::stringLen(normalizedBase64Data);
if (strLen%FOURBYTE != 0)
return 0;
int numberQuadruple = strLen/FOURBYTE;
if (numberQuadruple == 0)
return 0;
//
// convert the quadruplet(s) to triplet(s)
//
XMLCh d1, d2, d3, d4;
XMLCh b1, b2, b3, b4;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
XMLCh *decodedData = new XMLCh[numberQuadruple*3+1];
//
// Prcess all quadruple(s) except for the last
//
for (; i < numberQuadruple-1; i++)
{
if (!isData( (d1 = normalizedBase64Data[dataIndex++]) )||
!isData( (d2 = normalizedBase64Data[dataIndex++]) )||
!isData( (d3 = normalizedBase64Data[dataIndex++]) )||
!isData( (d4 = normalizedBase64Data[dataIndex++]) ))
{
delete[] decodedData;
return 0;//if found "no data" just return null
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = set1stOctect(b1, b2);
decodedData[encodedIndex++] = set2ndOctect(b2, b3);
decodedData[encodedIndex++] = set3rdOctect(b3, b4);
}
//
// process the last Quadruple
// the first two octets
if (!isData( (d1 = normalizedBase64Data[dataIndex++]) ) ||
!isData( (d2 = normalizedBase64Data[dataIndex++]) ))
{
delete[] decodedData;
return 0;//if found "no data" just return null
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
// the last two octets
d3 = normalizedBase64Data[dataIndex++];
d4 = normalizedBase64Data[dataIndex++];
if (!isData( d3 ) || !isData( d4 ))
{
//Check if they are PAD characters
if (isPad( d3 ) && isPad( d4 ))
{
//Two PAD e.g. 3c[Pad][Pad]
if ((b2 & 0xf) != 0)//last 4 bits should be zero
{
delete[] decodedData;
return 0;
}
decodedData[encodedIndex++] = set1stOctect(b1, b2);
decodedData[encodedIndex] = 0;
}
else if (!isPad( d3) && isPad(d4))
{
//One PAD e.g. 3cQ[Pad]
b3 = base64Alphabet[ d3 ];
if ((b3 & 0x3) != 0)//last 2 bits should be zero
{
delete[] decodedData;
return 0;
}
decodedData[encodedIndex++] = set1stOctect(b1, b2);
decodedData[encodedIndex++] = set2ndOctect(b2, b3);
decodedData[encodedIndex] = 0;
}
else
{
delete[] decodedData;
return 0;//an error like "3c[Pad]r", "3cdX", "3cXd", "3cXX" where X is non data
}
}
else
{ //No PAD e.g 3cQl
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = set1stOctect(b1, b2);
decodedData[encodedIndex++] = set2ndOctect(b2, b3);
decodedData[encodedIndex++] = set3rdOctect(b3, b4);
decodedData[encodedIndex] = 0;
}
return decodedData;
}
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void Base64::init()
{
if (isInitialized)
return;
int i;
// [0] = -1, [255] = -1
for ( i = 0; i < BASELENGTH; i++ )
base64Alphabet[i] = (XMLCh)-1;
// [65] = 0, [90] = 25
for ( i = chLatin_Z; i >= chLatin_A; i-- )
base64Alphabet[i] = (XMLCh)( i - chLatin_A );
// [97] = 0 + 26 = 26, [122] = 25 + 26 = 51
for ( i = chLatin_z; i >= chLatin_a; i-- )
base64Alphabet[i] = (XMLCh)( i - chLatin_a + 26 );
// [48] = 0 + 52, [57] = 9 + 52
for ( i = chDigit_9; i >= chDigit_0; i-- )
base64Alphabet[i] = (XMLCh)( i- chDigit_0 + 52 );
// [43] = 62
// [47] = 63
base64Alphabet[chPlus] = (XMLCh) 62;
base64Alphabet[chForwardSlash] = (XMLCh) 63;
isInitialized=true;
//
// index: 0 42 43 47 48 57 65 90 97 122 254
// char: '+' '/' '0' '9' 'A' 'Z' 'a' 'z'
// value: -1 ... -1 62 -1... 63 52 61 0 25 -1.. 26 51 -1...
//
}
inline bool Base64::isData(const XMLCh& octect)
{
// sanity check to avoid out-of-bound index
if (( octect >= BASELENGTH ) || ( octect < 0 ))
return false;
return( base64Alphabet[octect] != (XMLCh) -1);
}
1.1 xml-xerces/c/src/util/Base64.hpp
Index: Base64.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: Base64.hpp,v 1.1 2001/05/16 15:25:37 tng Exp $
*/
#ifndef BASE64_HPP
#define BASE64_HPP
#include <util/XercesDefs.hpp>
#include <util/XMLUniDefs.hpp>
//
// 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 :
//@{
/**
* Get data length
* returns length of decoded data given an
* array containing encoded data.
*
* @param base64Data Byte array containing Base64 data
* @return a -1 would be return if not
*/
static int getDataLength(const XMLCh* const base64Data);
/**
* Decodes Base64 data into octects
*
* @param binaryData Byte array containing Base64 data
* @return Array containind decoded data.
*/
static XMLCh* decode(const XMLCh* const base64Data);
//@}
private :
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
static void init();
static bool isData(const XMLCh& octect);
static bool isPad(const XMLCh& octect);
static XMLCh set1stOctect(const XMLCh&, const XMLCh&);
static XMLCh set2ndOctect(const XMLCh&, const XMLCh&);
static XMLCh set3rdOctect(const XMLCh&, const XMLCh&);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Base64();
Base64(const Base64&);
// -----------------------------------------------------------------------
// Private data members
//
// isInitialized
//
// set once hexNumberTable is initalized.
//
// base64Alphabet
//
// table used in decoding base64
//
// -----------------------------------------------------------------------
static bool isInitialized;
static XMLCh base64Alphabet[];
};
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
inline bool Base64::isPad(const XMLCh& octect)
{
return(octect == chEqual);
}
inline XMLCh Base64::set1stOctect(const XMLCh& b1, const XMLCh& b2)
{
return (( b1 <<2 ) | ( b2>>4 ));
}
inline XMLCh Base64::set2ndOctect(const XMLCh& b2, const XMLCh& b3)
{
return ((( b2 & 0xf )<<4 ) | (( b3>>2 ) & 0xf));
}
inline XMLCh Base64::set3rdOctect(const XMLCh& b3, const XMLCh& b4)
{
return (( b3<<6 ) | b4 );
}
#endif
1.1 xml-xerces/c/src/util/HexBin.cpp
Index: HexBin.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: HexBin.cpp,v $
* Revision 1.1 2001/05/16 15:25:38 tng
* Schema: Add Base64 and HexBin. By Pei Yong Zhang.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/HexBin.hpp>
#include <util/XMLUniDefs.hpp>
#include <util/XMLString.hpp>
// ---------------------------------------------------------------------------
// constants
// ---------------------------------------------------------------------------
static const int BASELENGTH = 255;
// ---------------------------------------------------------------------------
// class data member
// ---------------------------------------------------------------------------
bool HexBin::hexNumberTable[BASELENGTH];
bool HexBin::isInitialized = false;
int HexBin::getDataLength(const XMLCh* const hexData)
{
if (!isArrayByteHex(hexData))
return -1;
return XMLString::stringLen(hexData)/2;
}
bool HexBin::isArrayByteHex(const XMLCh* const hexData)
{
if ( !isInitialized )
init();
if (( hexData == 0 ) || ( *hexData == 0 )) // zero length
return false;
int strLen = XMLString::stringLen(hexData);
if ( strLen%2 != 0 )
return false;
for ( int i = 0; i < strLen; i++ )
if( !isHex(hexData[i]) )
return false;
return true;
}
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
bool HexBin::isHex(const XMLCh& octect)
{
// sanity check to avoid out-of-bound index
if (( octect >= BASELENGTH ) || ( octect < 0 ))
return false;
return (hexNumberTable[octect]);
}
void HexBin::init()
{
if ( isInitialized )
return;
int i;
for ( i = 0; i < BASELENGTH; i++ )
hexNumberTable[i] = false;
for ( i = chDigit_9; i >= chDigit_0; i-- )
hexNumberTable[i] = true;
for ( i = chLatin_F; i >= chLatin_A; i-- )
hexNumberTable[i] = true;
for ( i = chLatin_f; i >= chLatin_a; i-- )
hexNumberTable[i] = true;
isInitialized = true;
}
1.1 xml-xerces/c/src/util/HexBin.hpp
Index: HexBin.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: HexBin.hpp,v 1.1 2001/05/16 15:25:38 tng Exp $
*/
#ifndef HEXBIN_HPP
#define HEXBIN_HPP
#include <util/XercesDefs.hpp>
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);
//@}
private :
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
static void init();
static bool isHex(const XMLCh& octect);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
HexBin();
HexBin(const HexBin&);
// -----------------------------------------------------------------------
// Private data members
//
// isInitialized
//
// set once hexNumberTable is initalized.
//
// hexNumberTable
//
// arrany holding valid hexNumber character.
//
// -----------------------------------------------------------------------
static bool isInitialized;
static bool hexNumberTable[];
};
#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org