datatypevalidatorfactory.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 1,087 行 · 第 1/3 页
CPP
1,087 行
/* * Copyright 2001,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Log: DatatypeValidatorFactory.cpp,v $ * Revision 1.29 2004/09/13 21:38:34 peiyongz * getBuiltInBaseValidator * * Revision 1.28 2004/09/08 13:56:52 peiyongz * Apache License Version 2.0 * * Revision 1.27 2004/08/11 16:52:59 peiyongz * using Literal constants from XMLUni * * Revision 1.26 2004/01/13 16:17:09 knoaman * Fo sanity, use class name to qualify method * * Revision 1.25 2004/01/09 22:41:58 knoaman * Use a global static mutex for locking when creating local static mutexes instead of compareAndSwap * * Revision 1.24 2003/12/17 00:18:38 cargilld * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. * * Revision 1.23 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * * Revision 1.22 2003/11/13 23:02:09 peiyongz * using default memory manager and specify derivated from list, not user defined * * Revision 1.21 2003/11/12 20:30:58 peiyongz * movd ID/IDREF/IDREFS/ENTITY/ENTITIES dv to BuiltInRegistry * * Revision 1.20 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * * Revision 1.19 2003/11/05 16:36:15 peiyongz * initialize BuiltInRegistry during deserialization * * Revision 1.18 2003/10/20 15:56:48 knoaman * Fix multithreading problem. * * Revision 1.17 2003/10/17 21:13:05 peiyongz * Implement Serialization/Deserialization * * Revision 1.16 2003/05/18 14:02:07 knoaman * Memory manager implementation: pass per instance manager. * * Revision 1.15 2003/05/16 21:43:20 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * * Revision 1.14 2003/05/15 18:53:26 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.13 2003/03/18 19:42:17 knoaman * Schema Errata E2-18. * * Revision 1.12 2003/02/26 16:14:27 peiyongz * Schema Errata E2-43: disallow trailing decimal point and a new pattern added * to the Integer definition. * * Revision 1.11 2003/01/29 19:51:48 gareth * type names / uris are now added to DatatypeValidators. * * Revision 1.10 2003/01/03 16:39:45 tng * Performance: no need to create that many members for fBuiltInRegistry * * Revision 1.9 2002/12/18 14:17:55 gareth * Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf. * * Revision 1.8 2002/12/02 16:01:24 gareth * Fix to bug #12188. NCNAME validator now has a base validator of NAME. Patch by Peter Volchek. * * Revision 1.7 2002/12/02 13:25:51 gareth * Fix for bug #12188. Create NMTOKEN, ID, IDREF, ENTITY, NAME, NCNAME with appropriate base types. Some reordering of creation was required where dependencies resulted. * * Revision 1.6 2002/11/21 23:43:19 peiyongz * Schema Errata: E2-25 language * * Revision 1.5 2002/11/04 14:53:28 tng * C++ Namespace Support. * * Revision 1.4 2002/05/08 12:25:30 tng * Schema Fix: re-add the ID, IDREF ... datatype validators only if they were not there. * * Revision 1.3 2002/05/07 20:00:07 tng * Schema Fix: No need to re-add the ID, IDREF ... datatype validators if the fUserDefinedRegistry already exists. * * Revision 1.2 2002/02/25 21:28:26 tng * Schema Fix: Thread-safe the built-in datatype validator factory. * * Revision 1.1.1.1 2002/02/01 22:22:40 peiyongz * sane_include * * Revision 1.26 2001/11/07 19:18:52 peiyongz * DateTime Port * * Revision 1.25 2001/10/25 15:06:49 tng * Thread safe the static instance. * * Revision 1.24 2001/10/23 23:14:22 peiyongz * [Bug#880] patch to PlatformUtils:init()/term() and related. from Mark Weaver * * Revision 1.23 2001/09/25 16:00:03 peiyongz * DTV Reorganization: Create native NameDTV and NCNameDTV * * Revision 1.22 2001/08/24 17:12:01 knoaman * Add support for anySimpleType. * Remove parameter 'baseValidator' from the virtual method 'newInstance'. * * Revision 1.21 2001/08/01 18:49:16 peiyongz * AnyRUIDatatypeValidator * * Revision 1.20 2001/07/26 20:48:02 peiyongz * FloatDatatypeValidator * * Revision 1.19 2001/07/24 21:23:39 tng * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. * * Revision 1.18 2001/07/24 13:59:03 peiyongz * DoubleDTV * * Revision 1.17 2001/07/19 17:46:42 tng * Enable those derived dataype like nonPositiveinteger, negativeInteger ... etc. * * Revision 1.16 2001/07/13 14:10:33 peiyongz * UnionDTV * * Revision 1.15 2001/07/11 21:37:18 peiyongz * ListDatatypeDTV * * Revision 1.14 2001/07/06 20:21:58 peiyongz * QNameDTV & ENTITYDTV enabled * * Revision 1.13 2001/07/05 20:15:25 peiyongz * NOTATIONDatatypeValidator * * Revision 1.12 2001/07/04 20:16:31 peiyongz * IDREFDatatypeValidator * * Revision 1.11 2001/07/04 14:38:24 peiyongz * IDDatatypeValidator: created * DatatypeValidatorFactory: IDDTV enabled * XMLString:isValidName(): to validate Name (XML [4][5]) * * Revision 1.10 2001/05/28 21:11:17 tng * Schema: Various DatatypeValidator fix. By Pei Yong Zhang * * Revision 1.9 2001/05/18 16:51:37 knoaman * Added circular check for complexType + more error messages. * * Revision 1.8 2001/05/17 18:11:11 knoaman * More constraint and attribute checking. * * Revision 1.7 2001/05/16 15:24:42 tng * Schema: Add Base64 and HexBin. By Pei Yong Zhang. * * Revision 1.6 2001/05/15 21:59:19 knoaman * TraverseSchema: add attribute checking + some fixes + more error messages. * More attribute cheking to come. * * Revision 1.5 2001/05/11 21:51:13 knoaman * Schema updates and fixes. * * Revision 1.4 2001/05/11 13:27:28 tng * Copyright update. * * Revision 1.3 2001/05/09 18:43:40 tng * Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. * * Revision 1.2 2001/05/03 19:17:47 knoaman * TraverseSchema Part II. * * Revision 1.1 2001/03/21 21:39:14 knoaman * Schema symbols and Datatype validator part I * */// ---------------------------------------------------------------------------// Includes// ---------------------------------------------------------------------------#include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp>#include <xercesc/validators/schema/SchemaSymbols.hpp>#include <xercesc/util/XMLUniDefs.hpp>#include <xercesc/util/Janitor.hpp>#include <xercesc/validators/datatype/StringDatatypeValidator.hpp>#include <xercesc/validators/datatype/BooleanDatatypeValidator.hpp>#include <xercesc/validators/datatype/DecimalDatatypeValidator.hpp>#include <xercesc/validators/datatype/HexBinaryDatatypeValidator.hpp>#include <xercesc/validators/datatype/Base64BinaryDatatypeValidator.hpp>#include <xercesc/validators/datatype/IDDatatypeValidator.hpp>#include <xercesc/validators/datatype/IDREFDatatypeValidator.hpp>#include <xercesc/validators/datatype/NOTATIONDatatypeValidator.hpp>#include <xercesc/validators/datatype/ENTITYDatatypeValidator.hpp>#include <xercesc/validators/datatype/QNameDatatypeValidator.hpp>#include <xercesc/validators/datatype/NameDatatypeValidator.hpp>#include <xercesc/validators/datatype/NCNameDatatypeValidator.hpp>#include <xercesc/validators/datatype/ListDatatypeValidator.hpp>#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>#include <xercesc/validators/datatype/DoubleDatatypeValidator.hpp>#include <xercesc/validators/datatype/FloatDatatypeValidator.hpp>#include <xercesc/validators/datatype/AnyURIDatatypeValidator.hpp>#include <xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp>#include <xercesc/validators/datatype/DateTimeDatatypeValidator.hpp>#include <xercesc/validators/datatype/DateDatatypeValidator.hpp>#include <xercesc/validators/datatype/TimeDatatypeValidator.hpp>#include <xercesc/validators/datatype/DayDatatypeValidator.hpp>#include <xercesc/validators/datatype/MonthDatatypeValidator.hpp>#include <xercesc/validators/datatype/MonthDayDatatypeValidator.hpp>#include <xercesc/validators/datatype/YearDatatypeValidator.hpp>#include <xercesc/validators/datatype/YearMonthDatatypeValidator.hpp>#include <xercesc/validators/datatype/DurationDatatypeValidator.hpp>#include <xercesc/util/PlatformUtils.hpp>#include <xercesc/util/XMLRegisterCleanup.hpp>#include <xercesc/internal/XTemplateSerializer.hpp>#include <xercesc/util/HashPtr.hpp>XERCES_CPP_NAMESPACE_BEGIN// ---------------------------------------------------------------------------// DatatypeValidatorFactory: Local const data// ---------------------------------------------------------------------------const XMLCh fgTokPattern[] ={ chBackSlash, chLatin_c, chPlus, chNull};//E2-43//[+\-]?[0-9]+const XMLCh fgIntegerPattern[] ={ chOpenSquare, chPlus, chBackSlash, chDash, chCloseSquare, chQuestion, chOpenSquare, chDigit_0, chDash, chDigit_9, chCloseSquare, chPlus, chNull};//"\\i\\c*"const XMLCh fgNamePattern[] ={ chBackSlash, chLatin_i, chBackSlash, chLatin_c, chAsterisk, chNull};//"[\\i-[:]][\\c-[:]]*"const XMLCh fgNCNamePattern[] ={ chOpenSquare, chBackSlash, chLatin_i, chDash, chOpenSquare, chColon, chCloseSquare, chCloseSquare, chOpenSquare, chBackSlash, chLatin_c, chDash, chOpenSquare, chColon, chCloseSquare, chCloseSquare, chAsterisk, chNull};const XMLCh fgP0Y[] ={ chLatin_P, chDigit_0, chLatin_Y, chNull};const XMLCh fgP1Y[] ={ chLatin_P, chDigit_1, chLatin_Y, chNull};const XMLCh fgP100Y[] ={ chLatin_P, chDigit_1, chDigit_0, chDigit_0, chLatin_Y, chNull};const XMLCh fgPT24H[] ={ chLatin_P, chLatin_T, chDigit_2, chDigit_4, chLatin_H, chNull};const XMLCh fgP1M[] ={ chLatin_P, chDigit_1, chLatin_M, chNull};// ---------------------------------------------------------------------------// Local static data// ---------------------------------------------------------------------------static bool sBuiltInRegistryMutexRegistered = false;static XMLMutex* sBuiltInRegistryMutex = 0;static XMLRegisterCleanup builtInRegistryCleanup;// ---------------------------------------------------------------------------// DatatypeValidatorFactory: Static member data// ---------------------------------------------------------------------------RefHashTableOf<DatatypeValidator>* DatatypeValidatorFactory::fBuiltInRegistry = 0;RefHashTableOf<XMLCanRepGroup>* DatatypeValidatorFactory::fCanRepRegistry = 0;// ---------------------------------------------------------------------------// DatatypeValidatorFactory: Constructors and Destructor// ---------------------------------------------------------------------------DatatypeValidatorFactory::DatatypeValidatorFactory(MemoryManager* const manager) : fUserDefinedRegistry(0) , fMemoryManager(manager){}DatatypeValidatorFactory::~DatatypeValidatorFactory(){ cleanUp();}// ---------------------------------------------------------------------------// DatatypeValidatorFactory: Reset methods// ---------------------------------------------------------------------------void DatatypeValidatorFactory::resetRegistry() { if (fUserDefinedRegistry != 0) { fUserDefinedRegistry->removeAll(); }}// -----------------------------------------------------------------------// Notification that lazy data has been deleted// -----------------------------------------------------------------------void DatatypeValidatorFactory::reinitRegistry() { delete fBuiltInRegistry; fBuiltInRegistry = 0; delete fCanRepRegistry; fCanRepRegistry = 0; // delete local static data delete sBuiltInRegistryMutex; sBuiltInRegistryMutex = 0; sBuiltInRegistryMutexRegistered = false;}// ---------------------------------------------------------------------------// DatatypeValidatorFactory: Registry initialization methods// ---------------------------------------------------------------------------void DatatypeValidatorFactory::expandRegistryToFullSchemaSet(){ if (!sBuiltInRegistryMutexRegistered) { if (!sBuiltInRegistryMutex) { XMLMutexLock lock(XMLPlatformUtils::fgAtomicMutex); if (!sBuiltInRegistryMutex) sBuiltInRegistryMutex = new XMLMutex; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?