AttributeVector *getWritableAttribute(const vespalib::string &attrName) const override { if (_attrs.count(attrName) == 0) { return nullptr; } AttrMap::const_iterator itr = _attrMap.find(attrName); return ((itr == _attrMap.end()) ? nullptr : itr->second.get()); }
// Module short cuts --- unsigned GetAttributes(const TCHAR* module, const IAttributeTypeVector & types, IAttributeVector & attributes, bool noRefresh=false, bool noBroadcast=false) const { clib::recursive_mutex::scoped_lock proc(m_mutex); typedef std::pair<std::_tstring, std::_tstring> CommentEclPair; typedef std::map<std::_tstring, CommentEclPair> AttrMap; AttrMap attrs; std::_tstring attributeLabel; std::_tstring attributeComment; std::_tstring attributeEcl; typedef std::vector<std::_tstring> split_vector_type; split_vector_type SplitVec; boost::algorithm::split(SplitVec, m_modFile, boost::algorithm::is_any_of("\r\n"), boost::algorithm::token_compress_on); for (split_vector_type::const_iterator itr = SplitVec.begin(); itr != SplitVec.end(); ++itr) { std::_tstring trimmedLine = *itr; boost::algorithm::trim(trimmedLine); if (boost::algorithm::istarts_with(trimmedLine, IMPORT_MARKER)) { if (attributeLabel.length() && attributeEcl.length()) { attrs[attributeLabel] = CommentEclPair(attributeComment, attributeEcl); } boost::algorithm::ireplace_first(trimmedLine, IMPORT_MARKER, _T("")); attributeLabel = trimmedLine; attributeComment.clear(); attributeEcl.clear(); } else if (boost::algorithm::istarts_with(trimmedLine, COMMENT_MARKER)) { boost::algorithm::ireplace_first(trimmedLine, COMMENT_MARKER, _T("")); attributeComment += trimmedLine + _T("\r\n"); } else { attributeEcl += *itr + _T("\r\n"); } } if (attributeLabel.length() && attributeEcl.length()) { attrs[attributeLabel] = CommentEclPair(attributeComment, attributeEcl); } for(AttrMap::iterator itr = attrs.begin(); itr != attrs.end(); ++itr) { int curPos = 0; CModuleHelper moduleHelper(itr->first); if (boost::algorithm::iequals(moduleHelper.GetModuleLabel(), module)) { StlLinked<IAttribute> attribute = CreateModFileAttribute(this, module, moduleHelper.GetAttributeLabel(), itr->second.second); attributes.push_back(attribute); } } std::sort(attributes.begin(), attributes.end(), IAttributeCompare()); return attributes.size(); }
bool Ckeyb::exit(void) { #ifdef EMSCRIPTEN return true; #endif if (! modified) return true; int ret = QMessageBox::warning(mainwindow, QObject::tr("PockEmul"), QObject::tr("The keyboard layout has been modified.\n" "Do you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save); if (ret == QMessageBox::Discard) return true; // save the XML definition file QFile file(fn_KeyMap); file.open( QIODevice::WriteOnly); XmlWriter xw( &file ); xw.setAutoNewLine( true ); xw.writeRaw( "<!DOCTYPE KEYBMAP><KEYBMAP version=\"1.0\">" ); xw.newLine(); xw.writeTaggedString( "model", QString(pPC->getcfgfname()) ); xw.writeOpenTag( "Keyboard" ); QList<CKey>::iterator j; for (j = Keys.begin(); j != Keys.end(); ++j) { AttrMap attrs; attrs.insert( "description", j->Description.trimmed () ); attrs.insert( "scancode", QString("0x%1").arg(j->ScanCode,2,16,QChar('0')) ); attrs.insert( "masterscancode", QString("0x%1").arg(j->MasterScanCode,2,16,QChar('0')) ); attrs.insert( "left", QString("%1").arg(j->Rect.left()) ); attrs.insert( "top", QString("%1").arg(j->Rect.top() )); attrs.insert( "width", QString("%1").arg(j->Rect.width() ) ); attrs.insert( "height", QString("%1").arg(j->Rect.height() ) ); attrs.insert( "modifier", j->Modifier ); xw.writeAtomTag( "KEY", attrs ); } xw.writeCloseTag( "Keyboard" ); xw.writeRaw( "</KEYBMAP>" ); return true; }
void gatherAttrs(void * item, AttrMap & attrs) { attrs.clear(); for (Agsym_t *attr = agfstattr(item); attr; attr = agnxtattr(item, attr)) { if (strcmp(attr->name, "id") != 0 && agxget(item, attr->index) != NULL && strcmp(agxget(item, attr->index), "\\N") != 0) attrs[attr->name] = agxget(item, attr->index); } }
void walkGraph(graph_t * g, IGraphvizVisitor * visitor, int depth) { if (!g) return; AttrMap attrs; gatherAttrs(g, attrs); depth == 0 ? visitor->OnStartGraph(g->kind, g->name, attrs) : visitor->OnStartCluster(g->name, attrs); graph_t *mg, *subg; node_t *mm, *mn; edge_t *me; mm = g->meta_node; mg = mm->graph; for (me = agfstout(mg, mm); me; me = agnxtout(mg, me)) { mn = me->head; subg = agusergraph(mn); walkGraph(subg, visitor, depth + 1); } for (Agnode_t *v = agfstnode(g); v; v = agnxtnode(g,v)) { gatherAttrs(v, attrs); if (attrs.find("label") == attrs.end()) attrs["label"] = v->name; visitor->OnStartVertex(v->id, attrs); for (Agedge_t *e = agfstout(g, v); e; e = agnxtout(g, e)) { gatherAttrs(e, attrs); visitor->OnStartEdge(g->kind, e->id, e->tail->id, e->head->id, attrs); visitor->OnEndEdge(g->kind, e->id); } visitor->OnEndVertex(v->id); } depth == 0 ? visitor->OnEndGraph(g->kind, g->name) : visitor->OnEndCluster(g->name); }
xmlwriterblock::xmlwriterblock(QFile* file , Patient* blockpatient) { XmlWriter xw (file); xw.setAutoNewLine( true ); const QString index = blockpatient->index; const QString prenom = blockpatient->prenom; const QString nomjeunefille = blockpatient->nomdejeunefille; const QString nom = blockpatient->nom; const QString datedenaissance = blockpatient->datedenaissance; const QString datededeces= blockpatient->datededeces; const QString adresse = blockpatient->adresse; const QString ville = blockpatient->ville; const QString region = blockpatient->region; const QString codepostal = blockpatient->codepostal; const QString pays = blockpatient->pays; const QString telephone1 = blockpatient->telephone1; const QString telephone2 = blockpatient->telephone2; const QString telephone3 = blockpatient->telephone3; const QString courriel = blockpatient->courriel; const QString telecopie = blockpatient->telecopie; const QString textelibre = blockpatient->textelibre; const QString marque = blockpatient->marque; const QString codeinternat = blockpatient->codeinternat; const QString datededebut = blockpatient->datededebut; const QString datedefin = blockpatient->datedefin; const QString formatage = blockpatient->formatage; const QString indexdeconfiance = blockpatient->indexdeconfiance; xw.newLine(); xw.writeRaw("<!-- Patient block -->"); xw.newLine(); AttrMap attrPatient; attrPatient.insert( "emrUid", index); attrPatient.insert( "firstname" , prenom); attrPatient.insert( "birthname" , nom); attrPatient.insert( "secondname", nomjeunefille); attrPatient.insert( "dob", datedenaissance); attrPatient.insert( "dod", datededeces); xw.writeOpenTag("Patient", attrPatient); xw.writeRaw("<!-- Contact -->"); xw.newLine(); AttrMap attrAdress; attrAdress.insert( "ad", adresse); attrAdress.insert( "city", ville); attrAdress.insert( "county", region); attrAdress.insert( "zip" , codepostal); attrAdress.insert( "state" , pays); xw.writeOpenTag( "Address", attrAdress); AttrMap attrContact; attrContact.insert( "tel1", telephone1); attrContact.insert( "tel2", telephone2); attrContact.insert( "tel3" , telephone3); attrContact.insert( "fax" , telecopie); attrContact.insert("mail" , courriel); xw.writeOpenTag( "Contact", attrContact); xw.writeRaw( "<!-- PMHx -->"); xw.newLine(); xw.writeOpenTag("PMHx"); xw.writeOpenTag("PMH_Item"); xw.writeRaw("<!-- use FreeText or Encoded not both -->"); xw.newLine(); xw.writeTaggedString( "FreeText", textelibre, AttrMap() ); AttrMap attrEncoded; attrEncoded.insert("label", marque); attrEncoded.insert( "icd10" , codeinternat); xw.writeOpenTag( "Encoded" , attrEncoded); xw.writeTaggedString( "DateStart", datededebut, AttrMap("format", formatage) ); xw.writeTaggedString( "DateEnd", datedefin, AttrMap("format", formatage) ); xw.writeTaggedString( "ConfidenceIndex", indexdeconfiance, AttrMap() ); xw.writeCloseTag("PMH_Item"); xw.writeCloseTag("PMHx"); xw.writeRaw("<!-- Populate Form items -->"); xw.newLine(); xw.writeCloseTag("Patient"); xw.newLine(); }
void MegaFuseApp::transfer_complete(int td, handle ulhandle, const byte* ultoken, const byte* filekey, SymmCipher* key) { auto it = model->cacheManager.findByTransfer(td,file_cache_row::UPLOADING ); if(it == model->cacheManager.end()) { client->tclose(td); return; } printf("\033[2KUpload Complete\n"); auto sPath = model->splitPath(it->first); Node *target = model->nodeByPath(sPath.first); if(!target) { printf("\033[2KUpload target folder inaccessible, using /\n"); target = client->nodebyhandle(client->rootnodes[0]); } /*if (!putf->targetuser.size() && !client->nodebyhandle(putf->target)) { printf("Upload target folder inaccessible, using /\n"); putf->target = client->rootnodes[0]; }*/ NewNode* newnode = new NewNode[1]; // build new node newnode->source = NEW_UPLOAD; // upload handle required to retrieve/include pending file attributes newnode->uploadhandle = ulhandle; // reference to uploaded file memcpy(newnode->uploadtoken,ultoken,sizeof newnode->uploadtoken); // file's crypto key newnode->nodekey.assign((char*)filekey,Node::FILENODEKEYLENGTH); newnode->mtime = newnode->ctime = time(NULL); newnode->type = FILENODE; newnode->parenthandle = UNDEF; AttrMap attrs; MegaClient::unescapefilename(&sPath.second); attrs.map['n'] = sPath.second; std::string localname = it->second.localname; attrs.getjson(&localname); client->makeattr(key,&newnode->attrstring,localname.c_str()); /*if (putf->targetuser.size()) { cout << "Attempting to drop file into user " << putf->targetuser << "'s inbox..." << endl; client->putnodes(putf->targetuser.c_str(),newnode,1); } else*/ client->putnodes(target->nodehandle,newnode,1); printf("\033[2Kulhandle %llu, nodehandle %llu\n", ulhandle, newnode->nodehandle); it->second.td = -1; it->second.modified = false; client->tclose(td); model->eh.notifyEvent(EventsHandler::UPLOAD_COMPLETE,1); }
void TreeLoodsmanModel::fetchMoreAttr(const QModelIndex &parent) { TreeItem *item; if(parent.isValid()){ item = getItem(parent); if(!item) return; } long objId = item->id; if (m_attrVal.contains(objId)) return; LoodsmanSystem* loodsman = LoodsmanSystem::instance(); VARIANT inErrorCode; VARIANT stErrorMessage; /* ЗАГРУЖАЕТ ВСЕ АТРИБУТЫ ВЫБРАННОГО ТИПА БЕЗ ЗНАЧЕНИЙ */ AttrMap attrMap; long typeId = data(parent.sibling(parent.row(),fieldIndex("_ID_TYPE"))).toInt(); if (typeId >0){ QList<long> listIdAttr = m_typeModel->listAttr(typeId); for (int i=0;i<listIdAttr.count();i++){ long idAttr = listIdAttr.value(i); QList<QVariant> listData; listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_NAME"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_ID"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_ATTRTYPE"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_DEFAULT"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_LIST"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_ACCESSLEVEL"))); // isAttrLink listData.append(false); attrMap.insert(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_NAME")).toString(), listData); } } long parentTypeId = data(parent.parent().sibling(parent.parent().row(),fieldIndex("_ID_TYPE"))).toInt(); long linkId = data(parent.sibling(parent.row(),fieldIndex("_ID_LINKTYPE"))).toInt(); if (typeId >0 && parentTypeId>0 && linkId>0){ QString objLink = m_linkModel->data(linkId,m_linkModel->fieldIndex("_NAME")).toString(); QList<long> listIdAttr = m_typeModel->listAttrLink(typeId,parentTypeId,objLink); for (int i=0;i<listIdAttr.count();i++){ long idAttr = listIdAttr.value(i); QList<QVariant> listData; listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_NAME"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_ID"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_ATTRTYPE"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_DEFAULT"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_LIST"))); listData.append(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_ACCESSLEVEL"))); // isAttrLink listData.append(true); attrMap.insert(m_attrModel->data(idAttr,m_attrModel->fieldIndex("_NAME")).toString(), listData); } } /* ЗАГРУЖАЕТ ЗНАЧЕНИЕ АТРИБУТОВ 0 - строковое значение; 1 - целочисленное значение; 2 - действительное число; 3 - дата и время; 5 - текст; 6 - изображение); 0 - BSTR 1 - int 2 - double 3 - DateTime 5 - массив байт (Значение представляет собой одномерный вариантный массив (тип VT_UI1 (VC++), varByte(Delphi))) 6 - массив байт (Значение представляет собой одномерный вариантный массив (тип VT_UI1 (VC++), varByte(Delphi))) */ long objLinkId = data(parent.sibling(parent.row(),fieldIndex("_ID_LINK"))).toInt(); _variant_t testData = loodsman->main->GetAttributesValues2( to_bstr_t(QString("%1").arg(objId)), "",&inErrorCode, &stErrorMessage); unsigned char *p = (unsigned char *)testData.parray->pvData; MidasData* mData = new MidasData(); mData->setData(p); if (mData->first()){ do{ QString name = mData->fieldValue("_NAME").toString(); QList<QVariant> listData = attrMap.value(name); QStringList list; QDateTime dt; switch (listData.at(2).toInt()) { case 0: listData.append(mData->fieldValue("_VALUE").toString()); break; case 1: listData.append(mData->fieldValue("_VALUE").toInt()); break; case 2: listData.append(mData->fieldValue("_VALUE").toDouble()); break; case 3: list = mData->fieldValue("_VALUE").toString().split(QRegExp("\\s+")); if (list.count()>0) dt.setDate(QDate::fromString(list.at(0),"dd.MM.yyyy")); if (list.count()>1) dt.setTime(QTime::fromString(list.at(1),"HH:mm")); listData.append(dt); break; default: listData.append(mData->fieldValue("_VALUE")); } listData.append(mData->fieldValue("_ID_UNIT")); listData.append(mData->fieldValue("_UNIT")); attrMap[name] = listData; }while (mData->next()); } if (objLinkId > 0) { testData = loodsman->main->GetLinkAttributes( objLinkId, &inErrorCode, &stErrorMessage); p = (unsigned char *)testData.parray->pvData; mData->clear(); mData->setData(p); if (mData->first()){ do{ QString name = mData->fieldValue("_NAME").toString(); QList<QVariant> listData = attrMap.value(name); QStringList list; QDateTime dt; switch (listData.at(2).toInt()) { case 0: listData.append(mData->fieldValue("_VALUE").toString()); break; case 1: listData.append(mData->fieldValue("_VALUE").toInt()); break; case 2: listData.append(mData->fieldValue("_VALUE").toDouble()); break; case 3: list = mData->fieldValue("_VALUE").toString().split(QRegExp("\\s+")); if (list.count()>0) dt.setDate(QDate::fromString(list.at(0),"dd.MM.yyyy")); if (list.count()>1) dt.setTime(QTime::fromString(list.at(1),"HH:mm")); listData.append(dt); break; default: listData.append(mData->fieldValue("_VALUE")); } listData.append(mData->fieldValue("_ID_UNIT")); listData.append(mData->fieldValue("_UNIT")); attrMap[name] = listData; }while (mData->next()); } } m_attrVal.insert(objId,attrMap); }
void applyCtlExrToExr (Imf::Header inHeader, Imf::Header &outHeader, const Imf::Array2D<Imf::Rgba> &inPixels, Imf::Array2D<Imf::Rgba> &outPixels, int w, int h, const std::vector<std::string> &transformNames, const AttrMap &extraAttrs) { // // Make sure that the input and output headers contain // chromaticities and adoptedNeutral attributes. // if (!hasChromaticities (inHeader)) addChromaticities (inHeader, Chromaticities()); if (!hasAdoptedNeutral (inHeader)) addAdoptedNeutral (inHeader, chromaticities(inHeader).white); if (!hasChromaticities (outHeader)) addChromaticities (outHeader, chromaticities (inHeader)); if (!hasAdoptedNeutral (outHeader)) addAdoptedNeutral (outHeader, adoptedNeutral (inHeader)); // // Add extraAttrs to the input header, possibly overriding // the values of existing input header attributes. // for (AttrMap::const_iterator i = extraAttrs.begin(); i != extraAttrs.end(); ++i) { inHeader.insert (i->first.c_str(), *i->second); } // // Initialize an "environment" header with the same data that // would be available to rendering transforms in an image viewing // program. This allows transforms to bake color rendering into // the output file's pixels. // Header envHeader; initializeEnvHeader (envHeader); // // Set up input and output FrameBuffer objects for the transforms. // FrameBuffer inFb; initializeFrameBuffer (w, h, inPixels, inFb); FrameBuffer outFb; initializeFrameBuffer (w, h, outPixels, outFb); // // Run the CTL transforms // Box2i transformWindow (V2i (0, 0), V2i (w - 1, h - 1)); SimdInterpreter interpreter; #ifdef CTL_MODULE_BASE_PATH // // The configuration script has defined a default // location for CTL modules. Include this location // in the CTL module search path. // vector<string> paths = interpreter.modulePaths(); paths.push_back (CTL_MODULE_BASE_PATH); interpreter.setModulePaths (paths); #endif ImfCtl::applyTransforms (interpreter, transformNames, transformWindow, envHeader, inHeader, inFb, outHeader, outFb); }
void File::completed(Transfer* t, LocalNode* l) { if (t->type == PUT) { NewNode* newnode = new NewNode[1]; // build new node newnode->source = NEW_UPLOAD; // upload handle required to retrieve/include pending file attributes newnode->uploadhandle = t->uploadhandle; // reference to uploaded file memcpy(newnode->uploadtoken, t->ultoken, sizeof newnode->uploadtoken); // file's crypto key newnode->nodekey.assign((char*)t->filekey, FILENODEKEYLENGTH); newnode->type = FILENODE; newnode->parenthandle = UNDEF; #ifdef ENABLE_SYNC if ((newnode->localnode = l)) { l->newnode = newnode; newnode->syncid = l->syncid; } #endif AttrMap attrs; // store filename attrs.map['n'] = name; // store fingerprint t->serializefingerprint(&attrs.map['c']); string tattrstring; attrs.getjson(&tattrstring); newnode->attrstring = new string; t->client->makeattr(&t->key, newnode->attrstring, tattrstring.c_str()); if (targetuser.size()) { // drop file into targetuser's inbox int creqtag = t->client->reqtag; t->client->reqtag = t->tag; t->client->putnodes(targetuser.c_str(), newnode, 1); t->client->reqtag = creqtag; } else { handle th = h; // inaccessible target folder - use / instead if (!t->client->nodebyhandle(th)) { th = t->client->rootnodes[0]; } #ifdef ENABLE_SYNC if (l) { t->client->syncadding++; } #endif t->client->reqs[t->client->r].add(new CommandPutNodes(t->client, th, NULL, newnode, 1, t->tag, #ifdef ENABLE_SYNC l ? PUTNODES_SYNC : PUTNODES_APP)); #else PUTNODES_APP)); #endif } }
bool ofxXivelyOutput::parseResponseEeml(string _response) { if (bVerbose) printf("[Xively] start parsing eeml\n"); try { pData.clear(); DOMParser parser; AttrMap* pMap; AutoPtr<Document> pDoc = parser.parseMemory(_response.c_str(), _response.length()); NodeIterator itElem(pDoc, NodeFilter::SHOW_ELEMENT); Node* pNode = itElem.nextNode(); while (pNode) { if (pNode->nodeName() == XMLString("environment")) { pMap = (AttrMap*) pNode->attributes(); sUpdated = pMap->getNamedItem("updated")->nodeValue(); } if (pNode->nodeName() == XMLString("title")) sTitle = pNode->firstChild()->getNodeValue(); if (pNode->nodeName() == XMLString("status")) sStatus = pNode->firstChild()->getNodeValue(); if (pNode->nodeName() == XMLString("description")) sDescription = pNode->firstChild()->getNodeValue(); if (pNode->nodeName() == XMLString("website")) sWebsite = pNode->firstChild()->getNodeValue(); if (pNode->nodeName() == XMLString("location")) { // pMap = (AttrMap*)pNode->attributes(); // location.sDomain = pMap->getNamedItem("domain")->nodeValue(); // location.sExposure = pMap->getNamedItem("exposure")->nodeValue(); // location.sDisposition = pMap->getNamedItem("disposition")->nodeValue(); NodeIterator itChildren(pNode, NodeFilter::SHOW_ELEMENT); Node* pChild = itChildren.nextNode(); while (pChild) { if (pChild->nodeName() == XMLString("name")) location.sName = pChild->firstChild()->nodeValue(); if (pChild->nodeName() == XMLString("lat")) location.sLat = pChild->firstChild()->nodeValue(); if (pChild->nodeName() == XMLString("lon")) location.sLon = pChild->firstChild()->nodeValue(); pChild = itChildren.nextNode(); } } if (pNode->nodeName() == XMLString("data")) { ofxXivelyData data; pMap = (AttrMap*) pNode->attributes(); data.iId = atoi(pMap->getNamedItem("id")->nodeValue().c_str()); NodeIterator itChildren(pNode, NodeFilter::SHOW_ELEMENT); Node* pChild = itChildren.nextNode(); while (pChild) { if (pChild->nodeName() == XMLString("tag")) data.pTags.push_back(pChild->firstChild()->getNodeValue()); if (pChild->nodeName() == XMLString("value")) { data.fValue = atof(pChild->firstChild()->getNodeValue().c_str()); pMap = (AttrMap*) pChild->attributes(); data.fValueMin = atof(pMap->getNamedItem("minValue")->nodeValue().c_str()); data.fValueMax = atof(pMap->getNamedItem("maxValue")->nodeValue().c_str()); } pChild = itChildren.nextNode(); } pData.push_back(data); } pNode = itElem.nextNode(); } } catch (Exception& exc) { printf("[Xively] Parse xml exception: %s\n", exc.displayText().c_str()); return false; } if (bVerbose) printf("[Xively] finished parsing eeml\n"); return true; }