xobjectcomparator.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 970 行 · 第 1/3 页
CPP
970 行
/* * Copyright 2003,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: XObjectComparator.cpp,v $ * Revision 1.8 2004/09/23 00:37:24 cargilld * Remove unused variable and data member. * * Revision 1.7 2004/09/08 13:56:14 peiyongz * Apache License Version 2.0 * * Revision 1.6 2004/01/29 11:46:30 cargilld * Code cleanup changes to get rid of various compiler diagnostic messages. * * Revision 1.5 2003/12/17 00:18:34 cargilld * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. * * Revision 1.4 2003/12/16 18:42:27 knoaman * fMayMatch is no longer a data member of IC_Field * * Revision 1.3 2003/11/12 20:29:05 peiyongz * removal of fIDRefList * * Revision 1.2 2003/10/31 22:15:42 peiyongz * dumpContent * * Revision 1.1 2003/10/29 16:14:15 peiyongz * XObjectComparator/XTemplateComparator * * $Id: XObjectComparator.cpp,v 1.8 2004/09/23 00:37:24 cargilld Exp $ * */// ---------------------------------------------------------------------------// Includes// ---------------------------------------------------------------------------#include <xercesc/internal/XObjectComparator.hpp>#include <xercesc/internal/XTemplateComparator.hpp>#include <stdio.h>XERCES_CPP_NAMESPACE_BEGIN/********************************************************** * * XMLGrammarPool * * Grammar * * SchemaGrammar * DTDGrammar * ***********************************************************/ void XObjectComparator::dumpContent(XMLGrammarPoolImpl* const gramPool) { RefHashTableOf<Grammar>* gramReg = gramPool->fGrammarRegistry; RefHashTableOfEnumerator<Grammar> eNum(gramReg, false, gramPool->getMemoryManager()); int itemNumber = 0; while (eNum.hasMoreElements()) { eNum.nextElement(); itemNumber++; } printf("itemNumber = <%d>\n", itemNumber); //Any thing in the lValue shall be found in the rValue eNum.Reset(); while (eNum.hasMoreElements()) { XMLCh* key = (XMLCh*) eNum.nextElementKey(); char* keyChar = XMLString::transcode(key); printf("key=<%s>\n", keyChar); XMLString::release(&keyChar); Grammar* data = (Grammar*) gramReg->get(key); printf("grammarType = <%d>\n", data->getGrammarType()); }}bool XObjectComparator::isEquivalent(XMLGrammarPoolImpl* const lValue , XMLGrammarPoolImpl* const rValue){ IS_EQUIVALENT(lValue, rValue)#ifndef _DEBUG return ( XTemplateComparator::isEquivalent(lValue->fGrammarRegistry , rValue->fGrammarRegistry) && isEquivalent(lValue->fStringPool, rValue->fStringPool) );#else bool v1 = XTemplateComparator::isEquivalent(lValue->fGrammarRegistry , rValue->fGrammarRegistry); bool v2 = isEquivalent(lValue->fStringPool, rValue->fStringPool); return v1&&v2;#endif}bool XObjectComparator::isEquivalent(Grammar* const lValue , Grammar* const rValue){ IS_EQUIVALENT(lValue, rValue) if (lValue->getGrammarType() != rValue->getGrammarType()) return false; if (lValue->getGrammarType() == Grammar::SchemaGrammarType) { return isEquivalent((SchemaGrammar*)lValue, (SchemaGrammar*)rValue); } else { return isEquivalent((DTDGrammar*)lValue, (DTDGrammar*)rValue); }}bool XObjectComparator::isBaseEquivalent(Grammar* const , Grammar* const){ return true;}bool XObjectComparator::isEquivalent(SchemaGrammar* const lValue , SchemaGrammar* const rValue){ IS_EQUIVALENT(lValue, rValue) if (!isBaseEquivalent(lValue, rValue)) return false;#ifndef _DEBUG return ( (lValue->fValidated == rValue->fValidated) && XMLString::equals(lValue->fTargetNamespace, rValue->fTargetNamespace) && isEquivalent(lValue->fGramDesc, rValue->fGramDesc) && isEquivalent(&(lValue->fDatatypeRegistry), &(rValue->fDatatypeRegistry)) && XTemplateComparator::isEquivalent(lValue->fElemDeclPool , rValue->fElemDeclPool) && XTemplateComparator::isEquivalent(lValue->fElemNonDeclPool , rValue->fElemNonDeclPool) && XTemplateComparator::isEquivalent(lValue->fGroupElemDeclPool , rValue->fGroupElemDeclPool) && XTemplateComparator::isEquivalent(lValue->fNotationDeclPool , rValue->fNotationDeclPool) && XTemplateComparator::isEquivalent(lValue->fAttributeDeclRegistry , rValue->fAttributeDeclRegistry) && XTemplateComparator::isEquivalent(lValue->fComplexTypeRegistry , rValue->fComplexTypeRegistry) && XTemplateComparator::isEquivalent(lValue->fGroupInfoRegistry , rValue->fGroupInfoRegistry) &&/*** XTemplateComparator::isEquivalent(lValue->fIDRefList , rValue->fIDRefList) &&***/ XTemplateComparator::isEquivalent(lValue->fValidSubstitutionGroups , rValue->fValidSubstitutionGroups) );#else bool v1 = lValue->fValidated == rValue->fValidated; bool v2 = XMLString::equals(lValue->fTargetNamespace, rValue->fTargetNamespace); bool v3 = isEquivalent(lValue->fGramDesc, rValue->fGramDesc); bool v4 = isEquivalent(&(lValue->fDatatypeRegistry), &(rValue->fDatatypeRegistry)); bool v5 = XTemplateComparator::isEquivalent(lValue->fElemDeclPool , rValue->fElemDeclPool); bool v6 = XTemplateComparator::isEquivalent(lValue->fElemNonDeclPool , rValue->fElemNonDeclPool); bool v7 = XTemplateComparator::isEquivalent(lValue->fGroupElemDeclPool , rValue->fGroupElemDeclPool) ; bool v8 = XTemplateComparator::isEquivalent(lValue->fNotationDeclPool , rValue->fNotationDeclPool); bool v9 = XTemplateComparator::isEquivalent(lValue->fAttributeDeclRegistry , rValue->fAttributeDeclRegistry); bool v10 = XTemplateComparator::isEquivalent(lValue->fComplexTypeRegistry , rValue->fComplexTypeRegistry); bool v11 = XTemplateComparator::isEquivalent(lValue->fGroupInfoRegistry , rValue->fGroupInfoRegistry);/*** bool v12 = XTemplateComparator::isEquivalent(lValue->fIDRefList , rValue->fIDRefList);***/ bool v12 = true; bool v13 = XTemplateComparator::isEquivalent(lValue->fValidSubstitutionGroups , rValue->fValidSubstitutionGroups); return v1&&v2&&v3&&v4&&v5&&v6&&v7&&v8&&v9&&v10&&v11&&v12&&v13;#endif}/********************************************************** * * XMLGrammarDescription * * XMLSchemaDescription * XMLDTDDescription * ***********************************************************/ bool XObjectComparator::isEquivalent(XMLSchemaDescription* const lValue , XMLSchemaDescription* const rValue){ IS_EQUIVALENT(lValue, rValue) return true;}bool XObjectComparator::isEquivalent(XMLDTDDescription* const lValue , XMLDTDDescription* const rValue){ IS_EQUIVALENT(lValue, rValue) return true;}/********************************************************** * * XMLElementDecl * SchemaElementDecl * DTDElementDecl * ***********************************************************/ bool XObjectComparator::isBaseEquivalent(XMLElementDecl* const lValue , XMLElementDecl* const rValue){ IS_EQUIVALENT(lValue, rValue) return ( (lValue->fCreateReason == rValue->fCreateReason) && (lValue->fId == rValue->fId) && (lValue->fExternalElement == rValue->fExternalElement) && isEquivalent(lValue->getElementName(), rValue->getElementName()) );}bool XObjectComparator::isEquivalent(SchemaElementDecl* const lValue , SchemaElementDecl* const rValue){ IS_EQUIVALENT(lValue, rValue) if (!isBaseEquivalent((XMLElementDecl*)lValue, (XMLElementDecl*)rValue)) return false;#ifndef _DEBUG return ( (lValue->fModelType == rValue->fModelType) && (lValue->fEnclosingScope == rValue->fEnclosingScope) && (lValue->fFinalSet == rValue->fFinalSet) && (lValue->fBlockSet == rValue->fBlockSet) && (lValue->fMiscFlags == rValue->fMiscFlags) && (lValue->fValidity == rValue->fValidity) && (lValue->fValidation == rValue->fValidation) && (lValue->fSeenValidation == rValue->fSeenValidation) && (lValue->fSeenNoValidation == rValue->fSeenNoValidation) && (lValue->fHadContent == rValue->fHadContent) && XMLString::equals(lValue->fDefaultValue , rValue->fDefaultValue) && isEquivalent(lValue->fDatatypeValidator , rValue->fDatatypeValidator) && isEquivalent((DatatypeValidator*) lValue->fXsiSimpleTypeInfo , (DatatypeValidator*) rValue->fXsiSimpleTypeInfo) && isEquivalent(lValue->fComplexTypeInfo , rValue->fComplexTypeInfo) && isEquivalent(lValue->fXsiComplexTypeInfo , rValue->fXsiComplexTypeInfo) && isEquivalent(lValue->fAttWildCard , rValue->fAttWildCard) && isEquivalent(lValue->fSubstitutionGroupElem , rValue->fSubstitutionGroupElem) && XTemplateComparator::isEquivalent(lValue->fAttDefs , rValue->fAttDefs) && XTemplateComparator::isEquivalent(lValue->fIdentityConstraints , rValue->fIdentityConstraints) ); #else bool v1 = lValue->fModelType == rValue->fModelType; bool v2 = lValue->fEnclosingScope == rValue->fEnclosingScope; bool v3 = lValue->fFinalSet == rValue->fFinalSet; bool v4 = lValue->fBlockSet == rValue->fBlockSet; bool v5 = lValue->fMiscFlags == rValue->fMiscFlags; bool v6 = lValue->fValidity == rValue->fValidity; bool v7 = lValue->fValidation == rValue->fValidation; bool v8 = lValue->fSeenValidation == rValue->fSeenValidation; bool v9 = lValue->fSeenNoValidation == rValue->fSeenNoValidation; bool v10 = lValue->fHadContent == rValue->fHadContent; bool v11 = XMLString::equals(lValue->fDefaultValue , rValue->fDefaultValue); bool v12 = isEquivalent(lValue->fDatatypeValidator , rValue->fDatatypeValidator); bool v13 = isEquivalent((DatatypeValidator*) lValue->fXsiSimpleTypeInfo , (DatatypeValidator*) rValue->fXsiSimpleTypeInfo); bool v14 = isEquivalent(lValue->fComplexTypeInfo , rValue->fComplexTypeInfo); bool v15 = isEquivalent(lValue->fXsiComplexTypeInfo , rValue->fXsiComplexTypeInfo); bool v16 = isEquivalent(lValue->fAttWildCard , rValue->fAttWildCard); bool v17 = isEquivalent(lValue->fSubstitutionGroupElem , rValue->fSubstitutionGroupElem);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?