schemaelementdecl.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 505 行 · 第 1/2 页
CPP
505 行
, bool& wasAdded) const{ if (fComplexTypeInfo) { return fComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded); } else { if (options == XMLElementDecl::AddIfNotFound) { SchemaAttDef* retVal = 0; // If no att list exist yet, then create one if (!fAttDefs) { // Use a hash modulus of 29 and tell it owns its elements ((SchemaElementDecl*)this)->fAttDefs = new (getMemoryManager()) RefHash2KeysTableOf<SchemaAttDef>(29, true, getMemoryManager()); } retVal = fAttDefs->get(baseName, uriId); // Fault it in if not found and ask to add it if (!retVal) { // And add a default attribute for this name retVal = new (getMemoryManager()) SchemaAttDef ( prefix , baseName , uriId , XMLAttDef::CData , XMLAttDef::Implied , getMemoryManager() ); retVal->setElemId(getId()); fAttDefs->put((void*)retVal->getAttName()->getLocalPart(), uriId, retVal); wasAdded = true; } else { wasAdded = false; } return retVal; } else { wasAdded = false; return 0; } }}XMLAttDefList& SchemaElementDecl::getAttDefList() const{ if (!fComplexTypeInfo) { ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::DV_InvalidOperation, getMemoryManager()); } return fComplexTypeInfo->getAttDefList();}XMLElementDecl::CharDataOpts SchemaElementDecl::getCharDataOpts() const{ SchemaElementDecl::ModelTypes modelType = fModelType; if (fComplexTypeInfo) { modelType = (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType(); } XMLElementDecl::CharDataOpts retVal; switch(modelType) { case Children : retVal = XMLElementDecl::SpacesOk; break; case Empty : retVal = XMLElementDecl::NoCharData; break; default : retVal = XMLElementDecl::AllCharData; break; } return retVal;}bool SchemaElementDecl::hasAttDefs() const{ if (fComplexTypeInfo) { return fComplexTypeInfo->hasAttDefs(); } // If the collection hasn't been faulted in, then no att defs return false;}bool SchemaElementDecl::resetDefs(){ if (fComplexTypeInfo) { return fComplexTypeInfo->resetDefs(); } else if (fAttDefs) { //all the attdefs here are faulted-in, so just reset the fAttDefs //but still return false to indicate there is no real att defs // defined in this element fAttDefs->removeAll(); } return false;}const XMLCh*SchemaElementDecl::getFormattedContentModel() const{ if (fComplexTypeInfo) { return fComplexTypeInfo->getFormattedContentModel(); } return 0;}// ---------------------------------------------------------------------------// SchemaElementDecl: Getter methods// ---------------------------------------------------------------------------const SchemaAttDef* SchemaElementDecl::getAttDef(const XMLCh* const baseName, const int uriId) const{ if (fComplexTypeInfo) { return fComplexTypeInfo->getAttDef(baseName, uriId); } // If no complex type, then return a null return 0;}SchemaAttDef* SchemaElementDecl::getAttDef(const XMLCh* const baseName, const int uriId){ if (fComplexTypeInfo) { return fComplexTypeInfo->getAttDef(baseName, uriId); } // If no complex type, then return a null return 0;}/*** * Support for Serialization/De-serialization ***/IMPL_XSERIALIZABLE_TOCREATE(SchemaElementDecl)void SchemaElementDecl::serialize(XSerializeEngine& serEng){ XMLElementDecl::serialize(serEng); if (serEng.isStoring()) { serEng<<(int)fModelType; DatatypeValidator::storeDV(serEng, fDatatypeValidator); serEng<<fEnclosingScope; serEng<<fFinalSet; serEng<<fBlockSet; serEng<<fMiscFlags; serEng.writeString(fDefaultValue); serEng<<fComplexTypeInfo; /*** * Serialize RefHash2KeysTableOf<SchemaAttDef>* fAttDefs; ***/ XTemplateSerializer::storeObject(fAttDefs, serEng); serEng<<fXsiComplexTypeInfo; DatatypeValidator::storeDV(serEng, (DatatypeValidator*)fXsiSimpleTypeInfo); /*** * Serialize RefVectorOf<IdentityConstraint>* fIdentityConstraints; ***/ XTemplateSerializer::storeObject(fIdentityConstraints, serEng); serEng<<fAttWildCard; serEng<<fSubstitutionGroupElem; serEng<<(int)fValidity; serEng<<(int)fValidation; serEng<<fSeenValidation; serEng<<fSeenNoValidation; serEng<<fHadContent; } else { int i; serEng>>i; fModelType = (ModelTypes)i; fDatatypeValidator = DatatypeValidator::loadDV(serEng); serEng>>fEnclosingScope; serEng>>fFinalSet; serEng>>fBlockSet; serEng>>fMiscFlags; serEng.readString(fDefaultValue); serEng>>fComplexTypeInfo; /*** * DeSerialize RefHash2KeysTableOf<SchemaAttDef>* fAttDefs; ***/ XTemplateSerializer::loadObject(&fAttDefs, 29, true, serEng); serEng>>fXsiComplexTypeInfo; fXsiSimpleTypeInfo = DatatypeValidator::loadDV(serEng); /*** * DeSerialize RefVectorOf<IdentityConstraint>* fIdentityConstraints; ***/ XTemplateSerializer::loadObject(&fIdentityConstraints, 16, true, serEng); serEng>>fAttWildCard; serEng>>fSubstitutionGroupElem; serEng>>i; fValidity = (PSVIDefs::Validity)i; serEng>> i; fValidation = (PSVIDefs::Validation)i; serEng>>fSeenValidation; serEng>>fSeenNoValidation; serEng>>fHadContent; }}XMLElementDecl::objectType SchemaElementDecl::getObjectType() const{ return Schema;}XERCES_CPP_NAMESPACE_END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?