uniondatatypevalidator.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 475 行 · 第 1/2 页
CPP
475 行
/* * 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. *//* * $Id: UnionDatatypeValidator.cpp,v 1.28 2004/09/08 13:56:53 peiyongz Exp $ * $Log: UnionDatatypeValidator.cpp,v $ * Revision 1.28 2004/09/08 13:56:53 peiyongz * Apache License Version 2.0 * * Revision 1.27 2004/03/19 01:17:22 peiyongz * enumeration is ALWAYS owned, datatype validator not. * * Revision 1.26 2004/01/29 11:51:22 cargilld * Code cleanup changes to get rid of various compiler diagnostic messages. * * Revision 1.25 2004/01/13 21:18:18 peiyongz * revert code back to previous version * * Revision 1.24 2004/01/12 16:25:09 neilg * remove use of static buffers * * Revision 1.23 2004/01/06 18:13:59 peiyongz * using the no-exception-thrown ctor * * Revision 1.22 2003/12/23 21:50:36 peiyongz * Absorb exception thrown in getCanonicalRepresentation and return 0, * only validate when required * * Revision 1.21 2003/12/17 00:18:39 cargilld * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. * * Revision 1.20 2003/12/10 20:55:18 neilg * fixes for canonical value production; memory management was not implemented correctly * * Revision 1.19 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * * Revision 1.18 2003/11/24 05:10:26 neilg * implement method for determining member type of union that validated some value * * Revision 1.17 2003/11/13 23:19:18 peiyongz * initSize * * Revision 1.16 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * * Revision 1.15 2003/10/31 22:17:11 peiyongz * solve ownership * * Revision 1.14 2003/10/17 21:13:44 peiyongz * using XTemplateSerializer * * Revision 1.13 2003/10/07 19:39:03 peiyongz * Implementation of Serialization/Deserialization * * Revision 1.12 2003/10/01 16:32:41 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * * Revision 1.11 2003/08/16 18:42:49 neilg * fix for bug 22457. Union types that are restrictions of other union types were previously considered not to inherit their parents member types. This is at variance with the behaviour of the Java parser and apparently with the spec, so I have changed this. * * Revision 1.10 2003/05/16 06:01:57 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.9 2003/05/15 18:53:27 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.8 2003/02/06 13:51:55 gareth * fixed bug with multiple attributes being validated by the same union type. * * Revision 1.7 2003/01/29 19:53:35 gareth * we now store information about which validator was used to validate. * * Revision 1.6 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.5 2002/12/06 16:45:54 tng * header include cleanup. * * Revision 1.4 2002/11/04 14:53:28 tng * C++ Namespace Support. * * Revision 1.3 2002/09/24 19:44:40 tng * Performance: use XMLString::equals instead of XMLString::compareString * * Revision 1.2 2002/02/14 15:17:31 peiyongz * getEnumString() * * Revision 1.1.1.1 2002/02/01 22:22:42 peiyongz * sane_include * * Revision 1.5 2001/10/02 18:59:29 peiyongz * Invalid_Facet_Tag to display the tag name * * Revision 1.4 2001/09/20 13:11:42 knoaman * Regx + misc. fixes * * Revision 1.3 2001/08/21 18:42:54 peiyongz * Bugzilla# 2816: cleanUp() declared with external linkage and called * before defined as inline * * Revision 1.2 2001/08/14 22:11:56 peiyongz * new exception message added * * Revision 1.1 2001/07/13 14:10:40 peiyongz * UnionDTV * */// ---------------------------------------------------------------------------// Includes// ---------------------------------------------------------------------------#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>#include <xercesc/validators/datatype/InvalidDatatypeFacetException.hpp>#include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp>#include <xercesc/util/OutOfMemoryException.hpp>#include <xercesc/internal/XTemplateSerializer.hpp>XERCES_CPP_NAMESPACE_BEGINstatic const unsigned int BUF_LEN = 64;// ---------------------------------------------------------------------------// Constructors and Destructor// ---------------------------------------------------------------------------UnionDatatypeValidator::UnionDatatypeValidator(MemoryManager* const manager):DatatypeValidator(0, 0, 0, DatatypeValidator::Union, manager),fEnumerationInherited(false),fMemberTypesInherited(false),fEnumeration(0),fMemberTypeValidators(0),fValidatedDatatype(0){}UnionDatatypeValidator::~UnionDatatypeValidator(){ cleanUp();}UnionDatatypeValidator::UnionDatatypeValidator( RefVectorOf<DatatypeValidator>* const memberTypeValidators , const int finalSet , MemoryManager* const manager):DatatypeValidator(0, 0, finalSet, DatatypeValidator::Union, manager),fEnumerationInherited(false),fMemberTypesInherited(false),fEnumeration(0),fMemberTypeValidators(0),fValidatedDatatype(0){ if ( !memberTypeValidators ) { ThrowXMLwithMemMgr(InvalidDatatypeFacetException , XMLExcepts::FACET_Union_Null_memberTypeValidators, manager); } // no pattern, no enumeration fMemberTypeValidators = memberTypeValidators;}UnionDatatypeValidator::UnionDatatypeValidator( DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets , RefArrayVectorOf<XMLCh>* const enums , const int finalSet , MemoryManager* const manager , RefVectorOf<DatatypeValidator>* const memberTypeValidators , const bool memberTypesInherited ):DatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Union, manager),fEnumerationInherited(false),fMemberTypesInherited(memberTypesInherited),fEnumeration(0),fMemberTypeValidators(memberTypeValidators),fValidatedDatatype(0){ // // baseValidator another UnionDTV from which, // this UnionDTV is derived by restriction. // it shall be not null // if (!baseValidator) { ThrowXMLwithMemMgr(InvalidDatatypeFacetException , XMLExcepts::FACET_Union_Null_baseValidator, manager); } if (baseValidator->getType() != DatatypeValidator::Union) { XMLCh value1[BUF_LEN+1]; XMLString::binToText(baseValidator->getType(), value1, BUF_LEN, 10, manager); ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Union_invalid_baseValidatorType , value1 , manager); } try { init(baseValidator, facets, enums, manager); } catch(const OutOfMemoryException&) { throw; } catch (...) { cleanUp(); throw; }}void UnionDatatypeValidator::init(DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets , RefArrayVectorOf<XMLCh>* const enums , MemoryManager* const manager){ if (enums) setEnumeration(enums, false); // Set Facets if any defined if (facets) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?