⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arcengine.cxx

📁 SP是一个基于GNU C++编译器
💻 CXX
📖 第 1 页 / 共 4 页
字号:
  mapP->suppressFlags = newSuppressFlags;  // Build the attribute map.  if (metaAttributed) {    Vector<PackedBoolean> renamed;    ConstPtr<AttributeDefinitionList> metaAttDef      = metaAttributed->attributeDef();    if (!metaAttDef.isNull())      renamed.assign(metaAttDef->size(), PackedBoolean(0));    if (linkAtts) {      Boolean specified;      unsigned index;      const Text *linkNamerText = considerNamer(*linkAtts, specified, index);      if (linkNamerText)	buildAttributeMapRename(*mapP, *linkNamerText, atts, linkAtts, renamed);    }    if (namerText)      buildAttributeMapRename(*mapP, *namerText, atts, 0, renamed);    buildAttributeMapRest(*mapP, atts, linkAtts, renamed);  }  return *mapP;}void ArcProcessor::considerSupr(const AttributeList &atts,				const AttributeList *linkAtts,				unsigned &thisSuppressFlags,				unsigned &newSuppressFlags,				Boolean &inhibitCache,				unsigned &arcSuprIndex){  arcSuprIndex = invalidAtt;  if (thisSuppressFlags & suppressSupr)    return;  if (!supportAtts_[rArcSuprA].size())    return;  const AttributeValue *val;  unsigned tem;  if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcSuprA], tem))    val = linkAtts->value(tem);  else if (atts.attributeIndex(supportAtts_[rArcSuprA], arcSuprIndex)) {    if (atts.current(arcSuprIndex) || atts.specified(arcSuprIndex))      inhibitCache = 1;    val = atts.value(arcSuprIndex);  }  else    return;  if (!val)    return;  const Text *textP = val->text();  if (!textP)    return;  StringC token = textP->string();  // FIXME trim spaces  docSyntax_->generalSubstTable()->subst(token);  // sArcForm suppress processing for all elements except  // those that have a non-implied ArcSupr attribute.  thisSuppressFlags &= ~suppressForm;  newSuppressFlags &= ~(suppressForm|suppressSupr);  if (matchName(token, "sArcForm"))    newSuppressFlags |= suppressForm;#if 0  // I don't think this is useful  else if (matchName(token, "sArcSupr"))    newSuppressFlags |= suppressSupr;#endif  else if (matchName(token, "sArcAll"))    newSuppressFlags |= (suppressSupr|suppressForm);  else if (!matchName(token, "sArcNone")) {    Messenger::setNextLocation(textP->charLocation(0));    Messenger::message(ArcEngineMessages::invalidSuppress,		       StringMessageArg(token));  }}void ArcProcessor::considerIgnD(const AttributeList &atts,				const AttributeList *linkAtts,				unsigned thisSuppressFlags,				unsigned &newSuppressFlags,				Boolean &inhibitCache,				unsigned &arcIgnDIndex){  arcIgnDIndex = invalidAtt;  if (thisSuppressFlags & suppressSupr)    return;  if (!supportAtts_[rArcIgnDA].size())    return;  const AttributeValue *val;  unsigned tem;  if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcIgnDA], tem))    val = linkAtts->value(tem);  else if (atts.attributeIndex(supportAtts_[rArcIgnDA], arcIgnDIndex)) {    if (atts.current(arcIgnDIndex) || atts.specified(arcIgnDIndex))      inhibitCache = 1;    val = atts.value(arcIgnDIndex);  }  else    return;  if (!val)    return;  const Text *textP = val->text();  if (!textP)    return;  StringC token = textP->string();  // FIXME trim spaces  docSyntax_->generalSubstTable()->subst(token);  newSuppressFlags &= ~(ignoreData|condIgnoreData);  if (matchName(token, "ArcIgnD"))    newSuppressFlags |= ignoreData;  else if (matchName(token, "cArcIgnD"))    newSuppressFlags |= condIgnoreData;  else if (!matchName(token, "nArcIgnD")) {    Messenger::setNextLocation(textP->charLocation(0));    Messenger::message(ArcEngineMessages::invalidIgnD,		       StringMessageArg(token));  }}const Attributed *ArcProcessor::considerForm(const AttributeList &atts,			   const AttributeList *linkAtts,			   const StringC &name,			   Boolean isNotation,			   unsigned thisSuppressFlags,			   unsigned &newSuppressFlags,			   Boolean &inhibitCache,			   unsigned &arcFormIndex){  arcFormIndex = invalidAtt;  if ((thisSuppressFlags & suppressForm)      && (supportAtts_[rArcSuprF].size() == 0	  || (thisSuppressFlags & suppressSupr)	  || isNotation))    return 0;  unsigned tem;  const AttributeValue *val;  if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcFormA], tem))    val = linkAtts->value(tem);  else if (atts.attributeIndex(supportAtts_[rArcFormA], arcFormIndex)) {    if (atts.current(arcFormIndex) || atts.specified(arcFormIndex))      inhibitCache = 1;    val = atts.value(arcFormIndex);  }  else    return autoForm(atts, name, isNotation,		    thisSuppressFlags, newSuppressFlags,		    inhibitCache, arcFormIndex);      if (!val)    return 0;  const Text *textP = val->text();  if (!textP)    return 0;  StringC metaName;  metaName = textP->string();  // FIXME should trim leading and trailing spaces  metaSyntax_->generalSubstTable()->subst(metaName);  if (!isNotation) {    const Attributed *metaAttributed = metaDtd_->lookupElementType(metaName);    if (!metaAttributed) // CONSTDTD      metaAttributed = lookupCreateUndefinedElement(metaName, Location(), *metaDtd_);    if (metaName == supportAtts_[rArcSuprF]) {      newSuppressFlags |= suppressForm;      return metaAttributed;    }    if (thisSuppressFlags & suppressForm)      return 0;    return metaAttributed;  }  else    return metaDtd_->lookupNotation(metaName).pointer();}const Attributed *ArcProcessor::autoForm(const AttributeList &atts,		       const StringC &name,		       Boolean isNotation,		       unsigned thisSuppressFlags,		       unsigned &newSuppressFlags,		       Boolean &inhibitCache,		       unsigned &idIndex){  if (!isNotation) {    const Attributed *metaAttributed;    if (openElementFlags_.size() == 0) {      metaAttributed = metaDtd_->documentElementType();      inhibitCache = 1;    }    else {      metaAttributed = 0;      if (arcAuto_)	metaAttributed = metaDtd_->lookupElementType(name);      if (!metaAttributed	  && supportAtts_[rArcBridF].size() > 0	  && atts.idIndex(idIndex)	  && atts.specified(idIndex)) {	inhibitCache = 1;	metaAttributed	  = metaDtd_->lookupElementType(supportAtts_[rArcBridF]);      }    }    if (metaAttributed	&& name == supportAtts_[rArcSuprF]) {      newSuppressFlags = suppressForm|ignoreData;    }    else if (thisSuppressFlags & suppressForm)      return 0;    return metaAttributed;  }  else if (thisSuppressFlags & suppressForm)    return 0;  else {    const Attributed *metaAttributed = 0;    if (arcAuto_)      metaAttributed = metaDtd_->lookupNotation(name).pointer();    if (!metaAttributed && supportAtts_[rArcDataF].size() > 0)      metaAttributed	= metaDtd_->lookupNotation(supportAtts_[rArcDataF]).pointer();    return metaAttributed;  }}const Text *ArcProcessor::considerNamer(const AttributeList &atts,			    Boolean &inhibitCache,			    unsigned &arcNamerIndex){  arcNamerIndex = invalidAtt;  if (supportAtts_[rArcNamrA].size() == 0      || !atts.attributeIndex(supportAtts_[rArcNamrA], arcNamerIndex))    return 0;  if (atts.current(arcNamerIndex) || atts.specified(arcNamerIndex))    inhibitCache = 1;  const AttributeValue *val = atts.value(arcNamerIndex);  if (!val)    return 0;  return val->text();}void ArcProcessor::buildAttributeMapRename(MetaMap &map,					   const Text &rename,					   const AttributeList &atts,					   const AttributeList *linkAtts,					   Vector<PackedBoolean> &attRenamed){  Vector<StringC> tokens;  Vector<size_t> tokensPos;  split(rename, docSyntax_->space(), tokens, tokensPos);  ConstPtr<AttributeDefinitionList> metaAttDef;  if (map.attributed)    metaAttDef = map.attributed->attributeDef();  // FIXME Should check that ARCCONT doesn't appear more than once.  for (size_t i = 0; i < tokens.size(); i += 2) {    unsigned fromIndex = invalidAtt;    unsigned toIndex = invalidAtt;    metaSyntax_->generalSubstTable()->subst(tokens[i]);    if (tokens[i] == rniArcCont_)      toIndex = contentPseudoAtt;    else if (metaAttDef.isNull()	     || !metaAttDef->attributeIndex(tokens[i], toIndex)) {      setNextLocation(rename.charLocation(tokensPos[i]));      Messenger::message(ArcEngineMessages::renameToInvalid,			 StringMessageArg(tokens[i]));    }    else if (attRenamed[toIndex]) {      toIndex = invalidAtt;      setNextLocation(rename.charLocation(tokensPos[i]));      Messenger::message(ArcEngineMessages::renameToDuplicate,			 StringMessageArg(tokens[i]));    }    if (i + 1 >= tokens.size()) {      setNextLocation(rename.charLocation(tokensPos[i]));      Messenger::message(ArcEngineMessages::renameMissingAttName);    }    else {      docSyntax_->generalSubstTable()->subst(tokens[i + 1]);      if (tokens[i + 1] == rniContent_) {	fromIndex = contentPseudoAtt;      }      else if (tokens[i + 1] == rniDefault_) {	if (toIndex != contentPseudoAtt)	  attRenamed[toIndex] = 1;      }      else if (linkAtts	       && linkAtts->attributeIndex(tokens[i + 1], fromIndex))	fromIndex += atts.size();      else if (!atts.attributeIndex(tokens[i + 1], fromIndex)) {	setNextLocation(rename.charLocation(tokensPos[i + 1]));	Messenger::message(ArcEngineMessages::renameFromInvalid,			   StringMessageArg(tokens[i + 1]));      }    }    if (fromIndex != invalidAtt && toIndex != invalidAtt) {      map.attMapFrom.push_back(fromIndex);      map.attMapTo.push_back(toIndex);      if (toIndex != contentPseudoAtt) {	attRenamed[toIndex] = 1;	if (metaAttDef->def(toIndex)->isId()	    && (fromIndex >= atts.size() || !atts.id(fromIndex)))	  Messenger::message(ArcEngineMessages::idMismatch,			     StringMessageArg(metaAttDef->def(toIndex)					      ->name()));      }    }  }}void ArcProcessor::buildAttributeMapRest(MetaMap &map,					 const AttributeList &atts,					 const AttributeList *linkAtts,					 const Vector<PackedBoolean> &attRenamed){  ConstPtr<AttributeDefinitionList> metaAttDef    = map.attributed->attributeDef();  if (metaAttDef.isNull())    return;  for (unsigned i = 0; i < metaAttDef->size(); i++)    if (!attRenamed[i]) {      unsigned fromIndex;      if (metaAttDef->def(i)->isId()) {	for (unsigned j = 0; j < atts.size(); j++)	  if (atts.id(j)) {	    map.attMapFrom.push_back(j);	    map.attMapTo.push_back(i);	    break;	  }      }      else if (linkAtts && linkAtts->attributeIndex(metaAttDef->def(i)->name(),						    fromIndex)) {	map.attMapFrom.push_back(fromIndex + atts.size());	map.attMapTo.push_back(i);      }      else if (atts.attributeIndex(metaAttDef->def(i)->name(), fromIndex)) {	map.attMapFrom.push_back(fromIndex);	map.attMapTo.push_back(i);      }    }}Boolean ArcProcessor::matchName(const StringC &name, const char *key){  if (name.size() != strlen(key))    return 0;  StringC tem(docSd_->execToInternal(key));  docSyntax_->generalSubstTable()->subst(tem);  return name == tem;}void ArcProcessor::split(const Text &text,			 Char space,			 Vector<StringC> &tokens,			 Vector<size_t> &tokensPos){  const StringC &str = text.string();  for (size_t i = 0;;) {    for (; i < str.size() && str[i] == space; i++)      ;    if (i >= str.size())      break;    size_t start = i;    for (; i < str.size() && str[i] != space; i++)      ;    tokens.push_back(StringC(str.data() + start, i - start));    tokensPos.push_back(start);  }}void ArcProcessor::processEndElement(const EndElementEvent &event,				     Allocator &alloc){  Boolean wasArc = (openElementFlags_.back() & isArc);  openElementFlags_.resize(openElementFlags_.size() - 1);  if (wasArc) {    EndElementEvent *genEvent      = new (alloc) EndElementEvent(currentElement().type(),					metaDtd_,					event.location(),					0);    if (currentElement().included())      genEvent->setIncluded();    docHandler_->endElement(genEvent);    if (!currentElement().isFinished())      Messenger::message(ArcEngineMessages::unfinishedElement,			 StringMessageArg(currentElement().type()->name()));    popElement();  }}void ArcProcessor::dispatchMessage(Message &msg){  mgr_->dispatchMessage(msg);}void ArcProcessor::dispatchMessage(const Message &msg){  mgr_->dispatchMessage(msg);}void ArcProcessor::initMessage(Message &msg){  mgr_->initMessage(msg);  if (valid_) {    StringC rniPcdata = metaSyntax_->delimGeneral(Syntax::dRNI);    rniPcdata += metaSyntax_->reservedName(Syntax::rPCDATA);    getOpenElementInfo(msg.openElementInfo, rniPcdata);  }}ArcProcessor::MetaMapCache::MetaMapCache(){  for (int i = 0; i < nNoSpec; i++)    noSpec[i] = invalidAtt;  linkAtts = 0;}void ArcProcessor::MetaMapCache::clear(){  for (int i = 0; i < nNoSpec; i++)    noSpec[i] = invalidAtt;  linkAtts = 0;  map.clear();}ArcProcessor::MetaMap::MetaMap(): attributed(0){}void ArcProcessor::MetaMap::clear(){  attMapFrom.clear();  attMapTo.clear();  attributed = 0;}#ifdef SP_NAMESPACE}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -