You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2001/03/02 20:26:56 UTC
cvs commit: xml-xerces/c/src/util/regx ASCIIRangeFactory.cpp ASCIIRangeFactory.hpp BlockRangeFactory.cpp BlockRangeFactory.hpp Makefile.in ParserForXMLSchema.cpp ParserForXMLSchema.hpp RangeFactory.cpp RangeFactory.hpp RangeToken.cpp RangeToken.hpp RegxDefs.hpp UnicodeRangeFactory.cpp UnicodeRangeFactory.hpp XMLRangeFactory.cpp XMLRangeFactory.hpp XMLUniCharacter.cpp
knoaman 01/03/02 11:26:55
Added: c/src/util/regx ASCIIRangeFactory.cpp ASCIIRangeFactory.hpp
BlockRangeFactory.cpp BlockRangeFactory.hpp
Makefile.in ParserForXMLSchema.cpp
ParserForXMLSchema.hpp RangeFactory.cpp
RangeFactory.hpp RangeToken.cpp RangeToken.hpp
RegxDefs.hpp UnicodeRangeFactory.cpp
UnicodeRangeFactory.hpp XMLRangeFactory.cpp
XMLRangeFactory.hpp XMLUniCharacter.cpp
Log:
Schema: Regular expression handling part II
Revision Changes Path
1.1 xml-xerces/c/src/util/regx/ASCIIRangeFactory.cpp
Index: ASCIIRangeFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: ASCIIRangeFactory.cpp,v $
* Revision 1.1 2001/03/02 19:26:39 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/ASCIIRangeFactory.hpp>
#include <util/regx/RegxDefs.hpp>
#include <util/regx/TokenFactory.hpp>
#include <util/regx/RangeToken.hpp>
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
bool ASCIIRangeFactory::fRangesCreated = false;
bool ASCIIRangeFactory::fKeywordsInitialized = false;
// ---------------------------------------------------------------------------
// ASCIIRangeFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
ASCIIRangeFactory::ASCIIRangeFactory() {
}
ASCIIRangeFactory::~ASCIIRangeFactory() {
}
// ---------------------------------------------------------------------------
// ASCIIRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void ASCIIRangeFactory::buildRanges() {
if (fRangesCreated)
return;
// Create space ranges
RangeToken* tok = TokenFactory::instance()->createRange();
tok->addRange(chHTab, chHTab);
tok->addRange(chLF, chLF);
tok->addRange(chFF, chFF);
tok->addRange(chCR, chCR);
tok->addRange(chSpace, chSpace);
setRangeToken(fgASCIISpace, tok);
// Create digits ranges
tok = TokenFactory::instance()->createRange();
tok->addRange(chDigit_0, chDigit_9);
setRangeToken(fgASCIIDigit, tok);
// Create word ranges
tok = TokenFactory::instance()->createRange();
tok->addRange(chDigit_0, chDigit_9);
tok->addRange(chLatin_A, chLatin_Z);
tok->addRange(chUnderscore, chUnderscore);
tok->addRange(chLatin_a, chLatin_z);
setRangeToken(fgASCIIWord, tok);
// Create xdigit ranges
tok = TokenFactory::instance()->createRange();
tok->addRange(chDigit_0, chDigit_9);
tok->addRange(chLatin_A, chLatin_F);
tok->addRange(chLatin_a, chLatin_a);
setRangeToken(fgASCIIXDigit, tok);
// Create ascii ranges
tok = TokenFactory::instance()->createRange();
tok->addRange(0x00, 0x7F);
setRangeToken(fgASCII, tok);
fRangesCreated = true;
}
// ---------------------------------------------------------------------------
// ASCIIRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void ASCIIRangeFactory::initializeKeywordMap() {
if (fKeywordsInitialized)
return;
addKeywordMap(fgASCIISpace, fgASCIICategory);
addKeywordMap(fgASCIIDigit, fgASCIICategory);
addKeywordMap(fgASCIIWord, fgASCIICategory);
addKeywordMap(fgASCIIXDigit, fgASCIICategory);
addKeywordMap(fgASCII, fgASCIICategory);
fKeywordsInitialized = true;
}
/**
* End of file ASCIIRangeFactory.cpp
*/
1.1 xml-xerces/c/src/util/regx/ASCIIRangeFactory.hpp
Index: ASCIIRangeFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: ASCIIRangeFactory.hpp,v 1.1 2001/03/02 19:26:41 knoaman Exp $
*/
#if !defined(ASCIIRANGEFACTORY_HPP)
#define ASCIIRANGEFACTORY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RangeFactory.hpp>
class XMLUTIL_EXPORT ASCIIRangeFactory: public RangeFactory {
public:
// -----------------------------------------------------------------------
// Constructors and operators
// -----------------------------------------------------------------------
ASCIIRangeFactory();
~ASCIIRangeFactory();
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
void initializeKeywordMap();
protected:
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
void buildRanges();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ASCIIRangeFactory(const ASCIIRangeFactory&);
void operator=(const ASCIIRangeFactory&);
static bool fRangesCreated;
static bool fKeywordsInitialized;
};
#endif
/**
* End file ASCIIRangeFactory.hpp
*/
1.1 xml-xerces/c/src/util/regx/BlockRangeFactory.cpp
Index: BlockRangeFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: BlockRangeFactory.cpp,v $
* Revision 1.1 2001/03/02 19:26:41 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/BlockRangeFactory.hpp>
#include <util/regx/TokenFactory.hpp>
#include <util/regx/RangeToken.hpp>
#include <util/regx/RegxDefs.hpp>
#include <util/XMLString.hpp>
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
bool BlockRangeFactory::fRangesCreated = false;
bool BlockRangeFactory::fKeywordsInitialized = false;
// ---------------------------------------------------------------------------
// Local static data
// ---------------------------------------------------------------------------
const int SIZE = 68;
const XMLCh fgBlockNames[][SIZE] =
{
{ chLatin_B, chLatin_a, chLatin_s, chLatin_i, chLatin_c, chSpace, chLatin_L, chLatin_a,
chLatin_t, chLatin_i, chLatin_n, chNull },
{ chLatin_L, chLatin_a, chLatin_t, chLatin_i, chLatin_n, chDash, chDigit_1, chSpace,
chLatin_S, chLatin_u, chLatin_p, chLatin_p, chLatin_l, chLatin_e, chLatin_m, chLatin_e,
chLatin_n, chLatin_t, chNull },
{ chLatin_L, chLatin_a, chLatin_t, chLatin_i, chLatin_n, chSpace, chLatin_E, chLatin_x,
chLatin_t, chLatin_e, chLatin_n, chLatin_d, chLatin_e, chLatin_d, chDash, chLatin_A,
chNull },
{ chLatin_L, chLatin_a, chLatin_t, chLatin_i, chLatin_n, chSpace, chLatin_E, chLatin_x,
chLatin_t, chLatin_e, chLatin_n, chLatin_d, chLatin_e, chLatin_d, chDash, chLatin_B,
chNull },
{ chLatin_I, chLatin_P, chLatin_A, chSpace, chLatin_E, chLatin_x, chLatin_t, chLatin_e,
chLatin_n, chLatin_s, chLatin_i, chLatin_o, chLatin_n, chLatin_s, chNull },
{ chLatin_S, chLatin_p, chLatin_a, chLatin_c, chLatin_i, chLatin_n, chLatin_g, chSpace,
chLatin_M, chLatin_o, chLatin_d, chLatin_i, chLatin_f, chLatin_i, chLatin_e, chLatin_r,
chSpace, chLatin_L, chLatin_e, chLatin_t, chLatin_t, chLatin_e, chLatin_r, chLatin_s,
chNull },
{ chLatin_C, chLatin_o, chLatin_m, chLatin_b, chLatin_i, chLatin_n, chLatin_i, chLatin_n,
chLatin_g, chSpace, chLatin_D, chLatin_i, chLatin_a, chLatin_c, chLatin_r, chLatin_i,
chLatin_t, chLatin_i, chLatin_c, chLatin_a, chLatin_l, chSpace, chLatin_M, chLatin_a,
chLatin_r, chLatin_k, chLatin_s, chNull },
{ chLatin_G, chLatin_r, chLatin_e, chLatin_e, chLatin_k, chNull },
{ chLatin_C, chLatin_y, chLatin_r, chLatin_i, chLatin_l, chLatin_l, chLatin_i, chLatin_c,
chNull },
{ chLatin_A, chLatin_r, chLatin_m, chLatin_e, chLatin_n, chLatin_i, chLatin_a, chLatin_n,
chNull },
{ chLatin_H, chLatin_e, chLatin_b, chLatin_r, chLatin_e, chLatin_w, chNull },
{ chLatin_A, chLatin_r, chLatin_a, chLatin_b, chLatin_i, chLatin_c, chNull },
{ chLatin_D, chLatin_e, chLatin_v, chLatin_a, chLatin_n, chLatin_a, chLatin_g, chLatin_a,
chLatin_r, chLatin_i, chNull },
{ chLatin_B, chLatin_e, chLatin_n, chLatin_g, chLatin_a, chLatin_l, chLatin_i, chNull },
{ chLatin_G, chLatin_u, chLatin_r, chLatin_m, chLatin_u, chLatin_k, chLatin_h, chLatin_i,
chNull },
{ chLatin_G, chLatin_u, chLatin_j, chLatin_a, chLatin_r, chLatin_a, chLatin_t, chLatin_i,
chNull },
{ chLatin_O, chLatin_r, chLatin_i, chLatin_y, chLatin_a, chNull },
{ chLatin_T, chLatin_a, chLatin_m, chLatin_i, chLatin_l, chNull },
{ chLatin_T, chLatin_e, chLatin_l, chLatin_u, chLatin_g, chLatin_u, chNull },
{ chLatin_K, chLatin_a, chLatin_n, chLatin_n, chLatin_a, chLatin_d, chLatin_a, chNull },
{ chLatin_M, chLatin_a, chLatin_l, chLatin_a, chLatin_y, chLatin_a, chLatin_l, chLatin_a,
chLatin_m, chNull },
{ chLatin_T, chLatin_h, chLatin_a, chLatin_i, chNull },
{ chLatin_L, chLatin_a, chLatin_o, chNull },
{ chLatin_T, chLatin_i, chLatin_b, chLatin_e, chLatin_t, chLatin_a, chLatin_n, chNull },
{ chLatin_G, chLatin_e, chLatin_o, chLatin_r, chLatin_g, chLatin_i, chLatin_a, chLatin_n,
chNull },
{ chLatin_H, chLatin_a, chLatin_n, chLatin_g, chLatin_u, chLatin_l, chSpace, chLatin_J,
chLatin_a, chLatin_m, chLatin_o, chNull },
{ chLatin_L, chLatin_a, chLatin_t, chLatin_i, chLatin_n, chSpace, chLatin_E, chLatin_x,
chLatin_t, chLatin_e, chLatin_n, chLatin_d, chLatin_e, chLatin_d, chSpace, chLatin_A,
chLatin_d, chLatin_d, chLatin_i, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chLatin_a,
chLatin_l, chNull },
{ chLatin_G, chLatin_r, chLatin_e, chLatin_e, chLatin_k, chSpace, chLatin_E, chLatin_x,
chLatin_t, chLatin_e, chLatin_n, chLatin_d, chLatin_e, chLatin_d, chNull },
{ chLatin_G, chLatin_e, chLatin_n, chLatin_e, chLatin_r, chLatin_a, chLatin_l, chSpace,
chLatin_P, chLatin_u, chLatin_n, chLatin_c, chLatin_t, chLatin_u, chLatin_a, chLatin_t,
chLatin_i, chLatin_o, chLatin_n, chNull },
{ chLatin_S, chLatin_u, chLatin_p, chLatin_e, chLatin_r, chLatin_s, chLatin_c, chLatin_r,
chLatin_i, chLatin_p, chLatin_t, chLatin_s, chSpace, chLatin_a, chLatin_n, chLatin_d,
chSpace, chLatin_S, chLatin_u, chLatin_b, chLatin_s, chLatin_c, chLatin_r, chLatin_i,
chLatin_p, chLatin_t, chLatin_s, chNull },
{ chLatin_C, chLatin_u, chLatin_r, chLatin_r, chLatin_e, chLatin_n, chLatin_c, chLatin_y,
chSpace, chLatin_S, chLatin_y, chLatin_m, chLatin_b, chLatin_o, chLatin_l, chLatin_s,
chNull },
{ chLatin_C, chLatin_o, chLatin_m, chLatin_b, chLatin_i, chLatin_n, chLatin_i, chLatin_n,
chLatin_g, chSpace, chLatin_M, chLatin_a, chLatin_r, chLatin_k, chLatin_s, chSpace,
chLatin_f, chLatin_o, chLatin_r, chSpace, chLatin_S, chLatin_y, chLatin_m, chLatin_b,
chLatin_o, chLatin_l, chLatin_s, chNull },
{ chLatin_L, chLatin_e, chLatin_t, chLatin_t, chLatin_e, chLatin_r, chLatin_l, chLatin_i,
chLatin_k, chLatin_e, chSpace, chLatin_S, chLatin_y, chLatin_m, chLatin_b, chLatin_o,
chLatin_l, chLatin_s, chNull },
{ chLatin_N, chLatin_u, chLatin_m, chLatin_b, chLatin_e, chLatin_r, chSpace, chLatin_F,
chLatin_o, chLatin_r, chLatin_m, chLatin_s, chNull },
{ chLatin_A, chLatin_r, chLatin_r, chLatin_o, chLatin_w, chLatin_s, chNull },
{ chLatin_M, chLatin_a, chLatin_t, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chLatin_t,
chLatin_i, chLatin_c, chLatin_a, chLatin_l, chSpace, chLatin_O, chLatin_p, chLatin_e,
chLatin_r, chLatin_a, chLatin_t, chLatin_o, chLatin_r, chLatin_s, chNull },
{ chLatin_M, chLatin_i, chLatin_s, chLatin_c, chLatin_e, chLatin_l, chLatin_l, chLatin_a,
chLatin_n, chLatin_e, chLatin_o, chLatin_u, chLatin_s, chSpace, chLatin_T, chLatin_e,
chLatin_c, chLatin_h, chLatin_n, chLatin_i, chLatin_c, chLatin_a, chLatin_l, chNull },
{ chLatin_C, chLatin_o, chLatin_n, chLatin_t, chLatin_r, chLatin_o, chLatin_l, chSpace,
chLatin_P, chLatin_i, chLatin_c, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chLatin_s,
chNull },
{ chLatin_O, chLatin_p, chLatin_t, chLatin_i, chLatin_c, chLatin_a, chLatin_l, chSpace,
chLatin_C, chLatin_h, chLatin_a, chLatin_r, chLatin_a, chLatin_c, chLatin_t, chLatin_e,
chLatin_r, chSpace, chLatin_R, chLatin_e, chLatin_c, chLatin_o, chLatin_g, chLatin_n,
chLatin_i, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull },
{ chLatin_E, chLatin_n, chLatin_c, chLatin_l, chLatin_o, chLatin_s, chLatin_e, chLatin_d,
chSpace, chLatin_A, chLatin_l, chLatin_p, chLatin_h, chLatin_a, chLatin_n, chLatin_u,
chLatin_m, chLatin_e, chLatin_r, chLatin_i, chLatin_c, chLatin_s, chNull },
{ chLatin_B, chLatin_o, chLatin_x, chSpace, chLatin_D, chLatin_r, chLatin_a, chLatin_w,
chLatin_i, chLatin_n, chLatin_g, chNull },
{ chLatin_B, chLatin_l, chLatin_o, chLatin_c, chLatin_k, chSpace, chLatin_E, chLatin_l,
chLatin_e, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chLatin_s, chNull },
{ chLatin_G, chLatin_e, chLatin_o, chLatin_m, chLatin_e, chLatin_t, chLatin_r, chLatin_i,
chLatin_c, chSpace, chLatin_S, chLatin_h, chLatin_a, chLatin_p, chLatin_e, chLatin_s,
chNull },
{ chLatin_M, chLatin_i, chLatin_s, chLatin_c, chLatin_e, chLatin_l, chLatin_l, chLatin_a,
chLatin_n, chLatin_e, chLatin_o, chLatin_u, chLatin_s, chSpace, chLatin_S, chLatin_y,
chLatin_m, chLatin_b, chLatin_o, chLatin_l, chLatin_s, chNull },
{ chLatin_D, chLatin_i, chLatin_n, chLatin_g, chLatin_b, chLatin_a, chLatin_t, chLatin_s,
chNull },
{ chLatin_C, chLatin_J, chLatin_K, chSpace, chLatin_S, chLatin_y, chLatin_m, chLatin_b,
chLatin_o, chLatin_l, chLatin_s, chSpace, chLatin_a, chLatin_n, chLatin_d, chSpace,
chLatin_P, chLatin_u, chLatin_n, chLatin_c, chLatin_t, chLatin_u, chLatin_a, chLatin_t,
chLatin_i, chLatin_o, chLatin_n, chNull },
{ chLatin_H, chLatin_i, chLatin_r, chLatin_a, chLatin_g, chLatin_a, chLatin_n, chLatin_a,
chNull },
{ chLatin_K, chLatin_a, chLatin_t, chLatin_a, chLatin_k, chLatin_a, chLatin_n, chLatin_a,
chNull },
{ chLatin_B, chLatin_o, chLatin_p, chLatin_o, chLatin_m, chLatin_o, chLatin_f, chLatin_o,
chNull },
{ chLatin_H, chLatin_a, chLatin_n, chLatin_g, chLatin_u, chLatin_l, chSpace, chLatin_C,
chLatin_o, chLatin_m, chLatin_p, chLatin_a, chLatin_t, chLatin_i, chLatin_b, chLatin_i,
chLatin_l, chLatin_i, chLatin_t, chLatin_y, chSpace, chLatin_J, chLatin_a, chLatin_m,
chLatin_o, chNull },
{ chLatin_K, chLatin_a, chLatin_n, chLatin_b, chLatin_u, chLatin_n, chNull },
{ chLatin_E, chLatin_n, chLatin_c, chLatin_l, chLatin_o, chLatin_s, chLatin_e, chLatin_d,
chSpace, chLatin_C, chLatin_J, chLatin_K, chSpace, chLatin_L, chLatin_e, chLatin_t,
chLatin_t, chLatin_e, chLatin_r, chLatin_s, chSpace, chLatin_a, chLatin_n, chLatin_d,
chSpace, chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, chLatin_s, chNull },
{ chLatin_C, chLatin_J, chLatin_K, chSpace, chLatin_C, chLatin_o, chLatin_m, chLatin_p,
chLatin_a, chLatin_t, chLatin_i, chLatin_b, chLatin_i, chLatin_l, chLatin_i, chLatin_t,
chLatin_y, chNull },
{ chLatin_C, chLatin_J, chLatin_K, chSpace, chLatin_U, chLatin_n, chLatin_i, chLatin_f,
chLatin_i, chLatin_e, chLatin_d, chSpace, chLatin_I, chLatin_d, chLatin_e, chLatin_o,
chLatin_g, chLatin_r, chLatin_a, chLatin_p, chLatin_h, chLatin_s, chNull },
{ chLatin_H, chLatin_a, chLatin_n, chLatin_g, chLatin_u, chLatin_l, chSpace, chLatin_S,
chLatin_y, chLatin_l, chLatin_l, chLatin_a, chLatin_b, chLatin_l, chLatin_e, chLatin_s,
chNull },
{ chLatin_H, chLatin_i, chLatin_g, chLatin_h, chSpace, chLatin_S, chLatin_u, chLatin_r,
chLatin_r, chLatin_o, chLatin_g, chLatin_a, chLatin_t, chLatin_e, chLatin_s, chNull },
{ chLatin_H, chLatin_i, chLatin_g, chLatin_h, chSpace, chLatin_P, chLatin_r, chLatin_i,
chLatin_v, chLatin_a, chLatin_t, chLatin_e, chSpace, chLatin_U, chLatin_s, chLatin_e,
chSpace, chLatin_S, chLatin_u, chLatin_r, chLatin_r, chLatin_o, chLatin_g, chLatin_a,
chLatin_t, chLatin_e, chLatin_s, chNull },
{ chLatin_L, chLatin_o, chLatin_w, chSpace, chLatin_S, chLatin_u, chLatin_r, chLatin_r,
chLatin_o, chLatin_g, chLatin_a, chLatin_t, chLatin_e, chLatin_s, chNull },
{ chLatin_P, chLatin_r, chLatin_i, chLatin_v, chLatin_a, chLatin_t, chLatin_e, chSpace,
chLatin_U, chLatin_s, chLatin_e, chNull },
{ chLatin_C, chLatin_J, chLatin_K, chSpace, chLatin_C, chLatin_o, chLatin_m, chLatin_p,
chLatin_a, chLatin_t, chLatin_i, chLatin_b, chLatin_i, chLatin_l, chLatin_i, chLatin_t,
chLatin_y, chSpace, chLatin_I, chLatin_d, chLatin_e, chLatin_o, chLatin_g, chLatin_r,
chLatin_a, chLatin_p, chLatin_h, chLatin_s, chNull },
{ chLatin_A, chLatin_l, chLatin_p, chLatin_h, chLatin_a, chLatin_b, chLatin_e, chLatin_t,
chLatin_i, chLatin_c, chSpace, chLatin_P, chLatin_r, chLatin_e, chLatin_s, chLatin_e,
chLatin_n, chLatin_t, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chSpace,
chLatin_F, chLatin_o, chLatin_r, chLatin_m, chLatin_s, chNull },
{ chLatin_A, chLatin_r, chLatin_a, chLatin_b, chLatin_i, chLatin_c, chSpace, chLatin_P,
chLatin_r, chLatin_e, chLatin_s, chLatin_e, chLatin_n, chLatin_t, chLatin_a, chLatin_t,
chLatin_i, chLatin_o, chLatin_n, chSpace, chLatin_F, chLatin_o, chLatin_r, chLatin_m,
chLatin_s, chDash, chLatin_A, chNull },
{ chLatin_C, chLatin_o, chLatin_m, chLatin_b, chLatin_i, chLatin_n, chLatin_i, chLatin_n,
chLatin_g, chSpace, chLatin_H, chLatin_a, chLatin_l, chLatin_f, chSpace, chLatin_M,
chLatin_a, chLatin_r, chLatin_k, chLatin_s, chNull },
{ chLatin_C, chLatin_J, chLatin_K, chSpace, chLatin_C, chLatin_o, chLatin_m, chLatin_p,
chLatin_a, chLatin_t, chLatin_i, chLatin_b, chLatin_i, chLatin_l, chLatin_i, chLatin_t,
chLatin_y, chSpace, chLatin_F, chLatin_o, chLatin_r, chLatin_m, chLatin_s, chNull },
{ chLatin_S, chLatin_m, chLatin_a, chLatin_l, chLatin_l, chSpace, chLatin_F, chLatin_o,
chLatin_r, chLatin_m, chSpace, chLatin_V, chLatin_a, chLatin_r, chLatin_i, chLatin_a,
chLatin_n, chLatin_t, chLatin_s, chNull },
{ chLatin_A, chLatin_r, chLatin_a, chLatin_b, chLatin_i, chLatin_c, chSpace, chLatin_P,
chLatin_r, chLatin_e, chLatin_s, chLatin_e, chLatin_n, chLatin_t, chLatin_a, chLatin_t,
chLatin_i, chLatin_o, chLatin_n, chSpace, chLatin_F, chLatin_o, chLatin_r, chLatin_m,
chLatin_s, chDash, chLatin_B, chNull },
{ chLatin_S, chLatin_p, chLatin_e, chLatin_c, chLatin_i, chLatin_a, chLatin_l, chLatin_s,
chNull },
{ chLatin_H, chLatin_a, chLatin_l, chLatin_f, chLatin_w, chLatin_i, chLatin_d, chLatin_t,
chLatin_h, chSpace, chLatin_a, chLatin_n, chLatin_d, chSpace, chLatin_F, chLatin_u,
chLatin_l, chLatin_l, chLatin_w, chLatin_i, chLatin_d, chLatin_t, chLatin_h, chSpace,
chLatin_F, chLatin_o, chLatin_r, chLatin_m, chLatin_s, chNull }
};
const XMLCh blockRanges[] =
{
0x0000,0x007F,0x0080,0x00FF,0x0100,0x017F,0x0180,0x024F,0x0250,0x02AF,0x02B0,0x02FF,
0x0300,0x036F,0x0370,0x03FF,0x0400,0x04FF,0x0530,0x058F,0x0590,0x05FF,0x0600,0x06FF,
0x0900,0x097F,0x0980,0x09FF,0x0A00,0x0A7F,0x0A80,0x0AFF,0x0B00,0x0B7F,0x0B80,0x0BFF,
0x0C00,0x0C7F,0x0C80,0x0CFF,0x0D00,0x0D7F,0x0E00,0x0E7F,0x0E80,0x0EFF,0x0F00,0x0FBF,
0x10A0,0x10FF,0x1100,0x11FF,0x1E00,0x1EFF,0x1F00,0x1FFF,0x2000,0x206F,0x2070,0x209F,
0x20A0,0x20CF,0x20D0,0x20FF,0x2100,0x214F,0x2150,0x218F,0x2190,0x21FF,0x2200,0x22FF,
0x2300,0x23FF,0x2400,0x243F,0x2440,0x245F,0x2460,0x24FF,0x2500,0x257F,0x2580,0x259F,
0x25A0,0x25FF,0x2600,0x26FF,0x2700,0x27BF,0x3000,0x303F,0x3040,0x309F,0x30A0,0x30FF,
0x3100,0x312F,0x3130,0x318F,0x3190,0x319F,0x3200,0x32FF,0x3300,0x33FF,0x4E00,0x9FFF,
0xAC00,0xD7A3,0xD800,0xDB7F,0xDB80,0xDBFF,0xDC00,0xDFFF,0xE000,0xF8FF,0xF900,0xFAFF,
0xFB00,0xFB4F,0xFB50,0xFDFF,0xFE20,0xFE2F,0xFE30,0xFE4F,0xFE50,0xFE6F,0xFE70,0xFEFE,
0xFEFF,0xFEFF,0xFF00,0xFFEF, chNull
};
// ---------------------------------------------------------------------------
// BlockRangeFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
BlockRangeFactory::BlockRangeFactory() {
}
BlockRangeFactory::~BlockRangeFactory() {
}
// ---------------------------------------------------------------------------
// BlockRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void BlockRangeFactory::buildRanges() {
if (fRangesCreated)
return;
for (int i=0; i < SIZE; i++) {
RangeToken* tok = TokenFactory::instance()->createRange();
tok->addRange(blockRanges[i*2], blockRanges[(i*2)+1]);
if (XMLString::compareString((XMLCh*)fgBlockNames[i] , (XMLCh*) fgBlockSpecials) == 0) {
tok->addRange(0xFFF0, 0xFFFd);
}
setRangeToken(fgBlockNames[i], tok);
}
fRangesCreated = true;
}
// ---------------------------------------------------------------------------
// BlockRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void BlockRangeFactory::initializeKeywordMap() {
if (fKeywordsInitialized)
return;
for (int i=0; i< SIZE; i++) {
addKeywordMap(fgBlockNames[i], fgBlockCategory);
}
fKeywordsInitialized = true;
}
/**
* End of file BlockRangeFactory.cpp
*/
1.1 xml-xerces/c/src/util/regx/BlockRangeFactory.hpp
Index: BlockRangeFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: BlockRangeFactory.hpp,v 1.1 2001/03/02 19:26:42 knoaman Exp $
*/
#if !defined(BLOCKRANGEFACTORY_HPP)
#define BLOCKRANGEFACTORY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RangeFactory.hpp>
class XMLUTIL_EXPORT BlockRangeFactory: public RangeFactory {
public:
// -----------------------------------------------------------------------
// Constructors and operators
// -----------------------------------------------------------------------
BlockRangeFactory();
~BlockRangeFactory();
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
void initializeKeywordMap();
protected:
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
void buildRanges();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
BlockRangeFactory(const BlockRangeFactory&);
void operator=(const BlockRangeFactory&);
static bool fRangesCreated;
static bool fKeywordsInitialized;
};
#endif
/**
* End file BlockRangeFactory.hpp
*/
1.1 xml-xerces/c/src/util/regx/Makefile.in
Index: Makefile.in
===================================================================
# Generated automatically from Makefile.in by configure.
#
# The Apache Software License, Version 1.1
#
# Copyright (c) 1999-2000 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) 1999, International
# Business Machines, Inc., http://www.ibm.com . For more information
# on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
#
# $Log: Makefile.in,v $
# Revision 1.1 2001/03/02 19:26:43 knoaman
# Schema: Regular expression handling part II
#
# Revision 1.0 2001/01/26 19:50:51 knoaman
#
#
PLATFORM = @platform@
CC = @cc@
CXX = @cxx@
CXXFLAGS = @cxxflags@
CFLAGS = @cflags@
PREFIX = @prefix@
LDFLAGS = @ldflags@
LIBS = @libs@
OSVER = @osver@
USELIBWWW = @uselibwww@
MESSAGELOADER = @messageloader@
TRANSCODER = @transcoder@
NETACCESSOR = @netaccessor@
MODULE = util
SUBMODULE = regx
include ../../Makefile.incl
CPP_PUBHEADERS = RegxDefs.hpp \
UniCharTable.hpp \
Op.hpp \
OpFactory.hpp \
BMPattern.hpp \
Match.hpp \
RegxUtil.hpp \
RangeToken.hpp \
Token.hpp \
CharToken.hpp \
ClosureToken.hpp \
ConcatToken.hpp \
ConditionToken.hpp \
ModifierToken.hpp \
ParenToken.hpp \
StringToken.hpp \
UnionToken.hpp \
TokenInc.hpp \
XMLUniCharacter.hpp \
RangeFactory.hpp \
XMLRangeFactory.hpp \
BlockRangeFactory.hpp \
UnicodeRangeFactory.hpp \
ASCIIRangeFactory.hpp \
TokenFactory.hpp \
RegxParser.hpp \
ParserForXMLSchema.hpp \
RegularExpression.hpp
CPP_OBJECTS = Op.$(TO) \
OpFactory.$(TO) \
BMPattern.$(TO) \
Match.$(TO) \
RegxUtil.$(TO) \
RangeToken.$(TO) \
Token.$(TO) \
CharToken.$(TO) \
ClosureToken.$(TO) \
ConcatToken.$(TO) \
ConditionToken.$(TO) \
ModifierToken.$(TO) \
ParenToken.$(TO) \
StringToken.$(TO) \
UnionToken.$(TO) \
XMLUniCharacter.$(TO) \
RangeFactory.$(TO) \
XMLRangeFactory.$(TO) \
BlockRangeFactory.$(TO) \
UnicodeRangeFactory.$(TO) \
ASCIIRangeFactory.$(TO) \
TokenFactory.$(TO) \
RegxParser.$(TO) \
ParserForXMLSchema.$(TO) \
RegularExpression.$(TO)
include ../Makefile.util.submodule
1.1 xml-xerces/c/src/util/regx/ParserForXMLSchema.cpp
Index: ParserForXMLSchema.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: ParserForXMLSchema.cpp,v $
* Revision 1.1 2001/03/02 19:26:43 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/ParserForXMLSchema.hpp>
#include <util/regx/TokenFactory.hpp>
#include <util/regx/RangeToken.hpp>
#include <util/regx/TokenInc.hpp>
#include <util/regx/RegxDefs.hpp>
// ---------------------------------------------------------------------------
// ParserForXMLSchema: Constructors and Destructors
// ---------------------------------------------------------------------------
ParserForXMLSchema::ParserForXMLSchema()
: RegxParser()
{
}
ParserForXMLSchema::~ParserForXMLSchema() {
}
// ---------------------------------------------------------------------------
// ParserForXMLSchema: Parsing/Processing methods
// ---------------------------------------------------------------------------
Token* ParserForXMLSchema::processCaret() {
processNext();
return TokenFactory::instance()->createChar(chCaret);
}
Token* ParserForXMLSchema::processDollar() {
processNext();
return TokenFactory::instance()->createChar(chDollarSign);
}
Token* ParserForXMLSchema::processPlus(Token* const tok) {
processNext();
return TokenFactory::instance()->createConcat(tok,
TokenFactory::instance()->createClosure(tok));
}
Token* ParserForXMLSchema::processStar(Token* const tok) {
processNext();
return TokenFactory::instance()->createClosure(tok);
}
Token* ParserForXMLSchema::processQuestion(Token* const tok) {
processNext();
Token* retTok = TokenFactory::instance()->createUnion();
retTok->addChild(tok);
retTok->addChild(TokenFactory::instance()->createToken(Token::EMPTY));
return retTok;
}
Token* ParserForXMLSchema::processParen() {
processNext();
Token* retTok = TokenFactory::instance()->createParenthesis(parseRegx(), 0);
if (getState() != T_RPAREN) {
ThrowXML(RuntimeException, XMLExcepts::Parser_Factor1);
}
processNext();
return retTok;
}
RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) {
setParseContext(S_INBRACKETS);
processNext();
RangeToken* base = 0;
RangeToken* tok = 0;
bool isNRange = false;
if (getState() == T_CHAR && getCharData() == chCaret) {
isNRange = true;
processNext();
base = TokenFactory::instance()->createRange();
base->addRange(0, Token::UTF16_MAX);
tok = TokenFactory::instance()->createRange();
}
else {
tok= TokenFactory::instance()->createRange();
}
int type;
bool firstLoop = true;
while ( (type = getState()) != T_EOF) {
// single range | from-to-range | subtraction
if (type == T_CHAR && getCharData() == chCloseSquare && !firstLoop) {
if (isNRange) {
base->subtractRanges(tok);
tok = base;
}
break;
}
XMLInt32 ch = getCharData();
bool end = false;
if (type == T_BACKSOLIDUS) {
switch(ch) {
case chLatin_d:
case chLatin_D:
case chLatin_w:
case chLatin_W:
case chLatin_s:
case chLatin_S:
{
tok->mergeRanges(getTokenForShorthand(ch));
end = true;
}
break;
case chLatin_i:
case chLatin_I:
case chLatin_c:
case chLatin_C:
{
ch = processCInCharacterClass(tok, ch);
if (ch < 0) {
end = true;
}
}
break;
case chLatin_p:
case chLatin_P:
{
int start = getOffset();
RangeToken* tok2 = processBacksolidus_pP(ch);
if (tok2 == 0) {
ThrowXML(RuntimeException,XMLExcepts::Parser_Atom5);
}
tok->mergeRanges(tok2);
end = true;
}
break;
default:
ch = decodeEscaped();
}
} // end if T_BACKSOLIDUS
else if (type == T_XMLSCHEMA_CC_SUBTRACTION && !firstLoop) {
if (isNRange) {
base->subtractRanges(tok);
tok = base;
}
RangeToken* rangeTok = parseCharacterClass(false);
tok->subtractRanges(rangeTok);
if (getState() != T_CHAR || getCharData() != chCloseSquare) {
ThrowXML(RuntimeException,XMLExcepts::Parser_CC5);
}
break;
} // end if T_XMLSCHEMA...
processNext();
if (!end) {
if (type == T_CHAR) {
if (ch == chOpenSquare)
ThrowXML(RuntimeException,XMLExcepts::Parser_CC6);
if (ch == chCloseSquare)
ThrowXML(RuntimeException,XMLExcepts::Parser_CC7);
}
if (getState() != T_CHAR || getCharData() != chDash) {
tok->addRange(ch, ch);
}
else {
processNext();
if ((type = getState()) == T_EOF)
ThrowXML(RuntimeException,XMLExcepts::Parser_CC2);
if (type == T_CHAR && getCharData() == chCloseSquare) {
tok->addRange(ch, ch);
tok->addRange(chDash, chDash);
}
else if (type == T_XMLSCHEMA_CC_SUBTRACTION) {
tok->addRange(ch, ch);
tok->addRange(chDash, chDash);
}
else {
XMLInt32 rangeEnd = getCharData();
if (type == T_CHAR) {
if (rangeEnd == chOpenSquare)
ThrowXML(RuntimeException,XMLExcepts::Parser_CC6);
if (rangeEnd == chCloseSquare)
ThrowXML(RuntimeException,XMLExcepts::Parser_CC7);
}
if (type == T_BACKSOLIDUS) {
rangeEnd = decodeEscaped();
}
processNext();
tok->addRange(ch, rangeEnd);
}
}
}
firstLoop = false;
}
if (getState() == T_EOF)
ThrowXML(RuntimeException,XMLExcepts::Parser_CC2);
tok->sortRanges();
tok->compactRanges();
setParseContext(S_NORMAL);
processNext();
return tok;
}
XMLInt32 ParserForXMLSchema::processCInCharacterClass(RangeToken* const tok,
const XMLInt32 ch)
{
tok->mergeRanges(getTokenForShorthand(ch));
return -1;
}
// ---------------------------------------------------------------------------
// ParserForXMLSchema: Getter methods
// ---------------------------------------------------------------------------
Token* ParserForXMLSchema::getTokenForShorthand(const XMLInt32 ch) {
switch(ch) {
case chLatin_d:
return TokenFactory::instance()->getRange(fgXMLDigit);
case chLatin_D:
return TokenFactory::instance()->getRange(fgXMLDigit, true);
case chLatin_w:
return TokenFactory::instance()->getRange(fgXMLWord);
case chLatin_W:
return TokenFactory::instance()->getRange(fgXMLWord, true);
case chLatin_s:
return TokenFactory::instance()->getRange(fgXMLSpace);
case chLatin_S:
return TokenFactory::instance()->getRange(fgXMLSpace, true);
case chLatin_c:
return TokenFactory::instance()->getRange(fgXMLNameChar);
case chLatin_C:
return TokenFactory::instance()->getRange(fgXMLNameChar, true);
case chLatin_i:
return TokenFactory::instance()->getRange(fgXMLInitialNameChar);
case chLatin_I:
return TokenFactory::instance()->getRange(fgXMLInitialNameChar, true);
}
return 0;
}
// ---------------------------------------------------------------------------
// ParserForXMLSchema: Helper methods
// ---------------------------------------------------------------------------
XMLInt32 ParserForXMLSchema::decodeEscaped() {
if (getState() != T_BACKSOLIDUS)
ThrowXML(RuntimeException,XMLExcepts::Parser_Next1);;
XMLInt32 ch = getCharData();
switch (ch) {
case chLatin_n:
ch = chLF;
break;
case chLatin_r:
ch = chCR;
break;
case chLatin_t:
ch = chHTab;
break;
case chLatin_e:
case chLatin_f:
case chLatin_x:
case chLatin_u:
case chLatin_v:
ThrowXML(RuntimeException,XMLExcepts::Parser_Process1);
case chLatin_A:
case chLatin_Z:
case chLatin_z:
ThrowXML(RuntimeException,XMLExcepts::Parser_Descape5);
}
return ch;
}
/**
* End of file ParserForXMLSchema.cpp
*/
1.1 xml-xerces/c/src/util/regx/ParserForXMLSchema.hpp
Index: ParserForXMLSchema.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: ParserForXMLSchema.hpp,v 1.1 2001/03/02 19:26:44 knoaman Exp $
*/
#if !defined(PARSERFORXMLSCHEMA_HPP)
#define PARSERFORXMLSCHEMA_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RegxParser.hpp>
//#include <util/ParseException.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class Token;
class RangeToken;
class XMLUTIL_EXPORT ParserForXMLSchema : public RegxParser {
public:
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
ParserForXMLSchema();
~ParserForXMLSchema();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------
// Parsing/Processing methods
// -----------------------------------------------------------------------
XMLInt32 processCInCharacterClass(RangeToken* const tok,
const XMLInt32 ch);
Token* processCaret();
Token* processDollar();
Token* processLook(const unsigned short tokType);
Token* processBacksolidus_A();
Token* processBacksolidus_Z();
Token* processBacksolidus_z();
Token* processBacksolidus_b();
Token* processBacksolidus_B();
Token* processBacksolidus_c();
Token* processBacksolidus_C();
Token* processBacksolidus_i();
Token* processBacksolidus_I();
Token* processBacksolidus_g();
Token* processBacksolidus_X();
Token* processBacksolidus_lt();
Token* processBacksolidus_gt();
Token* processStar(Token* const tok);
Token* processPlus(Token* const tok);
Token* processQuestion(Token* const tok);
Token* processParen();
Token* processParen2();
Token* processCondition();
Token* processModifiers();
Token* processIndependent();
Token* processBackReference();
RangeToken* parseCharacterClass(const bool useNRange);
RangeToken* parseSetOperations();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
Token* getTokenForShorthand(const XMLInt32 ch);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
bool checkQuestion(const int off);
XMLInt32 decodeEscaped();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ParserForXMLSchema(const ParserForXMLSchema&);
void operator=(const ParserForXMLSchema&);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
};
// ---------------------------------------------------------------------------
// ParserForXMLSchema: Helper methods
// ---------------------------------------------------------------------------
inline bool ParserForXMLSchema::checkQuestion(const int off) {
return false;
}
// ---------------------------------------------------------------------------
// ParserForXMLSchema: Parsing/Processing methods
// ---------------------------------------------------------------------------
inline Token* ParserForXMLSchema::processLook(const unsigned short tokType) {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_A() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_B() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_b() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_C() {
processNext();
return getTokenForShorthand(chLatin_C);
}
inline Token* ParserForXMLSchema::processBacksolidus_c() {
processNext();
return getTokenForShorthand(chLatin_c);
}
inline Token* ParserForXMLSchema::processBacksolidus_g() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_gt() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_I() {
processNext();
return getTokenForShorthand(chLatin_I);
}
inline Token* ParserForXMLSchema::processBacksolidus_i() {
processNext();
return getTokenForShorthand(chLatin_i);
}
inline Token* ParserForXMLSchema::processBacksolidus_lt() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_X() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_Z() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBacksolidus_z() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processBackReference() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processCondition() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processIndependent() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processModifiers() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline Token* ParserForXMLSchema::processParen2() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
inline RangeToken* ParserForXMLSchema::parseSetOperations() {
// REVISIT: Do we need to throw an exception or just do nothing
return 0;
}
#endif
/**
* End of file ParserForXMLSchema.hpp
*/
1.1 xml-xerces/c/src/util/regx/RangeFactory.cpp
Index: RangeFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: RangeFactory.cpp,v $
* Revision 1.1 2001/03/02 19:26:44 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RangeFactory.hpp>
#include <util/regx/RangeToken.hpp>
#include <util/PlatformUtils.hpp>
#include <util/regx/RegxDefs.hpp>
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
RefHashTableOf<RangeTokenElemMap>* RangeFactory::fTokenRegistry = 0;
RefHashTableOf<RangeFactory>* RangeFactory::fRangeMap = 0;
XMLStringPool* RangeFactory::fCategories = 0;
RangeFactory* RangeFactory::fInstance = 0;
bool RangeFactory::fRegistryInitialized = false;
// ---------------------------------------------------------------------------
// RangeTokenElemMap: Constructors and Destructor
// ---------------------------------------------------------------------------
RangeTokenElemMap::RangeTokenElemMap(unsigned int categoryId) :
fCategoryId(categoryId)
, fRange(0)
, fNRange(0)
{
}
RangeTokenElemMap::~RangeTokenElemMap()
{
}
// ---------------------------------------------------------------------------
// RangeFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
RangeFactory::RangeFactory() {
}
RangeFactory::~RangeFactory() {
}
// ---------------------------------------------------------------------------
// RangeFactory: Getter methods
// ---------------------------------------------------------------------------
RangeToken* RangeFactory::getRange(const XMLCh* const keyword,
const bool complement) {
if (fTokenRegistry == 0 || fRangeMap == 0 || fCategories == 0)
return 0;
if (!fTokenRegistry->containsKey(keyword))
return 0;
RangeTokenElemMap* elemMap = 0;
// Use a faux scope to synchronize while we do this
{
XMLMutexLock lockInit(&fMutex);
elemMap = fTokenRegistry->get(keyword);
RangeToken* rangeTok = 0;
if (elemMap->getRangeToken() == 0) {
unsigned int categId = elemMap->getCategoryId();
const XMLCh* categName = fCategories->getValueForId(categId);
RangeFactory* rangeFactory = fRangeMap->get(categName);
if (rangeFactory == 0)
return 0;
rangeFactory->buildRanges();
}
if (complement && ((rangeTok = elemMap->getRangeToken()) != 0)) {
elemMap->setRangeToken((RangeToken*)
RangeToken::complementRanges(rangeTok),
complement);
}
}
return (elemMap == 0) ? 0 : elemMap->getRangeToken(complement);
}
void RangeFactory::buildRanges() {
return;
}
// ---------------------------------------------------------------------------
// RangeFactory: Putter methods
// ---------------------------------------------------------------------------
void RangeFactory::addCategory(const XMLCh* const categoryName) {
if (fCategories)
fCategories->addOrFind(categoryName);
}
void RangeFactory::addRangeMap(const XMLCh* const categoryName,
RangeFactory* const rangeFactory) {
if (fRangeMap)
fRangeMap->put((void*)categoryName, rangeFactory);
}
void RangeFactory::addKeywordMap(const XMLCh* const keyword,
const XMLCh* const categoryName) {
if (fCategories == 0 || fTokenRegistry == 0)
return;
unsigned int categId = fCategories->getId(categoryName);
if (categId == 0) {
throw; // ThrowXML(RuntimeException, "Invalid Category")
}
if (fTokenRegistry->containsKey(keyword)) {
RangeTokenElemMap* elemMap = fTokenRegistry->get(keyword);
if (elemMap->getCategoryId() != categId)
elemMap->setCategoryId(categId);
return;
}
fTokenRegistry->put((void*) keyword, new RangeTokenElemMap(categId));
}
// ---------------------------------------------------------------------------
// RangeFactory: Setter methods
// ---------------------------------------------------------------------------
void RangeFactory::setRangeToken(const XMLCh* const keyword,
RangeToken* const tok,const bool complement) {
if (fTokenRegistry == 0)
return;
if (fTokenRegistry->containsKey(keyword)) {
fTokenRegistry->get(keyword)->setRangeToken(tok, complement);
}
else {
throw; //ThrowXML(RuntimeException, "Keyword {0} not found")
}
}
// ---------------------------------------------------------------------------
// RangeFactory: Initialization methods
// ---------------------------------------------------------------------------
void RangeFactory::initializeRegistry() {
XMLMutexLock lockInit(&fMutex);
if (fRegistryInitialized)
return;
fTokenRegistry = new RefHashTableOf<RangeTokenElemMap>(109, false);
fRangeMap = new RefHashTableOf<RangeFactory>(29);
fCategories = new XMLStringPool();
fRegistryInitialized = true;
}
void RangeFactory::initializeKeywordMap() {
// Behavior defined at child level
}
/**
* End of file RangeFactory.cpp
*/
1.1 xml-xerces/c/src/util/regx/RangeFactory.hpp
Index: RangeFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: RangeFactory.hpp,v 1.1 2001/03/02 19:26:45 knoaman Exp $
*/
#if !defined(RANGEFACTORY_HPP)
#define RANGEFACTORY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/StringPool.hpp>
#include <util/Mutexes.hpp>
#include <stdlib.h>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class RangeToken;
class TokenFactory;
class XMLUTIL_EXPORT RangeTokenElemMap {
public:
RangeTokenElemMap(unsigned int categoryId);
~RangeTokenElemMap();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
unsigned int getCategoryId() const;
RangeToken* getRangeToken(const bool complement = false) const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setRangeToken(RangeToken* const tok, const bool complement = false);
void setCategoryId(const unsigned int categId);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RangeTokenElemMap(const RangeTokenElemMap&);
void operator=(const RangeTokenElemMap&);
// Data members
unsigned int fCategoryId;
RangeToken* fRange;
RangeToken* fNRange;
};
class XMLUTIL_EXPORT RangeFactory {
public:
// -----------------------------------------------------------------------
// Constructors and destructors
// -----------------------------------------------------------------------
virtual ~RangeFactory();
// -----------------------------------------------------------------------
// Putter methods
// -----------------------------------------------------------------------
void addCategory(const XMLCh* const categoryName);
void addRangeMap(const XMLCh* const categoryName,
RangeFactory* const rangeFactory);
void addKeywordMap(const XMLCh* const keyword,
const XMLCh* const categoryName);
// -----------------------------------------------------------------------
// Instance methods
// -----------------------------------------------------------------------
static RangeFactory* instance();
//-----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
virtual void initializeKeywordMap();
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
static void cleanUp();
protected:
// -----------------------------------------------------------------------
// Constructor and destructors
// -----------------------------------------------------------------------
RangeFactory();
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setRangeToken(const XMLCh* const keyword, RangeToken* const tok,
const bool complement = false);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/*
* Gets a commonly used RangeToken from the token registry based on the
* range name - Called by TokenFactory.
*/
RangeToken* getRange(const XMLCh* const name,
const bool complement = false);
RefHashTableOf<RangeTokenElemMap>* getTokenRegistry() const;
RefHashTableOf<RangeFactory>* getRangeMap() const;
XMLStringPool* getCategories() const;
/*
* Used by children to build commonly used ranges
*/
virtual void buildRanges();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RangeFactory(const RangeFactory&);
void operator=(const RangeFactory&);
// -----------------------------------------------------------------------
// Private Helpers methods
// -----------------------------------------------------------------------
/*
* Initializes the registry with a set of commonly used RangeToken
* objects.
*/
void initializeRegistry();
friend class TokenFactory;
// -----------------------------------------------------------------------
// Private data members
//
// fTokenRegistry
// Contains a set of commonly used tokens
//
// fRangeMap
// Contains a map between a category name and a RangeFactory object.
//
// fCategories
// Contains range categories names
// -----------------------------------------------------------------------
static bool fRegistryInitialized;
static RefHashTableOf<RangeTokenElemMap>* fTokenRegistry;
static RefHashTableOf<RangeFactory>* fRangeMap;
static XMLStringPool* fCategories;
static RangeFactory* fInstance;
XMLMutex fMutex;
};
// ---------------------------------------------------------------------------
// RangeTokenElemMap: Getter methods
// ---------------------------------------------------------------------------
inline unsigned int RangeTokenElemMap::getCategoryId() const {
return fCategoryId;
}
inline RangeToken* RangeTokenElemMap::getRangeToken(const bool complement) const {
return complement ? fNRange : fRange;
}
// ---------------------------------------------------------------------------
// RangeTokenElemMap: Setter methods
// ---------------------------------------------------------------------------
inline void RangeTokenElemMap::setCategoryId(const unsigned int categId) {
fCategoryId = categId;
}
inline void RangeTokenElemMap::setRangeToken(RangeToken* const tok,
const bool complement) {
if (complement)
fNRange = tok;
else
fRange = tok;
}
// ---------------------------------------------------------------------------
// RangeFactory: Getter methods
// ---------------------------------------------------------------------------
inline RefHashTableOf<RangeTokenElemMap>* RangeFactory::getTokenRegistry() const {
return fTokenRegistry;
}
inline RefHashTableOf<RangeFactory>* RangeFactory::getRangeMap() const {
return fRangeMap;
}
inline XMLStringPool* RangeFactory::getCategories() const {
return fCategories;
}
// ---------------------------------------------------------------------------
// RangeFactory: Instance methods
// ---------------------------------------------------------------------------
inline RangeFactory* RangeFactory::instance() {
if (!fInstance) {
fInstance = new RangeFactory();
atexit(cleanUp);
}
return (fInstance);
}
// ---------------------------------------------------------------------------
// RangeFactory: cleanUp methods
// ---------------------------------------------------------------------------
inline void RangeFactory::cleanUp() {
delete fTokenRegistry;
fTokenRegistry = 0;
delete fRangeMap;
fRangeMap = 0;
delete fCategories;
fCategories = 0;
delete fInstance;
fInstance = 0;
}
#endif
/**
* End file RangeFactory.hpp
*/
1.1 xml-xerces/c/src/util/regx/RangeToken.cpp
Index: RangeToken.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: RangeToken.cpp,v $
* Revision 1.1 2001/03/02 19:26:46 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RangeToken.hpp>
#include <util/regx/TokenFactory.hpp>
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
const int RangeToken::MAPSIZE = 256;
const unsigned int RangeToken::INITIALSIZE = 16;
// ---------------------------------------------------------------------------
// RangeToken: Constructors and Destructors
// ---------------------------------------------------------------------------
RangeToken::RangeToken(const unsigned short tokType) : Token(tokType)
, fSorted(false)
, fCompacted(false)
, fNonMapIndex(0)
, fElemCount(0)
, fMaxCount(0)
, fMap(0)
, fRanges(0)
, fCaseIToken(0)
{
}
RangeToken::~RangeToken() {
delete fMap;
delete[] fRanges;
}
// ---------------------------------------------------------------------------
// RangeToken: Getter methods
// ---------------------------------------------------------------------------
RangeToken* RangeToken::getCaseInsensitiveToken() {
// REVIST
// We will not build a token with case insenstive ranges
// For now we will return a copy of ourselves.
if (fCaseIToken == 0) {
bool isNRange = (getTokenType() == NRANGE) ? true : false;
RangeToken* lwrToken = TokenFactory::instance()->createRange(isNRange);
lwrToken->mergeRanges(this);
fCaseIToken = lwrToken;
}
return fCaseIToken;
}
// ---------------------------------------------------------------------------
// RangeToken: Range manipulation methods
// ---------------------------------------------------------------------------
void RangeToken::addRange(const XMLInt32 start, const XMLInt32 end) {
XMLInt32 val1, val2;
fCaseIToken = 0;
if (start <= end) {
val1 = start;
val2 = end;
}
else {
val1 = end;
val2 = start;
}
if (fRanges == 0) {
fMaxCount = INITIALSIZE;
fRanges = new XMLInt32[fMaxCount];
fRanges[0] = val1;
fRanges[1] = val2;
fElemCount = 2;
fSorted = true;
}
else {
if (fRanges[fElemCount-1] + 1 == val1) {
fRanges[fElemCount-1] = val2;
return;
}
if (fElemCount + 2 >= fMaxCount) {
expand(2);
}
if (fRanges[fElemCount-1] >= val1)
fSorted = false;
fRanges[fElemCount++] = val1;
fRanges[fElemCount++] = val2;
if (!fSorted) {
sortRanges();
}
}
}
void RangeToken::sortRanges() {
if (fSorted || fRanges == 0)
return;
for (int i = fElemCount - 4; i >= 0; i -= 2) {
for (int j = 0; j <= i; j +=2) {
if (fRanges[j] > fRanges[j + 2]
|| (fRanges[j]==fRanges[j+2] && fRanges[j+1] > fRanges[j+3])) {
XMLInt32 tmpVal = fRanges[j+2];
fRanges[j+2] = fRanges[j];
fRanges[j] = tmpVal;
tmpVal = fRanges[j+3];
fRanges[j+3] = fRanges[j+1];
fRanges[j+1] = tmpVal;
}
}
}
fSorted = true;
}
void RangeToken::compactRanges() {
if (fCompacted || fRanges == 0 || fElemCount <= 2)
return;
unsigned int base = 0;
unsigned int target = 0;
while (target < fElemCount) {
if (base != target) {
fRanges[base] = fRanges[target++];
fRanges[base+1] = fRanges[target++];
}
else
target += 2;
XMLInt32 baseEnd = fRanges[base + 1];
while (target < fElemCount) {
XMLInt32 startRange = fRanges[target];
if (baseEnd + 1 < startRange)
break;
XMLInt32 endRange = fRanges[target + 1];
if (baseEnd + 1 == startRange || baseEnd < endRange) {
baseEnd = endRange;
fRanges[base+1] = baseEnd;
target += 2;
}
else if (baseEnd >= endRange) {
target += 2;
}
else {
throw; //ThrowXML(RuntimeException, "CompactRanges - Internal Error")
}
} // inner while
base += 2;
}
if (base != fElemCount) {
while (fElemCount > base) {
fRanges[fElemCount--] = 0;
}
}
fCompacted = true;
}
void RangeToken::mergeRanges(const Token *const tok) {
if (tok->getTokenType() != this->getTokenType())
throw; //ThrowXML(IllegalArgumentException, "Merge Ranges - Mismatched type")
RangeToken* rangeTok = (RangeToken *) tok;
if (rangeTok->fRanges == 0)
return;
fCaseIToken = 0;
sortRanges();
rangeTok->sortRanges();
if (fRanges == 0) {
fMaxCount = rangeTok->fMaxCount;
fRanges = new XMLInt32[fMaxCount];
for (unsigned int index = 0; index < rangeTok->fElemCount; index++) {
fRanges[index] = rangeTok->fRanges[index];
}
fElemCount = rangeTok->fElemCount;
return;
}
unsigned int newMaxCount = (fElemCount + rangeTok->fElemCount >= fMaxCount)
? fMaxCount + rangeTok->fMaxCount : fMaxCount;
XMLInt32* result = new XMLInt32[newMaxCount];
for (unsigned int i=0, j=0, k=0; i < fElemCount || j < rangeTok->fElemCount;) {
if (i >= fElemCount) {
for (int count = 0; count < 2; count++) {
result[k++] = rangeTok->fRanges[j++];
}
}
else if (j >= rangeTok->fElemCount) {
for (int count = 0; count < 2; count++) {
result[k++] = fRanges[i++];
}
}
else if (rangeTok->fRanges[j] < fRanges[i]
|| (rangeTok->fRanges[j] == fRanges[i]
&& rangeTok->fRanges[j+1] < fRanges[i+1])) {
for (int count = 0; count < 2; count++) {
result[k++] = rangeTok->fRanges[j++];
}
}
else {
for (int count = 0; count < 2; count++) {
result[k++] = fRanges[i++];
}
}
}
delete [] fRanges;
fElemCount += rangeTok->fElemCount;
fRanges = result;
fMaxCount = newMaxCount;
}
void RangeToken::subtractRanges(RangeToken* const tok) {
if (fRanges == 0 || tok->fRanges == 0)
return;
if (tok->getTokenType() == NRANGE) {
intersectRanges(tok);
return;
}
fCaseIToken = 0;
sortRanges();
compactRanges();
tok->sortRanges();
tok->compactRanges();
unsigned int newMax = (fElemCount + tok->fElemCount >= fMaxCount)
? fMaxCount + tok->fMaxCount : fMaxCount;
XMLInt32* result = new XMLInt32[newMax];
unsigned int newElemCount = 0;
unsigned int srcCount = 0;
unsigned int subCount = 0;
while (srcCount < fElemCount && subCount < tok->fElemCount) {
XMLInt32 srcBegin = fRanges[srcCount];
XMLInt32 srcEnd = fRanges[srcCount + 1];
XMLInt32 subBegin = tok->fRanges[subCount];
XMLInt32 subEnd = tok->fRanges[subCount + 1];
if (srcEnd <= subBegin) { // no overlap
result[newElemCount++] = fRanges[srcCount++];
result[newElemCount++] = fRanges[srcCount++];
}
else if (srcEnd >= subBegin && srcBegin <= subEnd) {
if (subBegin <= srcBegin && srcEnd <= subEnd) {
srcCount += 2;
}
else if (subBegin <= srcBegin) {
fRanges[srcCount] = subEnd + 1;
subCount += 2;
}
else if (srcEnd <= subEnd) {
result[newElemCount++] = srcBegin;
result[newElemCount++] = subBegin - 1;
}
else {
result[newElemCount++] = srcBegin;
result[newElemCount++] = subBegin - 1;
fRanges[srcCount] = subEnd + 1;
subCount += 2;
}
}
else if (subEnd < srcBegin) {
subCount += 2;
}
else {
delete [] result;
throw; //ThrowXML(RuntimeExceptions, "SubtractRanges - Internal Error")
}
} //end while
while (srcCount < fElemCount) {
result[newElemCount++] = fRanges[srcCount++];
result[newElemCount++] = fRanges[srcCount++];
}
delete [] fRanges;
fRanges = result;
fElemCount = newElemCount;
fMaxCount = newMax;
}
/**
* Ignore whether 'tok' is NRANGE or not.
*/
void RangeToken::intersectRanges(RangeToken* const tok) {
if (fRanges == 0 || tok->fRanges == 0)
return;
fCaseIToken = 0;
sortRanges();
compactRanges();
tok->sortRanges();
tok->compactRanges();
unsigned int newMax = (fElemCount + tok->fElemCount >= fMaxCount)
? fMaxCount + tok->fMaxCount : fMaxCount;
XMLInt32* result = new XMLInt32[newMax];
unsigned int newElemCount = 0;
unsigned int srcCount = 0;
unsigned int tokCount = 0;
while (srcCount < fElemCount && tokCount < tok->fElemCount) {
XMLInt32 srcBegin = fRanges[srcCount];
XMLInt32 srcEnd = fRanges[srcCount + 1];
XMLInt32 tokBegin = tok->fRanges[tokCount];
XMLInt32 tokEnd = tok->fRanges[tokCount + 1];
if (srcEnd < tokBegin) {
srcCount += 2;
}
else if (srcEnd >= tokBegin && srcBegin <= tokEnd) {
if (tokBegin <= srcBegin && srcEnd <= tokEnd) {
result[newElemCount++] = srcBegin;
result[newElemCount++] = srcEnd;
srcCount += 2;
}
else if (tokBegin <= srcBegin) {
result[newElemCount++] = srcBegin;
result[newElemCount++] = tokEnd;
tokCount += 2;
if (tokCount < tok->fElemCount)
fRanges[srcCount] = tokEnd + 1;
else
srcCount += 2;
}
else if (srcEnd <= tokEnd) {
result[newElemCount++] = tokBegin;
result[newElemCount++] = srcEnd;
srcCount += 2;
}
else {
result[newElemCount++] = tokBegin;
result[newElemCount++] = tokEnd;
tokCount += 2;
if (tokCount < tok->fElemCount)
fRanges[srcCount] = tokEnd + 1;
else
srcCount += 2;
}
}
else if (tokEnd < srcBegin) {
tokCount += 2;
if (tokCount >= tok->fElemCount)
srcCount += 2;
}
else {
delete [] result;
throw; //ThrowXML(RuntimeException, "IntersectRanges - Internal Error")
}
} //end while
delete [] fRanges;
fRanges = result;
fElemCount = newElemCount;
fMaxCount = newMax;
}
/**
* for RANGE: Creates complement.
* for NRANGE: Creates the same meaning RANGE.
*/
Token* RangeToken::complementRanges(RangeToken* const tok) {
if (tok->getTokenType() != RANGE && tok->getTokenType() != NRANGE)
throw; //ThrowXML(IllegalArgumentException, "Must be RangeToken")
tok->sortRanges();
tok->compactRanges();
XMLInt32 lastElem = tok->fRanges[tok->fElemCount - 1];
RangeToken* rangeTok = TokenFactory::instance()->createRange();
if (tok->fRanges[0] > 0) {
rangeTok->addRange(0, tok->fRanges[0] - 1);
}
for (unsigned int i= 1; i< tok->fElemCount - 2; i += 2) {
rangeTok->addRange(tok->fRanges[i] + 1, tok->fRanges[i+1] - 1);
}
if (lastElem != UTF16_MAX) {
rangeTok->addRange(lastElem + 1, UTF16_MAX);
}
rangeTok->fCompacted = true;
return rangeTok;
}
// ---------------------------------------------------------------------------
// RangeToken: Match methods
// ---------------------------------------------------------------------------
bool RangeToken::match(const XMLInt32 ch) {
if (fMap == 0)
createMap();
bool ret;
if (getTokenType() == RANGE) {
if (ch < MAPSIZE)
return ((fMap[ch/32] & (1<<(ch&0x1f))) != 0);
ret = false;
for (unsigned int i= fNonMapIndex; i< fElemCount; i +=2) {
if (fRanges[i] <= ch && ch <= fRanges[i+1])
return true;
}
}
else {
if (ch < MAPSIZE)
return ((fMap[ch/32] & (1<<(ch&0x1f))) == 0);
ret = true;
for (unsigned int i= fNonMapIndex; i< fElemCount; i += 2) {
if (fRanges[i] <= ch && ch <= fRanges[i+1])
return false;
}
}
return ret;
}
// ---------------------------------------------------------------------------
// RangeToken: Private helpers methods
// ---------------------------------------------------------------------------
void RangeToken::expand(const unsigned int length) {
unsigned int newMax = fElemCount + length;
// Avoid too many reallocations by expanding by a percentage
unsigned int minNewMax = (unsigned int)((double)fElemCount * 1.25);
if (newMax < minNewMax)
newMax = minNewMax;
XMLInt32* newList = new XMLInt32[newMax];
for (unsigned int index = 0; index < fElemCount; index++)
newList[index] = fRanges[index];
delete [] fRanges;
fRanges = newList;
fMaxCount = newMax;
}
void RangeToken::createMap() {
int asize = MAPSIZE/32;
fMap = new int[asize];
fNonMapIndex = fElemCount;
for (int i = 0; i < asize; i++) {
fMap[i] = 0;
}
for (unsigned int j= 0; j < fElemCount; j += 2) {
XMLInt32 begin = fRanges[j];
XMLInt32 end = fRanges[j+1];
if (begin < MAPSIZE) {
for (int k = begin; k <= end && k < MAPSIZE; k++) {
fMap[k/32] |= 1<<(k&0x1F);
}
}
else {
fNonMapIndex = j;
break;
}
if (end >= MAPSIZE) {
fNonMapIndex = j;
break;
}
}
}
/**
* End of file RangeToken.cpp
*/
1.1 xml-xerces/c/src/util/regx/RangeToken.hpp
Index: RangeToken.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: RangeToken.hpp,v 1.1 2001/03/02 19:26:47 knoaman Exp $
*/
#if !defined(RANGETOKEN_HPP)
#define RANGETOKEN_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/Token.hpp>
class XMLUTIL_EXPORT RangeToken : public Token {
public:
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
RangeToken(const unsigned short tokType);
~RangeToken();
// -----------------------------------------------------------------------
// Public Constants
// -----------------------------------------------------------------------
static const int MAPSIZE;
static const unsigned int INITIALSIZE;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
RangeToken* getCaseInsensitiveToken();
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Range manipulation methods
// -----------------------------------------------------------------------
void addRange(const XMLInt32 start, const XMLInt32 end);
void mergeRanges(const Token *const tok);
void sortRanges();
void compactRanges();
void subtractRanges(RangeToken* const tok);
void intersectRanges(RangeToken* const tok);
static Token* complementRanges(RangeToken* const tok);
// -----------------------------------------------------------------------
// Match methods
// -----------------------------------------------------------------------
bool match(const XMLInt32 ch);
unsigned int fElemCount;
XMLInt32* fRanges;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
RangeToken(const RangeToken&);
void operator=(const RangeToken&);
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
void createMap();
void expand(const unsigned int length);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fSorted;
bool fCompacted;
int fNonMapIndex;
unsigned int fMaxCount;
int* fMap;
RangeToken* fCaseIToken;
};
#endif
/**
* End of file RangeToken.hpp
*/
1.1 xml-xerces/c/src/util/regx/RegxDefs.hpp
Index: RegxDefs.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: RegxDefs.hpp,v 1.1 2001/03/02 19:26:47 knoaman Exp $
*/
#if !defined(REGXDEFS_HPP)
#define REGXDEFS_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/XercesDefs.hpp>
#include <util/XMLUniDefs.hpp>
const XMLCh fgXMLCategory[] =
{
chLatin_X, chLatin_M, chLatin_L, chNull
};
static const XMLCh fgASCIICategory[] =
{
chLatin_A, chLatin_S, chLatin_C, chLatin_I, chLatin_I, chNull
};
const XMLCh fgUnicodeCategory[] =
{
chLatin_U, chLatin_N, chLatin_I, chLatin_C, chLatin_O, chLatin_D,
chLatin_E, chNull
};
const XMLCh fgBlockCategory[] =
{
chLatin_B, chLatin_L, chLatin_O, chLatin_C, chLatin_K, chNull
};
const XMLCh fgXMLSpace[] =
{
chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_i, chLatin_s, chLatin_S,
chLatin_p, chLatin_a, chLatin_c, chLatin_e, chNull
};
const XMLCh fgXMLDigit[] =
{
chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_i, chLatin_s, chLatin_D,
chLatin_i, chLatin_g, chLatin_i, chLatin_t, chNull
};
const XMLCh fgXMLWord[] =
{
chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_i, chLatin_s, chLatin_W,
chLatin_o, chLatin_r, chLatin_d, chNull
};
const XMLCh fgXMLNameChar[] =
{
chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_i, chLatin_s, chLatin_N,
chLatin_a, chLatin_m, chLatin_e, chLatin_C, chLatin_h, chLatin_a,
chLatin_r, chNull
};
const XMLCh fgXMLInitialNameChar[] =
{
chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_i, chLatin_s, chLatin_I,
chLatin_n, chLatin_i, chLatin_t, chLatin_i, chLatin_a, chLatin_l,
chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_C, chLatin_h,
chLatin_a, chLatin_r, chNull
};
const XMLCh fgASCII[] =
{
chLatin_a, chLatin_s, chLatin_c, chLatin_i, chLatin_i, chColon, chLatin_i,
chLatin_s, chLatin_A, chLatin_s, chLatin_c, chLatin_i, chLatin_i, chNull
};
const XMLCh fgASCIIDigit[] =
{
chLatin_a, chLatin_s, chLatin_c, chLatin_i, chLatin_i, chColon, chLatin_i,
chLatin_s, chLatin_D, chLatin_i, chLatin_g, chLatin_i, chLatin_t, chNull
};
const XMLCh fgASCIIWord[] =
{
chLatin_a, chLatin_s, chLatin_c, chLatin_i, chLatin_i, chColon, chLatin_i,
chLatin_s, chLatin_W, chLatin_o, chLatin_r, chLatin_d, chNull
};
const XMLCh fgASCIISpace[] =
{
chLatin_a, chLatin_s, chLatin_c, chLatin_i, chLatin_i, chColon, chLatin_i,
chLatin_s, chLatin_S, chLatin_p, chLatin_a, chLatin_c, chLatin_e, chNull
};
const XMLCh fgASCIIXDigit[] =
{
chLatin_a, chLatin_s, chLatin_c, chLatin_i, chLatin_i, chColon, chLatin_i,
chLatin_s, chLatin_X, chLatin_D, chLatin_i, chLatin_g, chLatin_i,
chLatin_t, chNull
};
const XMLCh fgUniAll[] =
{
chLatin_A, chLatin_L, chLatin_L, chNull
};
const XMLCh fgUniIsAlpha[] =
{
chLatin_I, chLatin_s, chLatin_A, chLatin_l, chLatin_p, chLatin_h,
chLatin_a, chNull
};
const XMLCh fgUniIsAlnum[] =
{
chLatin_I, chLatin_s, chLatin_A, chLatin_l, chLatin_n, chLatin_u,
chLatin_m, chNull
};
const XMLCh fgUniIsWord[] =
{
chLatin_I, chLatin_s, chLatin_W, chLatin_o, chLatin_r, chLatin_d,
chNull
};
const XMLCh fgUniIsDigit[] =
{
chLatin_I, chLatin_s, chLatin_D, chLatin_i, chLatin_g, chLatin_i,
chLatin_t, chNull
};
const XMLCh fgUniIsUpper[] =
{
chLatin_I, chLatin_s, chLatin_U, chLatin_p, chLatin_p, chLatin_e,
chLatin_r, chNull
};
const XMLCh fgUniIsLower[] =
{
chLatin_I, chLatin_s, chLatin_L, chLatin_o, chLatin_w, chLatin_e,
chLatin_r, chNull
};
const XMLCh fgUniIsPunct[] =
{
chLatin_I, chLatin_s, chLatin_P, chLatin_u, chLatin_n, chLatin_c,
chLatin_t, chNull
};
const XMLCh fgUniIsSpace[] =
{
chLatin_I, chLatin_s, chLatin_S, chLatin_p, chLatin_a, chLatin_c,
chLatin_e, chNull
};
const XMLCh fgUniAssigned[] =
{
chLatin_A, chLatin_S, chLatin_S, chLatin_I, chLatin_G, chLatin_N,
chLatin_E, chLatin_D, chNull
};
const XMLCh fgUniDecimalDigit[] =
{
chLatin_N, chLatin_d, chNull
};
const XMLCh fgBlockSpecials[] =
{
chLatin_S, chLatin_p, chLatin_e, chLatin_c, chLatin_i, chLatin_a,
chLatin_l, chLatin_s, chNull
};
const XMLCh fgUniLetter[] =
{
chLatin_L, chNull
};
const XMLCh fgUniNumber[] =
{
chLatin_N, chNull
};
const XMLCh fgUniMark[] =
{
chLatin_M, chNull
};
const XMLCh fgUniSeparator[] =
{
chLatin_Z, chNull
};
const XMLCh fgUniPunctuation[] =
{
chLatin_P, chNull
};
const XMLCh fgUniControl[] =
{
chLatin_C, chNull
};
const XMLCh fgUniSymbol[] =
{
chLatin_S, chNull
};
#endif
/**
* End of file RegxDefs.hpp
*/
1.1 xml-xerces/c/src/util/regx/UnicodeRangeFactory.cpp
Index: UnicodeRangeFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: UnicodeRangeFactory.cpp,v $
* Revision 1.1 2001/03/02 19:26:48 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/UnicodeRangeFactory.hpp>
#include <util/regx/TokenFactory.hpp>
#include <util/regx/RangeToken.hpp>
#include <util/regx/RegxDefs.hpp>
#include <util/regx/XMLUniCharacter.hpp>
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
bool UnicodeRangeFactory::fRangesCreated = false;
bool UnicodeRangeFactory::fKeywordsInitialized = false;
// ---------------------------------------------------------------------------
// Local data
// ---------------------------------------------------------------------------
const int UNICATEGSIZE = 35;
const unsigned short CHAR_LETTER = 28;
const unsigned short CHAR_MARK = 29;
const unsigned short CHAR_NUMBER = 30;
const unsigned short CHAR_SEPARATOR = 31;
const unsigned short CHAR_OTHER = 32;
const unsigned short CHAR_PUNCTUATION = 33;
const unsigned short CHAR_SYMBOL = 34;
const XMLCh uniCategNames[][UNICATEGSIZE] =
{
{chLatin_C, chLatin_n, chNull},
{chLatin_L, chLatin_u, chNull},
{chLatin_L, chLatin_l, chNull},
{chLatin_L, chLatin_t, chNull},
{chLatin_L, chLatin_m, chNull},
{chLatin_L, chLatin_o, chNull},
{chLatin_M, chLatin_n, chNull},
{chLatin_M, chLatin_e, chNull},
{chLatin_M, chLatin_c, chNull},
{chLatin_N, chLatin_d, chNull},
{chLatin_N, chLatin_l, chNull},
{chLatin_N, chLatin_o, chNull},
{chLatin_Z, chLatin_s, chNull},
{chLatin_Z, chLatin_l, chNull},
{chLatin_Z, chLatin_p, chNull},
{chLatin_C, chLatin_c, chNull},
{chLatin_C, chLatin_f, chNull},
{chLatin_C, chLatin_o, chNull},
{chLatin_C, chLatin_s, chNull},
{chLatin_P, chLatin_d, chNull},
{chLatin_P, chLatin_s, chNull},
{chLatin_P, chLatin_e, chNull},
{chLatin_P, chLatin_c, chNull},
{chLatin_P, chLatin_o, chNull},
{chLatin_S, chLatin_m, chNull},
{chLatin_S, chLatin_c, chNull},
{chLatin_S, chLatin_k, chNull},
{chLatin_S, chLatin_o, chNull},
{chLatin_L, chNull},
{chLatin_M, chNull},
{chLatin_N, chNull},
{chLatin_Z, chNull},
{chLatin_C, chNull},
{chLatin_P, chNull},
{chLatin_S, chNull},
};
// ---------------------------------------------------------------------------
// UnicodeRangeFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
UnicodeRangeFactory::UnicodeRangeFactory() {
}
UnicodeRangeFactory::~UnicodeRangeFactory() {
}
// ---------------------------------------------------------------------------
// UnicodeRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void UnicodeRangeFactory::buildRanges() {
if (fRangesCreated)
return;
RangeToken* ranges[UNICATEGSIZE];
for (int i=0; i < UNICATEGSIZE; i++) {
ranges[i] = TokenFactory::instance()->createRange();
}
for (int j=0; j < 0x10000; j++) {
unsigned short charType = XMLUniCharacter::getType(j);
// Assumption - treat initial punctuation as start punct.
// - treat final punctuation as end punct.
if (charType == XMLUniCharacter::INITIAL_PUNCTUATION) {
charType = XMLUniCharacter::START_PUNCTUATION;
}
else if (charType == XMLUniCharacter::FINAL_PUNCTUATION) {
charType = XMLUniCharacter::END_PUNCTUATION;
}
ranges[charType]->addRange(j, j);
charType = getUniCategory(charType);
ranges[charType]->addRange(j, j);
}
ranges[XMLUniCharacter::UNASSIGNED]->addRange(0x10000, Token::UTF16_MAX);
for (int k=0; k < UNICATEGSIZE; k++) {
setRangeToken(uniCategNames[k], ranges[k]);
}
// Create all range
RangeToken* tok = TokenFactory::instance()->createRange();
tok->addRange(0, Token::UTF16_MAX);
setRangeToken(fgUniAll, tok);
// Create alpha range
tok = TokenFactory::instance()->createRange();
tok->mergeRanges(ranges[XMLUniCharacter::UPPERCASE_LETTER]);
tok->mergeRanges(ranges[XMLUniCharacter::LOWERCASE_LETTER]);
tok->mergeRanges(ranges[XMLUniCharacter::OTHER_LETTER]);
setRangeToken(fgUniIsAlpha, tok);
// Create alpha-num range
RangeToken* alnumTok = TokenFactory::instance()->createRange();
alnumTok->mergeRanges(tok);
alnumTok->mergeRanges(ranges[XMLUniCharacter::DECIMAL_DIGIT_NUMBER]);
setRangeToken(fgUniIsAlnum, alnumTok);
// Create word range
tok = TokenFactory::instance()->createRange();
tok->mergeRanges(alnumTok);
tok->addRange(chUnderscore, chUnderscore);
setRangeToken(fgUniIsWord, tok);
// Create assigned range
tok = ranges[XMLUniCharacter::UNASSIGNED];
setRangeToken(fgUniAssigned,(RangeToken*)RangeToken::complementRanges(tok));
fRangesCreated = true;
}
// ---------------------------------------------------------------------------
// UnicodeRangeFactory: Initialization methods
// ---------------------------------------------------------------------------
void UnicodeRangeFactory::initializeKeywordMap() {
if (fKeywordsInitialized)
return;
for (int k=0; k < UNICATEGSIZE; k++) {
addKeywordMap(uniCategNames[k], fgUnicodeCategory);
}
addKeywordMap(fgUniAll, fgUnicodeCategory);
addKeywordMap(fgUniIsAlpha, fgUnicodeCategory);
addKeywordMap(fgUniIsAlnum, fgUnicodeCategory);
addKeywordMap(fgUniIsWord, fgUnicodeCategory);
addKeywordMap(fgUniAssigned, fgUnicodeCategory);
fKeywordsInitialized = true;
}
// ---------------------------------------------------------------------------
// UnicodeRangeFactory: Helper methods
// ---------------------------------------------------------------------------
unsigned short UnicodeRangeFactory::getUniCategory(const unsigned short type)
{
switch(type) {
case XMLUniCharacter::UPPERCASE_LETTER:
case XMLUniCharacter::LOWERCASE_LETTER:
case XMLUniCharacter::TITLECASE_LETTER:
case XMLUniCharacter::MODIFIER_LETTER:
case XMLUniCharacter::OTHER_LETTER:
return CHAR_LETTER;
case XMLUniCharacter::NON_SPACING_MARK:
case XMLUniCharacter::COMBINING_SPACING_MARK:
case XMLUniCharacter::ENCLOSING_MARK:
return CHAR_MARK;
case XMLUniCharacter::DECIMAL_DIGIT_NUMBER:
case XMLUniCharacter::LETTER_NUMBER:
case XMLUniCharacter::OTHER_NUMBER:
return CHAR_NUMBER;
case XMLUniCharacter::SPACE_SEPARATOR:
case XMLUniCharacter::LINE_SEPARATOR:
case XMLUniCharacter::PARAGRAPH_SEPARATOR:
return CHAR_SEPARATOR;
case XMLUniCharacter::CONTROL:
case XMLUniCharacter::FORMAT:
case XMLUniCharacter::SURROGATE:
case XMLUniCharacter::PRIVATE_USE:
case XMLUniCharacter::UNASSIGNED:
return CHAR_OTHER;
case XMLUniCharacter::CONNECTOR_PUNCTUATION:
case XMLUniCharacter::DASH_PUNCTUATION:
case XMLUniCharacter::START_PUNCTUATION:
case XMLUniCharacter::END_PUNCTUATION:
case XMLUniCharacter::OTHER_PUNCTUATION:
case XMLUniCharacter::INITIAL_PUNCTUATION:
case XMLUniCharacter::FINAL_PUNCTUATION:
return CHAR_PUNCTUATION;
case XMLUniCharacter::MATH_SYMBOL:
case XMLUniCharacter::CURRENCY_SYMBOL:
case XMLUniCharacter::MODIFIER_SYMBOL:
case XMLUniCharacter::OTHER_SYMBOL:
return CHAR_SYMBOL;
}
return 0;
}
/**
* End of file UnicodeRangeFactory.cpp
*/
1.1 xml-xerces/c/src/util/regx/UnicodeRangeFactory.hpp
Index: UnicodeRangeFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: UnicodeRangeFactory.hpp,v 1.1 2001/03/02 19:26:49 knoaman Exp $
*/
#if !defined(UNICODERANGEFACTORY_HPP)
#define UNICODERANGEFACTORY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RangeFactory.hpp>
class XMLUTIL_EXPORT UnicodeRangeFactory: public RangeFactory {
public:
// -----------------------------------------------------------------------
// Constructors and operators
// -----------------------------------------------------------------------
UnicodeRangeFactory();
~UnicodeRangeFactory();
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
void initializeKeywordMap();
protected:
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
void buildRanges();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
UnicodeRangeFactory(const UnicodeRangeFactory&);
void operator=(const UnicodeRangeFactory&);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
unsigned short getUniCategory(const unsigned short type);
static bool fRangesCreated;
static bool fKeywordsInitialized;
};
#endif
/**
* End file UnicodeRangeFactory.hpp
*/
1.1 xml-xerces/c/src/util/regx/XMLRangeFactory.cpp
Index: XMLRangeFactory.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XMLRangeFactory.cpp,v $
* Revision 1.1 2001/03/02 19:26:50 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/XMLRangeFactory.hpp>
#include <internal/CharTypeTables.hpp>
#include <util/regx/RegxDefs.hpp>
#include <util/regx/TokenFactory.hpp>
#include <util/regx/RangeToken.hpp>
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
bool XMLRangeFactory::fRangesCreated = false;
bool XMLRangeFactory::fKeywordsInitialized = false;
// ---------------------------------------------------------------------------
// Local static functions
// ---------------------------------------------------------------------------
static void setupRange(RangeToken* const rangeTok,
const XMLCh* const theTable) {
const XMLCh* pchCur = theTable;
// Do the ranges first
while (*pchCur)
{
const XMLCh chLow = *pchCur++;
const XMLCh chHigh = *pchCur++;
rangeTok->addRange(chLow, chHigh);
}
// Skip the range terminator
pchCur++;
// And then the singles until we hit its terminator
while (*pchCur) {
rangeTok->addRange(*pchCur, *pchCur++);
}
}
// ---------------------------------------------------------------------------
// XMLRangeFactory: Constructors and Destructor
// ---------------------------------------------------------------------------
XMLRangeFactory::XMLRangeFactory() {
}
XMLRangeFactory::~XMLRangeFactory() {
}
// ---------------------------------------------------------------------------
// XMLRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void XMLRangeFactory::buildRanges() {
if (fRangesCreated)
return;
// Create space ranges
RangeToken* tok = TokenFactory::instance()->createRange();
setupRange(tok, gWhitespaceChars);
setRangeToken(fgXMLSpace, tok);
// Create digits ranges
tok = TokenFactory::instance()->createRange();
setupRange(tok, gDigitChars);
tok->sortRanges();
tok->compactRanges();
setRangeToken(fgXMLDigit, tok);
// Create word ranges
tok = TokenFactory::instance()->createRange();
setupRange(tok, gBaseChars);
setupRange(tok, gXMLChars);
setupRange(tok, gDigitChars);
tok->sortRanges();
tok->compactRanges();
setRangeToken(fgXMLWord, tok);
// Create NameChar ranges
tok = TokenFactory::instance()->createRange();
setupRange(tok, gBaseChars);
setupRange(tok, gCombiningChars);
setupRange(tok, gExtenderChars);
setupRange(tok, gIdeographicChars);
setupRange(tok, gDigitChars);
tok->addRange(chDash, chDash);
tok->addRange(chColon, chColon);
tok->addRange(chPeriod, chPeriod);
tok->addRange(chUnderscore, chUnderscore);
tok->sortRanges();
tok->compactRanges();
setRangeToken(fgXMLNameChar, tok);
// Create initialNameChar ranges
tok = TokenFactory::instance()->createRange();
setupRange(tok, gBaseChars);
setupRange(tok, gXMLChars);
tok->addRange(chColon, chColon);
tok->addRange(chUnderscore, chUnderscore);
tok->sortRanges();
tok->compactRanges();
setRangeToken(fgXMLInitialNameChar, tok);
fRangesCreated = true;
}
// ---------------------------------------------------------------------------
// XMLRangeFactory: Range creation methods
// ---------------------------------------------------------------------------
void XMLRangeFactory::initializeKeywordMap() {
if (fKeywordsInitialized)
return;
addKeywordMap(fgXMLSpace, fgXMLCategory);
addKeywordMap(fgXMLDigit, fgXMLCategory);
addKeywordMap(fgXMLWord, fgXMLCategory);
addKeywordMap(fgXMLNameChar, fgXMLCategory);
addKeywordMap(fgXMLInitialNameChar, fgXMLCategory);
fKeywordsInitialized = true;
}
/**
* End of file XMLRangeFactory.cpp
*/
1.1 xml-xerces/c/src/util/regx/XMLRangeFactory.hpp
Index: XMLRangeFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XMLRangeFactory.hpp,v 1.1 2001/03/02 19:26:51 knoaman Exp $
*/
#if !defined(XMLRANGEFACTORY_HPP)
#define XMLRANGEFACTORY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/RangeFactory.hpp>
class XMLUTIL_EXPORT XMLRangeFactory: public RangeFactory {
public:
// -----------------------------------------------------------------------
// Constructors and operators
// -----------------------------------------------------------------------
XMLRangeFactory();
~XMLRangeFactory();
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
void initializeKeywordMap();
protected:
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
void buildRanges();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLRangeFactory(const XMLRangeFactory&);
void operator=(const XMLRangeFactory&);
static bool fRangesCreated;
static bool fKeywordsInitialized;
};
#endif
/**
* End file XMLRangeFactory.hpp
*/
1.1 xml-xerces/c/src/util/regx/XMLUniCharacter.cpp
Index: XMLUniCharacter.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 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) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XMLUniCharacter.cpp,v $
* Revision 1.1 2001/03/02 19:26:51 knoaman
* Schema: Regular expression handling part II
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/regx/XMLUniCharacter.hpp>
#if defined (XML_USE_ICU_TRANSCODER)
#include <unicode/unicode.h>
#else
#include <util/regx/UniCharTable.hpp>
#endif
// ---------------------------------------------------------------------------
// XMLUniCharacter: Public static methods
// ---------------------------------------------------------------------------
unsigned short XMLUniCharacter::getType(const XMLCh ch) {
#if defined (XML_USE_ICU_TRANSCODER)
return (unsigned short) Unicode::getType(ch);
#else
return (unsigned short) fgUniCharsTable[ch];
#endif
}
/**
* End of file XMLUniCharacter.cpp
*/