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

📄 genericeventhandler.cxx

📁 SP是一个基于GNU C++编译器
💻 CXX
📖 第 1 页 / 共 2 页
字号:
    case Markup::entityEnd:      depth--;      break;    default:      break;    }  switch (event->status()) {  case MarkedSectionEvent::include:    appEvent.status = SGMLApplication::MarkedSectionStartEvent::include;    break;  case MarkedSectionEvent::rcdata:    appEvent.status = SGMLApplication::MarkedSectionStartEvent::rcdata;    break;  case MarkedSectionEvent::cdata:    appEvent.status = SGMLApplication::MarkedSectionStartEvent::cdata;    break;  case MarkedSectionEvent::ignore:    appEvent.status = SGMLApplication::MarkedSectionStartEvent::ignore;    break;  }  setLocation(appEvent.pos, event->location());  app_->markedSectionStart(appEvent);  freeAll();  delete event;}void GenericEventHandler::ignoredChars(IgnoredCharsEvent *event){  SGMLApplication::IgnoredCharsEvent appEvent;  appEvent.data.ptr = event->data();  appEvent.data.len = event->dataLength();  setLocation(appEvent.pos, event->location());  app_->ignoredChars(appEvent);  delete event;}void GenericEventHandler::markedSectionEnd(MarkedSectionEndEvent *event){  SGMLApplication::MarkedSectionEndEvent appEvent;  switch (event->status()) {  case MarkedSectionEvent::include:    appEvent.status = SGMLApplication::MarkedSectionEndEvent::include;    break;  case MarkedSectionEvent::rcdata:    appEvent.status = SGMLApplication::MarkedSectionEndEvent::rcdata;    break;  case MarkedSectionEvent::cdata:    appEvent.status = SGMLApplication::MarkedSectionEndEvent::cdata;    break;  case MarkedSectionEvent::ignore:    appEvent.status = SGMLApplication::MarkedSectionEndEvent::ignore;    break;  }  setLocation(appEvent.pos, event->location());  app_->markedSectionEnd(appEvent);  delete event;}void GenericEventHandler::message(MessageEvent *event){  SGMLApplication::ErrorEvent appEvent;  switch (event->message().type->severity()) {  case MessageType::quantityError:    appEvent.type = SGMLApplication::ErrorEvent::quantity;    break;  case MessageType::idrefError:    appEvent.type = SGMLApplication::ErrorEvent::idref;    break;  case MessageType::error:    appEvent.type = SGMLApplication::ErrorEvent::otherError;    break;  case MessageType::info:    appEvent.type = SGMLApplication::ErrorEvent::info;    break;  case MessageType::warning:    appEvent.type = SGMLApplication::ErrorEvent::warning;    break;  }  setLocation(appEvent.pos, event->message().loc);  StringC str;  reportMessage(event->message(), str);  setString(appEvent.message, str);  app_->error(appEvent);  ErrorCountEventHandler::message(event);}void GenericEventHandler::setLocation1(SGMLApplication::Position &pos,				   const Location &loc){  const Location *locp = &loc;  for (;;) {    if (locp->origin().isNull()) {      lastOrigin_.clear();      openEntityPtr_ = (SpOpenEntity *)0;      return;    }    const InputSourceOrigin *origin = locp->origin()->asInputSourceOrigin();    if (origin && origin->externalInfo())      break;    locp = &locp->origin()->parent();  }  lastOrigin_ = locp->origin();  pos = locp->index();  openEntityPtr_ = new SpOpenEntity(locp->origin());  app_->openEntityChange(openEntityPtr_);}void GenericEventHandler::setAttributes(const SGMLApplication::Attribute *&attributes,			       const AttributeList &attributeList){  size_t nAttributes = attributeList.size();  SGMLApplication::Attribute *to    = (SGMLApplication::Attribute *)allocate(nAttributes * sizeof(*to));  attributes = to;  for (size_t i = 0; i < nAttributes; i++) {    SGMLApplication::Attribute *p = to + i;    setString(p->name, attributeList.name(i));    const AttributeValue *value = attributeList.value(i);    if (!value)      p->type = SGMLApplication::Attribute::invalid;    else {      const Text *text;      const StringC *string;      switch (value->info(text, string)) {      case AttributeValue::implied:	p->type = SGMLApplication::Attribute::implied;	break;      case AttributeValue::tokenized:	{	  if (attributeList.specified(i))	    p->defaulted = SGMLApplication::Attribute::specified;	  else if (attributeList.current(i))	    p->defaulted = SGMLApplication::Attribute::current;	  else	    p->defaulted = SGMLApplication::Attribute::definition;	  p->type = SGMLApplication::Attribute::tokenized;	  p->nEntities = 0;	  p->notation.name.len = 0;	  p->isId = attributeList.id(i);	  p->isGroup = (attributeList.getAllowedTokens(i) != 0);	  setString(p->tokens, *string);	  const AttributeSemantics *semantics = attributeList.semantics(i);	  if (semantics) {	    ConstPtr<Notation> notation = semantics->notation();	    if (!notation.isNull())	      setNotation(p->notation, *notation);	    else {	      size_t nEntities = semantics->nEntities();	      if (nEntities) {		SGMLApplication::Entity *v		  = (SGMLApplication::Entity *)allocate(nEntities * sizeof(*v));		p->entities = v;		p->nEntities = nEntities;		for (size_t i = 0; i < nEntities; i++)		  setEntity(v[i], *semantics->entity(i));	      }	    }	  }	}	break;      case AttributeValue::cdata:	{	  p->type = SGMLApplication::Attribute::cdata;	  if (attributeList.specified(i))	    p->defaulted = SGMLApplication::Attribute::specified;	  else if (attributeList.current(i))	    p->defaulted = SGMLApplication::Attribute::current;	  else	    p->defaulted = SGMLApplication::Attribute::definition;	  TextItem::Type type;	  const Char *s;	  size_t length;	  const Location *loc;	  size_t nChunks = 0;	  {	    TextIter iter(*text);	    while (iter.next(type, s, length, loc))	      switch (type) {	      case TextItem::data:	      case TextItem::sdata:	      case TextItem::cdata:	      case TextItem::nonSgml:		nChunks++;		break;	      default:		break;	      }	  }	  p->cdataChunks	    = (SGMLApplication::Attribute::CdataChunk *)allocate(nChunks * sizeof(SGMLApplication::Attribute::CdataChunk));	  p->nCdataChunks = nChunks;	  {	    size_t i = 0;	    for (TextIter iter(*text); iter.next(type, s, length, loc);) {	      switch (type) {	      case TextItem::data:	      case TextItem::sdata:	      case TextItem::cdata:		{		  SGMLApplication::Attribute::CdataChunk *chunk		    = (SGMLApplication::Attribute::CdataChunk *)(p->cdataChunks + i++);		  if (type != TextItem::sdata) {		    chunk->isSdata = 0;		    chunk->isNonSgml = 0;		  }		  else {		    chunk->isSdata = 1;		    setString(chunk->entityName,			      *loc->origin()->asInputSourceOrigin()->entityName());		  }		  chunk->data.ptr = s;		  chunk->data.len = length;		}		break;	      case TextItem::nonSgml:		{		  SGMLApplication::Attribute::CdataChunk *chunk		    = (SGMLApplication::Attribute::CdataChunk *)(p->cdataChunks + i++);		  chunk->isSdata = 0;		  chunk->isNonSgml = 1;		  chunk->nonSgmlChar = *s;		  chunk->data.len = 0;		  chunk->data.ptr = 0;		}		break;	      default:		break;	      }	    }	  }	}	break;      }    }  }}void GenericEventHandler::setEntity(SGMLApplication::Entity &to,				const Entity &from){  setString(to.name, from.name());  switch (from.declType()) {  case Entity::generalEntity:    to.declType = SGMLApplication::Entity::general;    break;  case Entity::parameterEntity:    to.declType = SGMLApplication::Entity::parameter;    break;  case Entity::doctype:    to.declType = SGMLApplication::Entity::doctype;    break;  case Entity::linktype:    to.declType = SGMLApplication::Entity::linktype;    break;  default:    CANNOT_HAPPEN();  }  switch (from.dataType()) {  case Entity::sgmlText:    to.dataType = SGMLApplication::Entity::sgml;    break;  case Entity::cdata:    to.dataType = SGMLApplication::Entity::cdata;    break;  case Entity::sdata:    to.dataType = SGMLApplication::Entity::sdata;    break;  case Entity::ndata:    to.dataType = SGMLApplication::Entity::ndata;    break;  case Entity::subdoc:    to.dataType = SGMLApplication::Entity::subdoc;    break;  case Entity::pi:    to.dataType = SGMLApplication::Entity::pi;    break;  }  const InternalEntity *internal = from.asInternalEntity();  if (internal) {    to.isInternal = 1;    setString(to.text, internal->string());  }  else {    const ExternalEntity *external = from.asExternalEntity();    to.isInternal = 0;    setExternalId(to.externalId, external->externalId());    const ExternalDataEntity *externalData = from.asExternalDataEntity();    if (externalData) {      setNotation(to.notation, *externalData->notation());      to.nAttributes = externalData->attributes().size();      if (to.nAttributes)	setAttributes(to.attributes, externalData->attributes());    }    else {      to.notation.name.len = 0;      to.nAttributes = 0;    }  }}void GenericEventHandler::setNotation(SGMLApplication::Notation &to,				      const Notation &from){  setString(to.name, from.name());  setExternalId(to.externalId, from.externalId());}void GenericEventHandler::setExternalId(SGMLApplication::ExternalId &to,					const ExternalId &from){  const StringC *str;  str = from.systemIdString();  if (str) {    to.haveSystemId = 1;    setString(to.systemId, *str);  }  else    to.haveSystemId = 0;  str = from.publicIdString();  if (str) {    to.havePublicId = 1;    setString(to.publicId, *str);  }  else    to.havePublicId = 0;  str = &from.effectiveSystemId();  if (str->size()) {    to.haveGeneratedSystemId = 1;    setString(to.generatedSystemId, *str);  }  else    to.haveGeneratedSystemId = 0;}MsgGenericEventHandler::MsgGenericEventHandler(SGMLApplication &app, 					       bool generalEntities,					       MessageReporter &reporter,					       const bool *messagesInhibitedPtr): GenericEventHandler(app, generalEntities),  reporter_(&reporter),  messagesInhibitedPtr_(messagesInhibitedPtr){}void MsgGenericEventHandler::reportMessage(const Message &msg, StringC &str){  WrapReporter wrap(reporter_);  reporter_->dispatchMessage(msg);  wrap.strStream.extractString(str);  if (!*messagesInhibitedPtr_)    *wrap.origStream << str;}SpOpenEntity::SpOpenEntity(const ConstPtr<Origin> &origin): origin_(origin){}SGMLApplication::LocationSpOpenEntity::location(SGMLApplication::Position pos) const{  SGMLApplication::Location loc;  const Origin *origin = origin_.pointer();  const InputSourceOrigin *inputSourceOrigin;  const ExternalInfo *externalInfo;  Index index = Index(pos);  for (;;) {    if (!origin)      return loc;    inputSourceOrigin = origin->asInputSourceOrigin();    if (inputSourceOrigin) {      externalInfo = inputSourceOrigin->externalInfo();      if (externalInfo)	break;    }    // Qualifier is for CodeWarrior    const ::SP_NAMESPACE_SCOPE Location &loc = origin->parent();    index = loc.index();    origin = loc.origin().pointer();  }  const StringC *entityName = inputSourceOrigin->entityName();  if (entityName)    GenericEventHandler::setString(loc.entityName, *entityName);  Offset off = inputSourceOrigin->startOffset(index);  loc.entityOffset = off;  if (!ExtendEntityManager::externalize(externalInfo, off, ((SpOpenEntity *)this)->soLoc_))    return loc;  loc.lineNumber = soLoc_.lineNumber;  GenericEventHandler::setString(loc.filename, soLoc_.actualStorageId);  loc.columnNumber = soLoc_.columnNumber;  loc.byteOffset = soLoc_.byteIndex;  loc.other = soLoc_.storageObjectSpec;  return loc;}#ifdef SP_NAMESPACE}#endif

⌨️ 快捷键说明

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