/** * Gets the pass and layer from the tag. */ void ColorBlock::applyTag(const XMLTag &tag) { const XMLTag *subtag; // add the shader subtag = tag.getSubTag(SHADER_TAG); if (subtag && subtag->hasAttribute(ATT_NAME)) _shader = _hostDisplay->getShader(subtag->getAttribute(ATT_NAME)); // add the mesh subtag = tag.getSubTag(MESH_TAG); if (subtag && subtag->hasAttribute(ATT_NAME)) _mesh = _hostDisplay->getMesh(subtag->getAttribute(ATT_NAME)); // add a texture subtag = tag.getSubTag(TEXTURE_TAG); if (subtag && subtag->hasAttribute(ATT_NAME)) _textures.push_back(_hostDisplay->getTexture(subtag->getAttribute(ATT_NAME))); // add textures subtag = tag.getSubTag(TEXTURES_TAG); if (subtag) { XMLTag::const_iterator itr; for (itr = subtag->begin(); itr != subtag->end(); ++itr) { if (**itr == TEXTURE_TAG && (*itr)->hasAttribute(ATT_NAME)) _textures.push_back(_hostDisplay->getTexture((*itr)->getAttribute(ATT_NAME))); } } }
XMLTag* XMLTag::GetEmbeddedTagByNameAndAttr(const char* tagName, const char* attrName, const char* attrValue, const UInt32 index) { if (fEmbeddedTags.GetLength() <= index) return NULL; XMLTag* result = NULL; UInt32 curIndex = 0; for (OSQueueIter iter(&fEmbeddedTags); !iter.IsDone(); iter.Next()) { XMLTag* temp = (XMLTag*)iter.GetCurrent()->GetEnclosingObject(); if (!strcmp(temp->GetTagName(), tagName) && (temp->GetAttributeValue(attrName) != NULL) && (!strcmp(temp->GetAttributeValue(attrName), attrValue))) { if (curIndex == index) { result = temp; break; } curIndex++; } } return result; }
XMLTag* TwoInOneAlg::Save() { XMLTag* tag = new XMLTag(XML_NODE_TWOINONEALG); tag->AddChild(m_firstAlg->Save()); tag->AddChild(m_secondAlg->Save()); return tag; }
char* XMLPrefsParser::GetPrefValueByRef(ContainerRef pref, const UInt32 inValueIndex, char** outPrefName, char** outDataType) { if (outPrefName != NULL) *outPrefName = pref->GetAttributeValue(kNameAttr); if (outDataType != NULL) { *outDataType = pref->GetAttributeValue(kTypeAttr); if (*outDataType == NULL) *outDataType = "CharArray"; } if (!strcmp(pref->GetTagName(), kPref)) { if (inValueIndex > 0) return NULL; else return pref->GetValue(); } if (!strcmp(pref->GetTagName(), kListPref)) { XMLTag* value = pref->GetEmbeddedTag(inValueIndex); if (value != NULL) return value->GetValue(); } if (!strcmp(pref->GetTagName(), kObject) || !strcmp(pref->GetTagName(), kObjectList)) *outDataType = "QTSS_Object"; return NULL; }
void XMLPrefsParser::AddNewObject( ContainerRef pref ) { if (!strcmp(pref->GetTagName(), kEmptyObject)) { // just flag that this is now a real object instead of a placeholder pref->SetTagName(kObject); return; } if (!strcmp(pref->GetTagName(), kObject)) { // change the object to be an object list and go to code below XMLTag* subObject = NEW XMLTag(kObject); XMLTag* objectPref; // copy all this objects tags into the new listed object while((objectPref = pref->GetEmbeddedTag()) != NULL) { pref->RemoveEmbeddedTag(objectPref); subObject->AddEmbeddedTag(objectPref); } pref->SetTagName(kObjectList); pref->AddEmbeddedTag(subObject); } // we want to fall through from second case above, so this isn't an else if (!strcmp(pref->GetTagName(), kObjectList)) { XMLTag* subObject = NEW XMLTag(kObject); pref->AddEmbeddedTag(subObject); } }
void XMLPrefsParser::AddPrefValue( ContainerRef pref, char* inNewValue) { if (!strcmp(pref->GetTagName(), kPref)) // is this a PREF tag { if (pref->GetValue() == NULL) { // easy case, no existing value, so just add a vlue pref->SetValue(inNewValue); return; } else { // it already has a value, so change the pref to be a list pref and go to code below char* firstValue = pref->GetValue(); XMLTag* value = NEW XMLTag(kValue); value->SetValue(firstValue); pref->SetTagName(kListPref); pref->SetValue(NULL); pref->AddEmbeddedTag(value); } } // we want to fall through from second case above, so this isn't an else if (!strcmp(pref->GetTagName(), kListPref)) { XMLTag* value = NEW XMLTag(kValue); value->SetValue(inNewValue); pref->AddEmbeddedTag(value); } }
void RCFSourceInfo::ParseRelayDestinations(XMLTag* relayTag) { // parse the NAME attribute of the relay tag and store it in the relayname attribute char* name = relayTag->GetAttributeValue("NAME"); if (name != NULL) { fName = new char[::strlen(name) + 1]; ::strcpy(fName, name); } UInt32 numTags = relayTag->GetNumEmbeddedTags(); AllocateOutputArray(numTags); // not all these are relay tags, but most are // Now actually go through and figure out what to put into these OutputInfo structures, // based on what's on the relay_destination line fNumOutputs = 0; for (UInt32 y = 0; y < numTags; y++) { XMLTag* destTag = relayTag->GetEmbeddedTagByNameAndAttr("OBJECT", "CLASS", "destination", y); if (destTag == NULL) return; char* destType = destTag->GetAttributeValue("TYPE"); if (destType == NULL) return; if (!strcmp(destType, "udp_destination")) ParseDestination(destTag, y); else if (!strcmp(destType, "announced_destination")) ParseAnnouncedDestination(destTag, y); fNumOutputs++; } }
XMLTag* CameraDriverRelay::Save() { XMLTag* tag = CameraDriver::Save(); tag->SetName(GetName()); tag->AddProperty(XML_ATTRIBUTE_TOPICNAME, m_stTopic); tag->AddProperty(XML_ATTRIBUTE_RATE, m_rate); return tag; }
void RCFSourceInfo::ParseDestination(XMLTag* destTag, UInt32 index) { XMLTag* prefTag; prefTag = destTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "out_addr"); if (prefTag != NULL) { char* outAddrStr = prefTag->GetValue(); if (outAddrStr != NULL) fOutputArray[index].fLocalAddr = SocketUtils::ConvertStringToAddr(outAddrStr); } prefTag = destTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "dest_addr"); if (prefTag != NULL) { char* destAddrStr = prefTag->GetValue(); if (destAddrStr != NULL) fOutputArray[index].fDestAddr = SocketUtils::ConvertStringToAddr(destAddrStr); } prefTag = destTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "ttl"); if (prefTag != NULL) { char* ttlStr = prefTag->GetValue(); if (ttlStr != NULL) fOutputArray[index].fTimeToLive = atoi(ttlStr); } prefTag = destTag->GetEmbeddedTagByNameAndAttr("LIST-PREF", "NAME", "udp_ports"); if (prefTag != NULL) { fOutputArray[index].fNumPorts = prefTag->GetNumEmbeddedTags(); fOutputArray[index].fPortArray = new UInt16[fOutputArray[index].fNumPorts]; ::memset(fOutputArray[index].fPortArray, 0, fOutputArray[index].fNumPorts * sizeof(UInt16)); for (UInt32 x = 0; x < fOutputArray[index].fNumPorts; x++) { XMLTag* portTag = prefTag->GetEmbeddedTagByName("VALUE", x); if (portTag != NULL) { char* portStr = portTag->GetValue(); if (portStr != NULL) { fOutputArray[index].fPortArray[x] = atoi(portStr); } } } } else { prefTag = destTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "udp_base_port"); if (prefTag == NULL) qtss_printf("Missing both 'udp_base_port' and 'udp_ports' tags.\n Cannot set up the destination!\n"); else { char* basePortStr = prefTag->GetValue(); if (basePortStr != NULL) fOutputArray[index].fBasePort = atoi(basePortStr); } } }
char OSISReferenceLinks::processText(std::string &text, const SWKey *key, const SWModule *module) { (void) key; (void) module; if (option) return 0; std::string token; bool intoken = false; bool stripThisToken = false; std::string orig = text; const char *from = orig.c_str(); for (text = ""; *from; ++from) { if (*from == '<') { intoken = true; token = ""; continue; } else if (*from == '>') { // process tokens intoken = false; if (std::strncmp(token.c_str(), "reference", 9) && std::strncmp(token.c_str(), "/reference", 10)) { text.push_back('<'); text.append(token); text.push_back('>'); } else { XMLTag tag; tag = token.c_str(); if (!tag.isEndTag() && type == tag.getAttribute("type") && (!subType.size() || subType == tag.getAttribute("subType"))) { stripThisToken = true; continue; } else if (tag.isEndTag() && stripThisToken) { stripThisToken = false; continue; } text.push_back('<'); text.append(token); text.push_back('>'); } continue; } if (intoken) { //copy token token.push_back(*from); } else { //copy text which is not inside a token text.push_back(*from); } } return 0; }
void XMLFile::Parse() { XMLTag* parentTag = m_root; XMLTag* currentTag = nullptr; std::string attrName; std::string attrContent; for (Token token : m_tokens) { switch (token.m_type) { case TokenType::OpeningTagStart: currentTag = new XMLTag(); parentTag->AddChild(currentTag); parentTag = currentTag; break; case TokenType::ClosingTagStart: parentTag = parentTag->mp_parent; break; case TokenType::TagName: if (currentTag->m_name == "") currentTag->m_name = token.m_content; break; case TokenType::TagContent: currentTag->m_value = token.m_content; break; case TokenType::AttributeName: attrName = token.m_content; break; case TokenType::AttributeContent: attrContent = token.m_content; currentTag->m_attributes[attrName] = attrContent; break; case TokenType::TagEnd: break; case TokenType::EqualSign: break; case TokenType::DoubleQuote: break; } } }
ContainerRef XMLPrefsParser::AddPref( ContainerRef container, char* inPrefName, char* inPrefDataType ) { XMLTag* pref = container->GetEmbeddedTagByAttr(kNameAttr, inPrefName); if (pref != NULL) return pref; // it already exists pref = NEW XMLTag(kPref); // start it out as a pref pref->AddAttribute(kNameAttr, inPrefName); if (!strcmp(inPrefDataType, "QTSS_Object")) pref->SetTagName(kEmptyObject); else if (strcmp(inPrefDataType, "CharArray")) pref->AddAttribute(kTypeAttr, (char*)inPrefDataType); container->AddEmbeddedTag(pref); return pref; }
void XMLPrefsParser::SetPrefValue( ContainerRef pref, const UInt32 inValueIndex, char* inNewValue) { UInt32 numValues = GetNumPrefValues(pref); if (((numValues == 0) || (numValues == 1)) && (inValueIndex == 0)) { pref->SetValue(inNewValue); } else if (inValueIndex == numValues) // this is an additional value AddPrefValue(pref, inNewValue); else { XMLTag* value = pref->GetEmbeddedTag(inValueIndex); if (value != NULL) value->SetValue(inNewValue); } }
void XMLPrefsParser::RemovePrefValue( ContainerRef pref, const UInt32 inValueIndex) { UInt32 numValues = GetNumPrefValues(pref); if (inValueIndex >= numValues) return; if (numValues == 1) { delete pref; // just remove the whole pref } else if (numValues == 2) { XMLTag* value = pref->GetEmbeddedTag(inValueIndex); // get the one we're removing delete value; // delete it value = pref->GetEmbeddedTag(0); // get the remaining tag index always 0 for 2 vals pref->RemoveEmbeddedTag(value); // pull it out of the parent if (!strcmp(pref->GetTagName(), kObjectList)) { pref->SetTagName(kObject); // set it back to a simple pref // move all this objects tags into the parent XMLTag* objectPref; while((objectPref = value->GetEmbeddedTag()) != NULL) { value->RemoveEmbeddedTag(objectPref); pref->AddEmbeddedTag(objectPref); } } else { char* temp = value->GetValue(); pref->SetTagName(kPref); // set it back to a simple pref pref->SetValue(temp); } delete value; // get rid of the other one } else { XMLTag* value = pref->GetEmbeddedTag(inValueIndex); if (value) delete value; } }
void XMLTag::FormatData(ResizeableStringFormatter* formatter, UInt32 indent) { for (UInt32 i=0; i<indent; i++) formatter->PutChar('\t'); formatter->PutChar('<'); formatter->Put(fTag); if (fAttributes.GetLength() > 0) { formatter->PutChar(' '); for (OSQueueIter iter(&fAttributes); !iter.IsDone(); iter.Next()) { XMLAttribute* attr = (XMLAttribute*)iter.GetCurrent()->GetEnclosingObject(); formatter->Put(attr->fAttrName); formatter->Put("=\""); formatter->Put(attr->fAttrValue); formatter->Put("\" "); } } formatter->PutChar('>'); if (fEmbeddedTags.GetLength() == 0) { if (fValue > 0) formatter->Put(fValue); } else { formatter->Put(kEOLString); for (OSQueueIter iter(&fEmbeddedTags); !iter.IsDone(); iter.Next()) { XMLTag* current = (XMLTag*)iter.GetCurrent()->GetEnclosingObject(); current->FormatData(formatter, indent + 1); } for (UInt32 i=0; i<indent; i++) formatter->PutChar('\t'); } formatter->Put("</"); formatter->Put(fTag); formatter->PutChar('>'); formatter->Put(kEOLString); }
void xmlTagCallback(XMLTag &callingTag) { if (callingTag.getName() == "test-double") { doubleValue = callingTag.getDoubleAttributeValue("attribute"); } if (callingTag.getName() == "test-eigen") { eigenValue = callingTag.getEigenVectorXdAttributeValue("attribute", 3); } if (callingTag.getName() == "test-int") { intValue = callingTag.getIntAttributeValue("attribute"); } if (callingTag.getName() == "test-bool") { boolValue = callingTag.getBooleanAttributeValue("attribute"); } if (callingTag.getName() == "test-string") { stringValue = callingTag.getStringAttributeValue("text"); } }
char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) { SWBuf token; bool intoken = false; bool hide = false; SWBuf tagText; XMLTag startTag; SWBuf refs = ""; int footnoteNum = 1; char buf[254]; SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey(); VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p); if (!parser) { delete p; parser = new VerseKey(); } *parser = key->getText(); SWBuf orig = text; const char *from = orig.c_str(); for (text = ""; *from; from++) { if (*from == '<') { intoken = true; token = ""; continue; } if (*from == '>') { // process tokens intoken = false; XMLTag tag(token); if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { refs = ""; startTag = tag; hide = true; tagText = ""; continue; } } if (hide && tag.isEndTag()) { if (module->isProcessEntryAttributes()) { SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"]; footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0; sprintf(buf, "%i", ++footnoteNum); module->getEntryAttributes()["Footnote"]["count"]["value"] = buf; StringList attributes = startTag.getAttributeNames(); for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) { module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str()); } module->getEntryAttributes()["Footnote"][buf]["body"] = tagText; startTag.setAttribute("swordFootnote", buf); if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) { if (!refs.length()) refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText(); module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str(); } } hide = false; if ((option) || ((startTag.getAttribute("type") && (!strcmp(startTag.getAttribute("type"), "crossReference"))))) { // we want the tag in the text; crossReferences are handled by another filter text += startTag; text.append(tagText); } else continue; } } // if not a note token, keep token in text if ((!strcmp(tag.getName(), "scripRef")) && (!tag.isEndTag())) { SWBuf osisRef = tag.getAttribute("passage"); if (refs.length()) refs += "; "; refs += osisRef; } if (!hide) { text += '<'; text.append(token); text += '>'; } else { tagText += '<'; tagText.append(token); tagText += '>'; } continue; } if (intoken) { //copy token token += *from; } else if (!hide) { //copy text which is not inside a token text += *from; } else tagText += *from; } delete parser; return 0; }
void RCFSourceInfo::Parse(XMLTag* relayTag) { XMLTag* sourceTag = relayTag->GetEmbeddedTagByNameAndAttr("OBJECT", "CLASS", "source"); if (sourceTag == NULL) return; fNumStreams = 0; UInt32 destIPAddr = 0; UInt32 srcIPAddr = 0; UInt16 ttl = 0; XMLTag* prefTag; prefTag = sourceTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "in_addr"); if (prefTag != NULL) { char* destAddrStr = prefTag->GetValue(); if (destAddrStr != NULL) destIPAddr = SocketUtils::ConvertStringToAddr(destAddrStr); } prefTag = sourceTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "source_addr"); if (prefTag != NULL) { char* srcAddrStr = prefTag->GetValue(); if (srcAddrStr != NULL) srcIPAddr = SocketUtils::ConvertStringToAddr(srcAddrStr); } prefTag = sourceTag->GetEmbeddedTagByNameAndAttr("PREF", "NAME", "ttl"); if (prefTag != NULL) { char* ttlStr = prefTag->GetValue(); if (ttlStr != NULL) ttl = atoi(ttlStr); } prefTag = sourceTag->GetEmbeddedTagByNameAndAttr("LIST-PREF", "NAME", "udp_ports"); if (prefTag != NULL) { fNumStreams = prefTag->GetNumEmbeddedTags(); // Allocate a proper sized stream array fStreamArray = new StreamInfo[fNumStreams]; for (UInt32 x = 0; x < fNumStreams; x++) { XMLTag* portTag = prefTag->GetEmbeddedTagByName("VALUE", x); int port = 0; if (portTag != NULL) { char* portStr = portTag->GetValue(); if (portStr != NULL) port = atoi(portStr); } // Setup all the StreamInfo structures fStreamArray[x].fSrcIPAddr = srcIPAddr; fStreamArray[x].fDestIPAddr = destIPAddr; fStreamArray[x].fPort = port; fStreamArray[x].fTimeToLive = ttl; fStreamArray[x].fPayloadType = qtssUnknownPayloadType; fStreamArray[x].fTrackID = x + 1; } } // Now go through all the relay_destination lines (starting from the next line after the // relay_source line. this->ParseRelayDestinations(relayTag); }
void x86_mce_callback_register(x86_mce_callback_t cbfunc) { mc_callback_bank_extended = cbfunc; } /* Machine check recoverable judgement callback handler * It is used to judge whether an UC error is recoverable by software */ static mce_recoverable_t mc_recoverable_scan = NULL; void mce_recoverable_register(mce_recoverable_t cbfunc) { mc_recoverable_scan = cbfunc; } /* Judging whether to Clear Machine Check error bank callback handler * According to Intel latest MCA OS Recovery Writer's Guide, * whether the error MCA bank needs to be cleared is decided by the mca_source * and MCi_status bit value. */ static mce_need_clearbank_t mc_need_clearbank_scan = NULL; void mce_need_clearbank_register(mce_need_clearbank_t cbfunc) { mc_need_clearbank_scan = cbfunc; } /* Utility function to perform MCA bank telemetry readout and to push that * telemetry towards an interested dom0 for logging and diagnosis. * The caller - #MC handler or MCA poll function - must arrange that we * do not migrate cpus. */ /* XXFM Could add overflow counting? */ /* Add out_param clear_bank for Machine Check Handler Caller. * For Intel latest CPU, whether to clear the error bank status needs to * be judged by the callback function defined above. */ mctelem_cookie_t mcheck_mca_logout(enum mca_source who, cpu_banks_t bankmask, struct mca_summary *sp, cpu_banks_t* clear_bank) { struct vcpu *v = current; struct domain *d; uint64_t gstatus, status, addr, misc; struct mcinfo_global mcg; /* on stack */ struct mcinfo_common *mic; struct mcinfo_global *mig; /* on stack */ mctelem_cookie_t mctc = NULL; uint32_t uc = 0, pcc = 0, recover, need_clear = 1 ; struct mc_info *mci = NULL; mctelem_class_t which = MC_URGENT; /* XXXgcc */ unsigned int cpu_nr; int errcnt = 0; int i; enum mca_extinfo cbret = MCA_EXTINFO_IGNORED; cpu_nr = smp_processor_id(); BUG_ON(cpu_nr != v->processor); mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus); memset(&mcg, 0, sizeof (mcg)); mcg.common.type = MC_TYPE_GLOBAL; mcg.common.size = sizeof (mcg); if (v != NULL && ((d = v->domain) != NULL)) { mcg.mc_domid = d->domain_id; mcg.mc_vcpuid = v->vcpu_id; } else { mcg.mc_domid = -1; mcg.mc_vcpuid = -1; } mcg.mc_gstatus = gstatus; /* MCG_STATUS */ switch (who) { case MCA_MCE_HANDLER: case MCA_MCE_SCAN: mcg.mc_flags = MC_FLAG_MCE; which = MC_URGENT; break; case MCA_POLLER: case MCA_RESET: mcg.mc_flags = MC_FLAG_POLLED; which = MC_NONURGENT; break; case MCA_CMCI_HANDLER: mcg.mc_flags = MC_FLAG_CMCI; which = MC_NONURGENT; break; default: BUG(); } /* Retrieve detector information */ x86_mc_get_cpu_info(cpu_nr, &mcg.mc_socketid, &mcg.mc_coreid, &mcg.mc_core_threadid, &mcg.mc_apicid, NULL, NULL, NULL); /* If no mc_recovery_scan callback handler registered, * this error is not recoverable */ recover = (mc_recoverable_scan)? 1: 0; for (i = 0; i < 32 && i < nr_mce_banks; i++) { struct mcinfo_bank mcb; /* on stack */ /* Skip bank if corresponding bit in bankmask is clear */ if (!test_bit(i, bankmask)) continue; mca_rdmsrl(MSR_IA32_MC0_STATUS + i * 4, status); if (!(status & MCi_STATUS_VAL)) continue; /* this bank has no valid telemetry */ /* For Intel Latest CPU CMCI/MCE Handler caller, we need to * decide whether to clear bank by MCi_STATUS bit value such as * OVER/UC/EN/PCC/S/AR */ if ( mc_need_clearbank_scan ) need_clear = mc_need_clearbank_scan(who, status); /* If this is the first bank with valid MCA DATA, then * try to reserve an entry from the urgent/nonurgent queue * depending on whethere we are called from an exception or * a poller; this can fail (for example dom0 may not * yet have consumed past telemetry). */ if (errcnt == 0) { if ((mctc = mctelem_reserve(which)) != NULL) { mci = mctelem_dataptr(mctc); mcinfo_clear(mci); } } memset(&mcb, 0, sizeof (mcb)); mcb.common.type = MC_TYPE_BANK; mcb.common.size = sizeof (mcb); mcb.mc_bank = i; mcb.mc_status = status; /* form a mask of which banks have logged uncorrected errors */ if ((status & MCi_STATUS_UC) != 0) uc |= (1 << i); /* likewise for those with processor context corrupt */ if ((status & MCi_STATUS_PCC) != 0) pcc |= (1 << i); if (recover && uc) /* uc = 1, recover = 1, we need not panic. */ recover = mc_recoverable_scan(status); addr = misc = 0; if (status & MCi_STATUS_ADDRV) { mca_rdmsrl(MSR_IA32_MC0_ADDR + 4 * i, addr); d = maddr_get_owner(addr); if (d != NULL && (who == MCA_POLLER || who == MCA_CMCI_HANDLER)) mcb.mc_domid = d->domain_id; } if (status & MCi_STATUS_MISCV) mca_rdmsrl(MSR_IA32_MC0_MISC + 4 * i, misc); mcb.mc_addr = addr; mcb.mc_misc = misc; if (who == MCA_CMCI_HANDLER) { mca_rdmsrl(MSR_IA32_MC0_CTL2 + i, mcb.mc_ctrl2); rdtscll(mcb.mc_tsc); } /* Increment the error count; if this is the first bank * with a valid error then add the global info to the mcinfo. */ if (errcnt++ == 0 && mci != NULL) x86_mcinfo_add(mci, &mcg); /* Add the bank data */ if (mci != NULL) x86_mcinfo_add(mci, &mcb); if (mc_callback_bank_extended && cbret != MCA_EXTINFO_GLOBAL) { cbret = mc_callback_bank_extended(mci, i, status);
bool OSISHeadings::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { MyUserData *u = (MyUserData *)userData; XMLTag tag(token); SWBuf name = tag.getName(); // we only care about titles and divs or if we're already in a heading // // are we currently in a heading? if (u->currentHeadingName.size()) { u->heading.append(u->lastTextNode); if (name == u->currentHeadingName) { if (tag.isEndTag(u->sID)) { if (!u->depth-- || u->sID) { // see comment below about preverse div changed and needing to preserve the <title> container tag for old school pre-verse titles // we've just finished a heading. It's all stored up in u->heading bool canonical = (SWBuf("true") == u->currentHeadingTag.getAttribute("canonical")); bool preverse = (SWBuf("x-preverse") == u->currentHeadingTag.getAttribute("subType") || SWBuf("x-preverse") == u->currentHeadingTag.getAttribute("subtype")); // do we want to put anything in EntryAttributes? if (u->module->isProcessEntryAttributes() && (option || canonical || !preverse)) { SWBuf buf; buf.appendFormatted("%i", u->headerNum++); // leave the actual <title...> wrapper in if we're part of an old school preverse title // because now frontend have to deal with preverse as a div which may or may not include <title> elements // and they can't simply wrap all preverse material in <h1>, like they probably did previously SWBuf heading; if (u->currentHeadingName == "title") { XMLTag wrapper = u->currentHeadingTag; if (SWBuf("x-preverse") == wrapper.getAttribute("subType")) wrapper.setAttribute("subType", 0); else if (SWBuf("x-preverse") == wrapper.getAttribute("subtype")) wrapper.setAttribute("subtype", 0); heading = wrapper; heading += u->heading; heading += tag; } else heading = u->heading; u->module->getEntryAttributes()["Heading"][(preverse)?"Preverse":"Interverse"][buf] = heading; StringList attributes = u->currentHeadingTag.getAttributeNames(); for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) { u->module->getEntryAttributes()["Heading"][buf][it->c_str()] = u->currentHeadingTag.getAttribute(it->c_str()); } } // do we want the heading in the body? if (!preverse && (option || canonical)) { buf.append(u->currentHeadingTag); buf.append(u->heading); buf.append(tag); } u->suspendTextPassThru = false; u->clear(); } } else u->depth++; } u->heading.append(tag); return true; } // are we a title or a preverse div? else if ( name == "title" || (name == "div" && ( SWBuf("x-preverse") == tag.getAttribute("subType") || SWBuf("x-preverse") == tag.getAttribute("subtype")))) { u->currentHeadingName = name; u->currentHeadingTag = tag; u->heading = ""; u->sID = u->currentHeadingTag.getAttribute("sID"); u->depth = 0; u->suspendTextPassThru = true; return true; } return false; }
XMLTag* CameraDriver::Save() { XMLTag* tag = new XMLTag(GetName()); Camera::SaveTo(tag); tag->AddProperty(XML_ATTRIBUTE_CALIBFILE, m_stCalibName); tag->AddProperty(XML_ATTRIBUTE_HASPTU, m_hasPTU ? 1 : 0); tag->AddProperty(XML_ATTRIBUTE_GRABBERNAME, m_grabberName); tag->AddProperty(XML_ATTRIBUTE_CAMERATYPE, m_stCameraType); tag->AddProperty(XML_ATTRIBUTE_CAMCOLOR, (int)m_isColor); tag->AddProperty(XML_ATTRIBUTE_IMGWIDTH, m_imageWidth); tag->AddProperty(XML_ATTRIBUTE_IMGHEIGHT, m_imageHeight); tag->AddProperty(XML_ATTRIBUTE_CAMPORT, m_port); tag->AddProperty(XML_ATTRIBUTE_HRESOLUTION ,m_hresolution); tag->AddProperty(XML_ATTRIBUTE_VRESOLUTION ,m_vresolution); tag->AddProperty(XML_ATTRIBUTE_STARTROW ,m_startRow); tag->AddProperty(XML_ATTRIBUTE_STARTCOLUMN ,m_startColumn); tag->AddProperty(XML_ATTRIBUTE_FIELD ,m_field); tag->AddProperty(XML_ATTRIBUTE_BITSPERCHANNEL ,m_BitsPerChannel); tag->AddProperty(XML_ATTRIBUTE_COLORSPACE ,m_colorSpace); tag->AddProperty(XML_ATTRIBUTE_GENERIC ,m_generic); tag->AddProperty(XML_ATTRIBUTE_DEVICE ,m_device); tag->AddProperty(XML_ATTRIBUTE_EXTERNALTRIGGER,m_externalTrigger); tag->AddProperty(XML_ATTRIBUTE_LINEIN ,m_lineIn); return tag; }
// Return true if the content was handled or is to be ignored. // false if the what has been seen is to be accumulated and considered later. bool handleToken(std::string & text, XMLTag & token) { // The start token for the current entry; static XMLTag startTag; // Flags to indicate whether we are in a entry, entryFree or superentry static bool inEntry = false; static bool inEntryFree = false; static bool inSuperEntry = false; std::string const & tokenName = token.name(); static char const * splitPtr; static char const * splitPtr2 = nullptr; static std::array<char, 4096> splitBuffer; static SWKey tmpKey; //-- START TAG ------------------------------------------------------------------------- if (!token.isEndTag()) { // If we are not in an "entry" and we see one, then enter it. if (!inEntry && !inEntryFree && !inSuperEntry) { inEntry = (tokenName == "entry"); inEntryFree = (tokenName == "entryFree"); inSuperEntry = (tokenName == "superentry"); if (inEntry || inEntryFree || inSuperEntry) { #ifdef DEBUG cout << "Entering " << tokenName << endl; #endif startTag = token; text = ""; keyStr = token.attribute("n"); // P5 with linking and/or non-URI chars if (keyStr.empty()) { keyStr = token.attribute("sortKey"); // P5 otherwise if (keyStr.empty()) { keyStr = token.attribute("key"); // P4 } } return false; // make tag be part of the output } } } //-- EMPTY and END TAG --------------------------------------------------------------------------------------------- else { // ENTRY end // If we see the end of an entry that we are in, then leave it if ((inEntry && (tokenName == "entry" )) || (inEntryFree && (tokenName == "entryFree" )) || (inSuperEntry && (tokenName == "superentry"))) { #ifdef DEBUG cout << "Leaving " << tokenName << endl; #endif // Only one is false coming into here, // but all must be on leaving. inEntry = false; inEntryFree = false; inSuperEntry = false; text += token.toString(); entryCount++; #ifdef DEBUG cout << "keyStr: " << keyStr << endl; #endif splitPtr = std::strchr(keyStr.c_str(), '|'); if (splitPtr) { std::strncpy (splitBuffer.data(), keyStr.c_str(), splitPtr - keyStr.c_str()); splitBuffer[splitPtr - keyStr.c_str()] = 0; currentKey->setText(splitBuffer.data()); #ifdef DEBUG cout << "splitBuffer: " << splitBuffer.data() << endl; cout << "currentKey: " << currentKey->getText() << endl; #endif writeEntry(*currentKey, text); #if 1 while (splitPtr) { splitPtr += 1; splitPtr2 = std::strstr(splitPtr, "|"); entryCount++; if (splitPtr2) { std::strncpy (splitBuffer.data(), splitPtr, splitPtr2 - splitPtr); splitBuffer[splitPtr2 - splitPtr] = 0; #ifdef DEBUG cout << "splitBuffer: " << splitBuffer.data() << endl; cout << "currentKey: " << currentKey->getText() << endl; #endif linkToEntry(currentKey->getText(), splitBuffer.data()); splitPtr = splitPtr2; } else { std::strcpy(splitBuffer.data(), splitPtr); #ifdef DEBUG cout << "splitBuffer: " << splitBuffer.data() << endl; cout << "currentKey: " << currentKey->getText() << endl; #endif linkToEntry(currentKey->getText(), splitBuffer.data()); splitPtr = nullptr; } } #endif } else { currentKey->setText(keyStr); writeEntry(*currentKey, text); } // Since we consumed the text, clear it // and tell the caller that the tag was consumed. text = ""; return true; } } return false; }
XMLTag* Save() { XMLTag* tag = new XMLTag(GetName()); tag->AddChild(m_firstAlg->Save()); return tag; }
// Accessor methods // XMLTag* ImageInputSystem::Save() { XMLTag* tag = new XMLTag(XML_NODE_IMAGEINPUTSYSTEM); tag->AddChild(XMLTag::Tag(m_cameras)); return tag; }
char ThMLHeadings::processText(SWBuf &text, const SWKey *key, const SWModule *module) { SWBuf token; bool intoken = false; bool isheader = false; bool hide = false; bool preverse = false; bool withinDiv = false; SWBuf header; int headerNum = 0; int pvHeaderNum = 0; char buf[254]; XMLTag startTag; SWBuf orig = text; const char *from = orig.c_str(); XMLTag tag; for (text = ""; *from; ++from) { if (*from == '<') { intoken = true; token = ""; continue; } if (*from == '>') { // process tokens intoken = false; if (!strnicmp(token.c_str(), "div", 3) || !strnicmp(token.c_str(), "/div", 4)) { withinDiv = (!strnicmp(token.c_str(), "div", 3)); tag = token; if (hide && tag.isEndTag()) { if (module->isProcessEntryAttributes() && (option || (!preverse))) { if (preverse) { sprintf(buf, "%i", pvHeaderNum++); module->getEntryAttributes()["Heading"]["Preverse"][buf] = header; } else { sprintf(buf, "%i", headerNum++); module->getEntryAttributes()["Heading"]["Interverse"][buf] = header; if (option) { // we want the tag in the text text.append(header); } } StringList attributes = startTag.getAttributeNames(); for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) { module->getEntryAttributes()["Heading"][buf][it->c_str()] = startTag.getAttribute(it->c_str()); } } hide = false; if (!option || preverse) { // we don't want the tag in the text anymore preverse = false; continue; } preverse = false; } if (tag.getAttribute("class") && ((!stricmp(tag.getAttribute("class"), "sechead")) || (!stricmp(tag.getAttribute("class"), "title")))) { isheader = true; if (!tag.isEndTag()) { //start tag if (!tag.isEmpty()) { startTag = tag; /* how do we tell a ThML preverse title from one that should be in the text? probably if any text is before the title... just assuming all are preverse for now } if (tag.getAttribute("subtype") && !stricmp(tag.getAttribute("subtype"), "x-preverse")) { */ hide = true; preverse = true; header = ""; continue; } // move back up under startTag = tag } /* this is where non-preverse will go eventually if (!tag.isEndTag()) { //start tag hide = true; header = ""; if (option) { // we want the tag in the text text.append('<'); text.append(token); text.append('>'); } continue; } */ } else isheader = false; } if (withinDiv && isheader) { header.append('<'); header.append(token); header.append('>'); } else { // if not a heading token, keep token in text if (!hide) { text.append('<'); text.append(token); text.append('>'); } } continue; } if (intoken) { //copy token token.append(*from); } else if (!hide) { //copy text which is not inside a token text.append(*from); } else header.append(*from); } return 0; }
void GeometryConfiguration:: addTypeSpecificAttributes ( const std::string& type, utils::XMLTag& tag ) { preciceTrace1("addTypeSpecificAttributes()", type); using utils::XMLTag; using utils::XMLAttribute; using utils::ValidatorEquals; XMLTag tagDiscretizationWidth(*this, TAG_DISCRETIZATION_WIDTH, XMLTag::OCCUR_ONCE); XMLAttribute<double> attrDoubleValue(ATTR_VALUE); tagDiscretizationWidth.addAttribute(attrDoubleValue); if (type == VALUE_BUILTIN_CUBOID){ tag.addSubtag(tagDiscretizationWidth); XMLTag tagLength(*this, TAG_LENGTH, XMLTag::OCCUR_ONCE); XMLAttribute<utils::DynVector> attrValue(ATTR_VALUE); tagLength.addAttribute(attrValue); tag.addSubtag(tagLength); } else if (type == VALUE_BUILTIN_DRATCHET){ tag.addSubtag(tagDiscretizationWidth); XMLTag tagLength (*this, TAG_LENGTH, XMLTag::OCCUR_ONCE); XMLAttribute<double> attrValue(ATTR_VALUE); //ValidatorGreaterThan<double> validValue (0.0); //attrValue.setValidator ( validValue ); tagLength.addAttribute(attrValue); tag.addSubtag(tagLength); XMLTag tagPores(*this, TAG_PORES, XMLTag::OCCUR_ONCE); tagPores.addAttribute(attrValue); tag.addSubtag(tagPores); XMLTag tagRadius(*this, TAG_RADIUS, XMLTag::OCCUR_ONCE); tagRadius.addAttribute(attrValue); tag.addSubtag(tagRadius); } else if (type == VALUE_BUILTIN_SPHERE){ tag.addSubtag(tagDiscretizationWidth); XMLTag tagRadius(*this, TAG_RADIUS, XMLTag::OCCUR_ONCE); XMLAttribute<double> attrValue(ATTR_VALUE); //ValidatorGreaterThan<double> validValue ( 0.0 ); //attrValue.setValidator ( validValue ); tagRadius.addAttribute(attrValue); tag.addSubtag(tagRadius); } else if (type == VALUE_BUILTIN_BUBBLE){ tag.addSubtag(tagDiscretizationWidth); XMLTag tagRadius(*this, TAG_RADIUS, XMLTag::OCCUR_ONCE); XMLAttribute<double> attrValue(ATTR_VALUE); //ValidatorGreaterThan<double> validValue ( 0.0 ); //attrValue.setValidator ( validValue ); tagRadius.addAttribute(attrValue); tag.addSubtag(tagRadius); XMLTag tagDefo(*this, TAG_DEFORMATION, XMLTag::OCCUR_NOT_OR_ONCE); XMLAttribute<double> attrValue2(ATTR_VALUE); //ValidatorGreaterThan<double> validValue2 ( 0.0 ); //attrValue2.setValidator ( validValue2 ); tagDefo.addAttribute(attrValue2); tag.addSubtag(tagDefo); } else if (type == VALUE_IMPORT){ XMLTag tagFilename(*this, TAG_FILENAME, XMLTag::OCCUR_ONCE); XMLAttribute<std::string> attrValue(ATTR_VALUE); tagFilename.addAttribute(attrValue); tag.addSubtag(tagFilename); XMLTag tagFiletype(*this, TAG_FILETYPE, XMLTag::OCCUR_ONCE); ValidatorEquals<std::string> validFiletype("vrml"); attrValue.setValidator(validFiletype); tagFiletype.addAttribute(attrValue); tag.addSubtag(tagFiletype); } else { assertion (false); } }
void SimulationOptions::_setupXMLStructure( Util::XMLParser & xmlOpts ) { XMLTag * root = xmlOpts.createRootTag("SteerSimOptions", "This file contains options for SteerSim. Edit this file to your preference, and\nthen use the '-config' command line option to load these options in SteerSim.\nOptions specified by the command line will override options in this configuration file."); // primary option groups root->createChildTag("keyboard", "Maps various actions to keyboard input (config for keybaord not implemented yet!)"); root->createChildTag("mouse", "Maps various actions to mouse input (config for mouse not implemented yet!)"); XMLTag * guiTag = root->createChildTag("gui", "Options related to the openGL visualization and interaction. Also, make sure to look at the engine driver options for more interface-related options."); XMLTag * globalTag = root->createChildTag("global", "Options related to the main execution of the steersim"); XMLTag * engineTag = root->createChildTag("engine", "Options related to the simulation engine"); XMLTag * gridDatabaseTag = root->createChildTag("gridDatabase", "Options related to the spatial database"); XMLTag * engineDriversTag = root->createChildTag("engineDrivers", "Options related to engine drivers"); root->createChildTag("modules", "Module-specific options. Any options specified on the command-line will override the options specified here. Modules specified here will not necessarily be loaded when started; for that use the startupModules option for the engine.", XML_DATA_TYPE_CONTAINER, NULL, &_moduleOptionsXMLParser ); // option sub-groups engineDriversTag->createChildTag("commandLine", "Options for the command-line engine driver (currently there are no options for the command-line)"); XMLTag * glfwEngineDriverTag = engineDriversTag->createChildTag("glfw", "Options for the GLFW engine driver"); engineDriversTag->createChildTag("qt", "Options for the Qt engine driver (config for qt not implemented yet!)"); // GUI options guiTag->createChildTag("useAntialiasing", "Set to \"true\" to remove jaggies, for smoother-looking visuals, but lower performance", XML_DATA_TYPE_BOOLEAN, &guiOptions.useAntialiasing); guiTag->createChildTag("useShadows", "DO NOT USE THIS VALUE. It is only kept here for backwards compatibility.", XML_DATA_TYPE_BOOLEAN, &_dummyUseShadowsFlag); guiTag->createChildTag("useVsync", "Set to \"false\" for higher performance that is not synchronizeded with the display's refresh rate", XML_DATA_TYPE_BOOLEAN, &guiOptions.useVsync); guiTag->createChildTag("mouseRotationFactor", "Scaling factor for sensitivity of camera rotation when using mouse.", XML_DATA_TYPE_FLOAT, &guiOptions.mouseRotationFactor); guiTag->createChildTag("mouseZoomFactor", "Scaling factor for sensitivity of camera zoom when using mouse", XML_DATA_TYPE_FLOAT, &guiOptions.mouseZoomFactor); guiTag->createChildTag("mouseMovementFactor", "Scaling factor for sensitivity of camera movement when using mouse", XML_DATA_TYPE_FLOAT, &guiOptions.mouseMovementFactor); guiTag->createChildTag("canUseMouseSelection", "Set to \"true\" to be able to select agents with the mouse, \"false\" is recommended when using many many agents, because selection algorithm is brute-force and slow", XML_DATA_TYPE_BOOLEAN, &guiOptions.canUseMouseSelection); guiTag->createChildTag("canUseMouseWheelZoom", "Set to \"true\" to be able to zoom with the mouse wheel; this does not disable other possible ways to zoom the camera.", XML_DATA_TYPE_BOOLEAN, &guiOptions.canUseMouseWheelZoom); guiTag->createChildTag("cameraPosition", "Camera's physical position in the 3-D scene", XML_DATA_TYPE_XYZ, &guiOptions.cameraPosition); guiTag->createChildTag("cameraLookAt", "The 3-D point the camera will look at", XML_DATA_TYPE_XYZ, &guiOptions.cameraLookAt); guiTag->createChildTag("cameraUp", "The vector that represnts the upright orientation for the camera", XML_DATA_TYPE_XYZ, &guiOptions.cameraUp); guiTag->createChildTag("cameraVerticalFieldOfView", "The vertical field of view of the camera, in degrees", XML_DATA_TYPE_FLOAT, &guiOptions.cameraFovy); guiTag->createChildTag("backgroundColor", "The background color of the openGL visualization", XML_DATA_TYPE_RGB, &guiOptions.backgroundColor); guiTag->createChildTag("lineWidth", "width of lines drawn in the GUI", XML_DATA_TYPE_FLOAT, &guiOptions.lineWidth); // global options globalTag->createChildTag("engineDriver", "The name of the engine driver to use, if not specified from command line", XML_DATA_TYPE_STRING, &globalOptions.engineDriver); globalTag->createChildTag("redirectCoutToFile", "If a filename is specified, std::cout will be redirected to that filename. NOTE: Only std::cout will be redirected; low-level and C-style output will not be redirected.", XML_DATA_TYPE_STRING, &globalOptions.coutRedirectionFilename); globalTag->createChildTag("redirectCerrToFile", "If a filename is specified, std::cerr will be redirected to that filename. NOTE: Only std::cerr will be redirected; low-level and C-style output will not be redirected. Exceptions will be caught and redirected to both the new and the original std::cerr output.", XML_DATA_TYPE_STRING, &globalOptions.cerrRedirectionFilename); globalTag->createChildTag("redirectClogToFile", "If a filename is specified, std::clog will be redirected to that filename. NOTE: Only std::clog will be redirected; low-level and C-style output will not be redirected.", XML_DATA_TYPE_STRING, &globalOptions.clogRedirectionFilename); // engine options engineTag->createChildTag("moduleSearchPath","The default directory to search for dynamic plug-in modules at runtime.", XML_DATA_TYPE_STRING, &engineOptions.moduleSearchPath); engineTag->createChildTag("testCaseSearchPath","The default directory to search for test cases at runtime.", XML_DATA_TYPE_STRING, &engineOptions.testCaseSearchPath); engineTag->createChildTag("startupModules", "The list of modules to use on startup. Modules specified by the command line will be merged with this list.", XML_DATA_TYPE_CONTAINER, NULL, &_startupModulesXMLParser); engineTag->createChildTag("numThreads", "The default number of threads to run on the simulation", XML_DATA_TYPE_UNSIGNED_INT, &engineOptions.numThreads); engineTag->createChildTag("numFrames", "The default number of frames to simulate - 0 means run the entire simulation until all agents are disabled.", XML_DATA_TYPE_UNSIGNED_INT, &engineOptions.numFramesToSimulate); engineTag->createChildTag("fixedFPS", "The fixed frames-per-second for the simulation clock. This value is used when simulationClockMode is \"fixed-fast\" or \"fixed-real-time\".", XML_DATA_TYPE_FLOAT, &engineOptions.fixedFPS); engineTag->createChildTag("minVariableDt", "The minimum time-step allowed when the clock is in \"variable-real-time\" mode. If the proposed time-step is smaller, this value will be used instead, effectively limiting the max frame rate.", XML_DATA_TYPE_FLOAT, &engineOptions.minVariableDt); engineTag->createChildTag("maxVariableDt", "The maximum time-step allowed when the clock is in \"variable-real-time\" mode. If the proposed time-step is larger, this value will be used instead, at the expense of breaking synchronization between simulation time and real-time.", XML_DATA_TYPE_FLOAT, &engineOptions.maxVariableDt); engineTag->createChildTag("clockMode", "can be either \"fixed-fast\" (fixed simulation frame rate, running as fast as possible), \"fixed-real-time\" (fixed simulation frame rate, running in real-time), or \"variable-real-time\" (variable simulation frame rate in real-time).", XML_DATA_TYPE_STRING, &engineOptions.clockMode); // grid database options gridDatabaseTag->createChildTag("maxItemsPerGridCell", "Max number of items a grid cell can contain", XML_DATA_TYPE_UNSIGNED_INT, &gridDatabaseOptions.maxItemsPerGridCell); gridDatabaseTag->createChildTag("sizeX", "Total size of the grid along the X axis", XML_DATA_TYPE_FLOAT, &gridDatabaseOptions.gridSizeX); gridDatabaseTag->createChildTag("sizeZ", "Total size of the grid along the Z axis", XML_DATA_TYPE_FLOAT, &gridDatabaseOptions.gridSizeZ); gridDatabaseTag->createChildTag("numCellsX", "Number of cells in the grid along the X axis", XML_DATA_TYPE_UNSIGNED_INT, &gridDatabaseOptions.numGridCellsX); gridDatabaseTag->createChildTag("numCellsZ", "Number of cells in the grid along the Z axis", XML_DATA_TYPE_UNSIGNED_INT, &gridDatabaseOptions.numGridCellsZ); gridDatabaseTag->createChildTag("draw", "Draws the grid if \"true\".", XML_DATA_TYPE_BOOLEAN, &gridDatabaseOptions.drawGrid); // GLFW engine driver options glfwEngineDriverTag->createChildTag("startWithClockPaused", "Starts the clock paused if \"true\".", XML_DATA_TYPE_BOOLEAN, &glfwEngineDriverOptions.pausedOnStart); glfwEngineDriverTag->createChildTag("windowSizeX", "Width of the openGL window in pixels", XML_DATA_TYPE_UNSIGNED_INT, &glfwEngineDriverOptions.windowSizeX); glfwEngineDriverTag->createChildTag("windowSizeY", "Height of the openGL window in pixels", XML_DATA_TYPE_UNSIGNED_INT, &glfwEngineDriverOptions.windowSizeY); glfwEngineDriverTag->createChildTag("windowPositionX", "Position of the openGL window in x", XML_DATA_TYPE_UNSIGNED_INT, &glfwEngineDriverOptions.windowPositionX); glfwEngineDriverTag->createChildTag("windowPositionY", "Position of the openGL window in y", XML_DATA_TYPE_UNSIGNED_INT, &glfwEngineDriverOptions.windowPositionY); glfwEngineDriverTag->createChildTag("windowTitle", "Title of the openGL window", XML_DATA_TYPE_STRING, &glfwEngineDriverOptions.windowTitle); glfwEngineDriverTag->createChildTag("fullscreen", "Uses fullscreen (rather than windowed) mode if \"true\".", XML_DATA_TYPE_BOOLEAN, &glfwEngineDriverOptions.fullscreen); glfwEngineDriverTag->createChildTag("stereoMode", "The stereoscopic mode. Can be one of \"off\", \"side-by-side\", \"top-and-bottom\", or \"quadbuffer\".", XML_DATA_TYPE_STRING, &glfwEngineDriverOptions.stereoMode); }
char OSISScripref::processText(std::string &text, const SWKey *key, const SWModule *module) { (void) key; (void) module; std::string token; bool intoken = false; bool hide = false; std::string tagText; XMLTag startTag; std::string orig = text; const char *from = orig.c_str(); XMLTag tag; for (text = ""; *from; ++from) { if (*from == '<') { intoken = true; token = ""; continue; } if (*from == '>') { // process tokens intoken = false; tag = token.c_str(); if (!std::strncmp(token.c_str(), "note", 4) || !std::strncmp(token.c_str(), "/note", 5)) { if (!tag.isEndTag() && !tag.isEmpty()) { startTag = tag; if (tag.attribute("type") == "crossReference") { hide = true; tagText = ""; if (option) { // we want the tag in the text text.push_back('<'); text.append(token); text.push_back('>'); } continue; } } if (hide && tag.isEndTag()) { hide = false; if (option) { // we want the tag in the text text.append(tagText); // end tag gets added further down } else continue; // don't let the end tag get added to the text } } // if not a heading token, keep token in text if (!hide) { text.push_back('<'); text.append(token); text.push_back('>'); } else { tagText.push_back('<'); tagText.append(token); tagText.push_back('>'); } continue; } if (intoken) { //copy token token.push_back(*from); } else if (!hide) { //copy text which is not inside a token text.push_back(*from); } else tagText.push_back(*from); } return 0; }
char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) { SWBuf token; bool intoken = false; bool hide = false; SWBuf tagText; XMLTag startTag; SWBuf refs = ""; int footnoteNum = 1; char buf[254]; SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey(); VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p); if (!parser) { delete p; parser = new VerseKey(); } *parser = key->getText(); SWBuf orig = text; const char *from = orig.c_str(); XMLTag tag; bool strongsMarkup = false; for (text = ""; *from; ++from) { // remove all newlines temporarily to fix kjv2003 module if ((*from == 10) || (*from == 13)) { if ((text.length()>1) && (text[text.length()-2] != ' ') && (*(from+1) != ' ')) text.append(' '); continue; } if (*from == '<') { intoken = true; token = ""; continue; } if (*from == '>') { // process tokens intoken = false; if (!strncmp(token, "note", 4) || !strncmp(token.c_str(), "/note", 5)) { tag = token; if (!tag.isEndTag()) { if (tag.getAttribute("type") && (!strcmp("x-strongsMarkup", tag.getAttribute("type")) || !strcmp("strongsMarkup", tag.getAttribute("type"))) // deprecated ) { tag.setEmpty(false); // handle bug in KJV2003 module where some note open tags were <note ... /> strongsMarkup = true; } if (!tag.isEmpty()) { // if ((!tag.isEmpty()) || (SWBuf("strongsMarkup") == tag.getAttribute("type"))) { refs = ""; startTag = tag; hide = true; tagText = ""; continue; } } if (hide && tag.isEndTag()) { if (module->isProcessEntryAttributes() && !strongsMarkup) { //don`t parse strongsMarkup to EntryAttributes as Footnote sprintf(buf, "%i", footnoteNum++); StringList attributes = startTag.getAttributeNames(); for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) { module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str()); } module->getEntryAttributes()["Footnote"][buf]["body"] = tagText; startTag.setAttribute("swordFootnote", buf); if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) { if (!refs.length()) refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText(); module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str(); } } hide = false; if (option || (startTag.getAttribute("type") && !strcmp(startTag.getAttribute("type"), "crossReference"))) { // we want the tag in the text; crossReferences are handled by another filter text.append(startTag); // text.append(tagText); // we don't put the body back in because it is retrievable from EntryAttributes["Footnotes"][]["body"]. } else continue; } strongsMarkup = false; } // if not a heading token, keep token in text //if ((!strcmp(tag.getName(), "reference")) && (!tag.isEndTag())) { // SWBuf osisRef = tag.getAttribute("osisRef"); if (!strncmp(token, "reference", 9)) { if (refs.length()) { refs.append("; "); } const char* attr = strstr(token.c_str() + 9, "osisRef=\""); const char* end = attr ? strchr(attr+9, '"') : 0; if (attr && end) { refs.append(attr+9, end-(attr+9)); } } if (!hide) { text.append('<'); text.append(token); text.append('>'); } else { tagText.append('<'); tagText.append(token); tagText.append('>'); } continue; } if (intoken) { //copy token token.append(*from); } else if (!hide) { //copy text which is not inside a token text.append(*from); } else tagText.append(*from); } delete parser; return 0; }
bool XMLTag::ParseTag(StringParser* parser, DTDVerifier* verifier, char* errorBuffer, int errorBufferSize) { while (true) { if (!parser->GetThru(NULL, '<')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize, "Couldn't find a valid tag"); return false; // couldn't find beginning of tag } char c = parser->PeekFast(); if (c == '/') { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize, "End tag with no begin tag on line %d", parser->GetCurrentLineNumber()); return false; // we shouldn't be seeing a close tag here } if ((c != '!') && (c != '?')) break; // this should be the beginning of a regular tag ConsumeIfComment(parser); // otherwise this is a processing instruction or a c-data, so look for the next tag } int tagStartLine = parser->GetCurrentLineNumber(); StrPtrLen temp; parser->ConsumeUntil(&temp, sNonNameMask); if (temp.Len == 0) { if (errorBuffer != NULL) { if (parser->GetDataRemaining() == 0) qtss_snprintf(errorBuffer, errorBufferSize, "Unexpected end of file on line %d", parser->GetCurrentLineNumber()); else qtss_snprintf(errorBuffer, errorBufferSize,"Unexpected character (%c) on line %d", parser->PeekFast(), parser->GetCurrentLineNumber()); } return false; // bad file } fTag = temp.GetAsCString(); parser->ConsumeWhitespace(); while ((parser->PeekFast() != '>') && (parser->PeekFast() != '/')) { // we must have an attribute value for this tag XMLAttribute* attr = new XMLAttribute; fAttributes.EnQueue(&attr->fElem); parser->ConsumeUntil(&temp, sNonNameMask); if (temp.Len == 0) { if (errorBuffer != NULL) { if (parser->GetDataRemaining() == 0) qtss_snprintf(errorBuffer, errorBufferSize, "Unexpected end of file on line %d", parser->GetCurrentLineNumber()); else qtss_snprintf(errorBuffer, errorBufferSize,"Unexpected character (%c) on line %d", parser->PeekFast(), parser->GetCurrentLineNumber()); } return false; // bad file } attr->fAttrName = temp.GetAsCString(); if (!parser->Expect('=')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"Missing '=' after attribute %s on line %d", attr->fAttrName, parser->GetCurrentLineNumber()); return false; // bad attribute specification } if (!parser->Expect('"')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"Attribute %s value not in quotes on line %d", attr->fAttrName, parser->GetCurrentLineNumber()); return false; // bad attribute specification } parser->ConsumeUntil(&temp, '"'); attr->fAttrValue = temp.GetAsCString(); if (!parser->Expect('"')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize, "Attribute %s value not in quotes on line %d", attr->fAttrName, parser->GetCurrentLineNumber()); return false; // bad attribute specification } if (verifier && !verifier->IsValidAttributeName(fTag, attr->fAttrName)) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize, "Attribute %s not allowed in tag %s on line %d", attr->fAttrName, fTag, parser->GetCurrentLineNumber()); return false; // bad attribute specification } if (verifier && !verifier->IsValidAttributeValue(fTag, attr->fAttrName, attr->fAttrValue)) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"Bad value for attribute %s on line %d", attr->fAttrName, parser->GetCurrentLineNumber()); return false; // bad attribute specification } parser->ConsumeWhitespace(); } if (parser->PeekFast() == '/') { // this is an empty element tag, i.e. no contents or end tag (e.g <TAG attr="value" /> parser->Expect('/'); if (!parser->Expect('>')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"'>' must follow '/' on line %d", parser->GetCurrentLineNumber()); return false; // bad attribute specification } return true; // we're done with this tag } if (!parser->Expect('>')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"Bad format for tag <%s> on line %d", fTag, parser->GetCurrentLineNumber()); return false; // bad attribute specification } while(true) { parser->ConsumeUntil(&temp, '<'); // this is either value or whitespace if (parser->GetDataRemaining() < 4) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize, "Reached end of file without end for tag <%s> declared on line %d", fTag, tagStartLine); return false; } if ((*parser)[1] == '/') { // we'll only assign a value if there were no embedded tags if (fEmbeddedTags.GetLength() == 0 && (!verifier || verifier->CanHaveValue(fTag))) fValue = temp.GetAsCString(); else { // otherwise this needs to have been just whitespace StringParser tempParser(&temp); tempParser.ConsumeWhitespace(); if (tempParser.GetDataRemaining() > 0) { if (errorBuffer) { if (fEmbeddedTags.GetLength() > 0) qtss_snprintf(errorBuffer, errorBufferSize,"Unexpected text outside of tag on line %d", tagStartLine); else qtss_snprintf(errorBuffer, errorBufferSize, "Tag <%s> on line %d not allowed to have data", fTag, tagStartLine); } } } break; // we're all done with this tag } if (((*parser)[1] != '!') && ((*parser)[1] != '?')) { // this must be the beginning of an embedded tag XMLTag* tag = NEW XMLTag(); fEmbeddedTags.EnQueue(&tag->fElem); if (!tag->ParseTag(parser, verifier, errorBuffer, errorBufferSize)) return false; if (verifier && !verifier->IsValidSubtag(fTag, tag->GetTagName())) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize, "Tag %s not allowed in tag %s on line %d", tag->GetTagName(), fTag, parser->GetCurrentLineNumber()); return false; // bad attribute specification } } else { parser->ConsumeLength(NULL, 1); // skip '<' ConsumeIfComment(parser); } } parser->ConsumeLength(NULL, 2); // skip '</' parser->ConsumeUntil(&temp, sNonNameMask); if (!temp.Equal(fTag)) { char* newTag = temp.GetAsCString(); if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"End tag </%s> on line %d doesn't match tag <%s> declared on line %d", newTag, parser->GetCurrentLineNumber(),fTag, tagStartLine); delete newTag; return false; // bad attribute specification } if (!parser->GetThru(NULL, '>')) { if (errorBuffer != NULL) qtss_snprintf(errorBuffer, errorBufferSize,"Couldn't find end of tag <%s> declared on line %d", fTag, tagStartLine); return false; // bad attribute specification } return true; }