void onobserve() { oicappData *ad = g_oicObserveAd; AttributeMap attributeMap = g_curAttributeMap; std::string tmpStr[2]; int index = 0; for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it) { tmpStr[index] = it->first; tmpStr[index].append(" : "); for(auto value = it->second.begin() ; value != it->second.end() ; ++value) { tmpStr[index].append(*value); } index++; } DBG("%s" , tmpStr[0].c_str()); DBG("%s" , tmpStr[1].c_str()); _gl_update_item(ad , strdup(tmpStr[0].c_str()) , ad->itemConsumerTemp); _gl_update_item(ad , strdup(tmpStr[1].c_str()) , ad->itemConsumerHumid); }
void PubSubEventSubscriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == 0) { if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { getPayloadInternal()->setNode(*attributeValue); } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) { if (boost::optional<JID> jid = JID::parse(*attributeValue)) { getPayloadInternal()->setJID(*jid); } } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subscription")) { if (boost::optional<PubSubEventSubscription::SubscriptionType> value = EnumParser<PubSubEventSubscription::SubscriptionType>()(PubSubEventSubscription::None, "none")(PubSubEventSubscription::Pending, "pending")(PubSubEventSubscription::Subscribed, "subscribed")(PubSubEventSubscription::Unconfigured, "unconfigured").parse(*attributeValue)) { getPayloadInternal()->setSubscription(*value); } } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subid")) { getPayloadInternal()->setSubscriptionID(*attributeValue); } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("expiry")) { getPayloadInternal()->setExpiry(stringToDateTime(*attributeValue)); } } if (level >= 1 && currentPayloadParser) { currentPayloadParser->handleStartElement(element, ns, attributes); } ++level; }
void MAMQueryParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level_ == TopLevel) { boost::optional<std::string> attributeValue; if ((attributeValue = attributes.getAttributeValue("queryid"))) { getPayloadInternal()->setQueryID(*attributeValue); } if ((attributeValue = attributes.getAttributeValue("node"))) { getPayloadInternal()->setNode(*attributeValue); } } else if (level_ == PayloadLevel) { if (element == "x" && ns == "jabber:x:data") { formParser_ = boost::make_shared<FormParser>(); } else if (element == "set" && ns == "http://jabber.org/protocol/rsm") { resultSetParser_ = boost::make_shared<ResultSetParser>(); } } if (formParser_) { /* parsing a nested Form */ formParser_->handleStartElement(element, ns, attributes); } if (resultSetParser_) { /* parsing a nested ResultSet */ resultSetParser_->handleStartElement(element, ns, attributes); } ++level_; }
void MUCUserPayloadParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level == ItemLevel) { if (element == "item") { MUCUserPayload::Item item; std::string affiliation = attributes.getAttribute("affiliation"); std::string role = attributes.getAttribute("role"); std::string nick = attributes.getAttribute("nick"); std::string jid = attributes.getAttribute("jid"); item.affiliation = parseAffiliation(affiliation); item.role = parseRole(role); if (!jid.empty()) { item.realJID = JID(jid); } if (!nick.empty()) { item.nick = nick; } getPayloadInternal()->addItem(item); } else if (element == "status") { MUCUserPayload::StatusCode status; try { status.code = boost::lexical_cast<int>(attributes.getAttribute("code").c_str()); getPayloadInternal()->addStatusCode(status); } catch (boost::bad_lexical_cast&) { } } } ++level; }
void PubSubItemsParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == 0) { if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { getPayloadInternal()->setNode(*attributeValue); } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("max_items")) { try { getPayloadInternal()->setMaximumItems(boost::lexical_cast<unsigned int>(*attributeValue)); } catch (boost::bad_lexical_cast&) { } } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subid")) { getPayloadInternal()->setSubscriptionID(*attributeValue); } } if (level == 1) { if (element == "item" && ns == "http://jabber.org/protocol/pubsub") { currentPayloadParser = boost::make_shared<PubSubItemParser>(parsers); } } if (level >= 1 && currentPayloadParser) { currentPayloadParser->handleStartElement(element, ns, attributes); } ++level; }
void XMPPParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (!parseErrorOccurred_) { if (level_ == TopLevel) { if (element == "stream" && ns == "http://etherx.jabber.org/streams") { ProtocolHeader header; header.setFrom(attributes.getAttribute("from")); header.setTo(attributes.getAttribute("to")); header.setID(attributes.getAttribute("id")); header.setVersion(attributes.getAttribute("version")); client_->handleStreamStart(header); } else { parseErrorOccurred_ = true; } } else { if (level_ == StreamLevel) { assert(!currentElementParser_); currentElementParser_ = createElementParser(element, ns); } currentElementParser_->handleStartElement(element, ns, attributes); } } ++level_; }
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Feature featureId, const AttributeMap &map, const std::string &attributeName) { StyleSheetTable::AttributeMap::const_iterator it = map.find(attributeName); if (it != map.end()) { ::trySetLength(entry, featureId, it->second); return; } }
bool TemplateBuilder::hasAttribute( const AttributeMap& attributes, const std::string& name) { return attributes.find(name) != attributes.end(); }
void PubSubSubscriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == 0) { if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { getPayloadInternal()->setNode(*attributeValue); } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subid")) { getPayloadInternal()->setSubscriptionID(*attributeValue); } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) { if (boost::optional<JID> jid = JID::parse(*attributeValue)) { getPayloadInternal()->setJID(*jid); } } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subscription")) { if (boost::optional<PubSubSubscription::SubscriptionType> value = EnumParser<PubSubSubscription::SubscriptionType>()(PubSubSubscription::None, "none")(PubSubSubscription::Pending, "pending")(PubSubSubscription::Subscribed, "subscribed")(PubSubSubscription::Unconfigured, "unconfigured").parse(*attributeValue)) { getPayloadInternal()->setSubscription(*value); } } } if (level == 1) { if (element == "subscribe-options" && ns == "http://jabber.org/protocol/pubsub") { currentPayloadParser = boost::make_shared<PubSubSubscribeOptionsParser>(parsers); } } if (level >= 1 && currentPayloadParser) { currentPayloadParser->handleStartElement(element, ns, attributes); } ++level; }
void PubSubOptionsParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == 0) { if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("node")) { getPayloadInternal()->setNode(*attributeValue); } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("jid")) { if (boost::optional<JID> jid = JID::parse(*attributeValue)) { getPayloadInternal()->setJID(*jid); } } if (boost::optional<std::string> attributeValue = attributes.getAttributeValue("subid")) { getPayloadInternal()->setSubscriptionID(*attributeValue); } } if (level == 1) { if (element == "x" && ns == "jabber:x:data") { currentPayloadParser = boost::make_shared<FormParser>(); } } if (level >= 1 && currentPayloadParser) { currentPayloadParser->handleStartElement(element, ns, attributes); } ++level; }
void StanzaParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (inStanza()) { if (!inPayload()) { assert(!currentPayloadParser_); PayloadParserFactory* payloadParserFactory = factories_->getPayloadParserFactory(element, ns, attributes); if (payloadParserFactory) { currentPayloadParser_.reset(payloadParserFactory->createPayloadParser()); } else { currentPayloadParser_.reset(new UnknownPayloadParser()); } } assert(currentPayloadParser_); currentPayloadParser_->handleStartElement(element, ns, attributes); } else { boost::optional<std::string> from = attributes.getAttributeValue("from"); if (from) { getStanza()->setFrom(JID(*from)); } boost::optional<std::string> to = attributes.getAttributeValue("to"); if (to) { getStanza()->setTo(JID(*to)); } boost::optional<std::string> id = attributes.getAttributeValue("id"); if (id) { getStanza()->setID(*id); } handleStanzaAttributes(attributes); } ++currentDepth_; }
void PartHandler::startElement(const QName& qname, const AttributeMap& attributes) { _result.reset(new Part()); _measureIndex = 0; auto id = attributes.find(kIdTag); if (id != attributes.end()) _result->setId(id->second); }
void testGetAttribute_Namespaced() { AttributeMap testling; testling.addAttribute("lang", "", "nl"); testling.addAttribute("lang", "http://www.w3.org/XML/1998/namespace", "en"); testling.addAttribute("lang", "", "fr"); CPPUNIT_ASSERT_EQUAL(std::string("en"), testling.getAttribute("lang", "http://www.w3.org/XML/1998/namespace")); }
void JingleIBBTransportMethodPayloadParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) { try { getPayloadInternal()->setBlockSize(boost::lexical_cast<int>(attributes.getAttributeValue("block-size").get_value_or("0"))); } catch (boost::bad_lexical_cast &) { getPayloadInternal()->setBlockSize(0); } getPayloadInternal()->setSessionID(attributes.getAttributeValue("sid").get_value_or("")); ++level; }
int ArchiveMan::archivePos( int archDocId, KraftDoc *doc ) { /* mysql> describe archdocpos; +-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+----------------+ | archPosID | int(11) | NO | PRI | NULL | auto_increment | | archDocID | int(11) | NO | MUL | | | | ordNumber | int(11) | NO | | | | | text | text | YES | | NULL | | | amount | decimal(6,2) | YES | | NULL | | | unit | varchar(64) | YES | | NULL | | | price | decimal(6,2) | YES | | NULL | | | vat | decimal(3,1) | YES | | 0.0 | | +-----------+--------------+------+-----+---------+----------------+ */ if( ! doc ) return -1; QSqlTableModel model; model.setTable("archdocpos"); QSqlRecord record = model.record(); int cnt = 0; DocPositionList posList = doc->positions(); DocPositionListIterator it( posList ); kDebug() << "Archiving pos for " << archDocId << endl; while ( it.hasNext() ) { DocPosition *dp = static_cast<DocPosition*>( it.next() ); record.setValue( "archDocID", archDocId ); record.setValue( "ordNumber", 1+cnt /* dp->position() */ ); record.setValue( "kind", dp->attribute( DocPosition::Kind ) ); record.setValue( "text", dp->text() ); // expandItemText( dp ) ); record.setValue( "amount", dp->amount() ); record.setValue( "unit", dp->unit().einheit( dp->amount() ) ); record.setValue( "price", dp->unitPrice().toDouble() ); record.setValue( "overallPrice", dp->overallPrice().toDouble() ); record.setValue( "taxType", dp->taxTypeNumeric() ); if(!model.insertRecord(-1, record)) { kDebug() << model.lastError(); } dbID id = KraftDB::self()->getLastInsertID(); // kDebug() << "Inserted for id " << id.toString() << endl; cnt++; // save the attributes of the positions in the attributes // table but with a new host type which reflects the arch state AttributeMap attribs = dp->attributes(); attribs.setHost( "ArchPosition" ); attribs.save( id ); } return cnt; }
void CollectionScanner::scanFiles( const QStringList& entries ) { DEBUG_BLOCK typedef QPair<QString, QString> CoverBundle; QStringList validImages; validImages << "jpg" << "png" << "gif" << "jpeg"; QStringList validPlaylists; validPlaylists << "m3u" << "pls"; QValueList<CoverBundle> covers; QStringList images; foreachType( QStringList, entries ) { const QString path = *it; const QString ext = extension( path ); const QString dir = directory( path ); // Write path to logfile if( !m_logfile.isEmpty() ) { QFile log( m_logfile ); if( log.open( IO_WriteOnly ) ) log.writeBlock( path.local8Bit(), path.length() ); } if( validImages.contains( ext ) ) images += path; else if( m_importPlaylists && validPlaylists.contains( ext ) ) { AttributeMap attributes; attributes["path"] = path; writeElement( "playlist", attributes ); } else { MetaBundle::EmbeddedImageList images; MetaBundle mb( KURL::fromPathOrURL( path ), true, TagLib::AudioProperties::Fast, &images ); const AttributeMap attributes = readTags( mb ); if( !attributes.empty() ) { writeElement( "tags", attributes ); CoverBundle cover( attributes["artist"], attributes["album"] ); if( !covers.contains( cover ) ) covers += cover; foreachType( MetaBundle::EmbeddedImageList, images ) { AttributeMap attributes; attributes["path"] = path; attributes["hash"] = (*it).hash(); attributes["description"] = (*it).description(); writeElement( "embed", attributes ); } } }
void DeliveryReceiptParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributeMap) { if (level_ == 0) { if (element == "received") { if (attributeMap.getAttributeValue("id").is_initialized()) { getPayloadInternal()->setReceivedID(attributeMap.getAttributeValue("id").get()); } } } ++level_; }
// This sets the various recording data to the values they should have // before reading in some text. inline void RestrictedXmlParser::ResetContent() { fileProlog.assign( "" ); rootName.assign( "" ); rootAttributes.clear(); currentName.assign( "" ); currentAttributes.clear(); currentBody.assign( "" ); currentElementIsEmpty = true; }
void KeyHandler::startElement(const QName& qname, const AttributeMap& attributes) { _result.reset(new Key()); auto number = attributes.find(kNumberAttribute); if (number != attributes.end()) _result->setNumber(lxml::IntegerHandler::parseInteger(number->second)); auto print = attributes.find(kPrintObjectAttribute); if (print != attributes.end()) _result->setPrintObject(print->second == "no" ? false : true); }
void JingleFileTransferFileInfoParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { charData.clear(); if (element == "hash") { hashAlg = attributes.getAttributeValue("algo").get_value_or(""); } else if (element == "range") { rangeOffset = safeLexicalCast<boost::uintmax_t>(attributes.getAttributeValue("offset").get_value_or("")); } ++level; }
void MordentHandler::startElement(const lxml::QName& qname, const AttributeMap& attributes) { _result.reset(new Mordent()); auto placement = attributes.find(kPlacementAttribute); if (placement != attributes.end()) _result->setPlacement(presentOptional(EmptyPlacementHandler::placementFromString(placement->second))); auto longv = attributes.find(kLongAttribute); if (longv != attributes.end()) _result->setLong(longv->second == "yes"); }
void printAttributeMap(const AttributeMap attributeMap) { for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it) { DBG("\tAttribute name: %s" , it->first.c_str()); for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr) { DBG("\t\tAttribute value: %s" , (*valueItr).c_str()); } } }
// static AttributeMap AttributeMap::CreateFromAttribArray(const EGLAttrib *attributes) { AttributeMap map; if (attributes) { for (const EGLAttrib *curAttrib = attributes; curAttrib[0] != EGL_NONE; curAttrib += 2) { map.insert(curAttrib[0], curAttrib[1]); } } return map; }
// static AttributeMap AttributeMap::CreateFromIntArray(const EGLint *attributes) { AttributeMap map; if (attributes) { for (const EGLint *curAttrib = attributes; curAttrib[0] != EGL_NONE; curAttrib += 2) { map.insert(static_cast<EGLAttrib>(curAttrib[0]), static_cast<EGLAttrib>(curAttrib[1])); } } return map; }
void onPut(const OCRepresentation& rep , const int eCode) { if(eCode == SUCCESS_RESPONSE) { std::cout << "PUT request was successful" << std::endl; AttributeMap attributeMap = rep.getAttributeMap(); for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it) { std::cout << "\tAttribute name: " << it->first << " value: "; for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr) { std::cout << "\t" << *valueItr << " "; } std::cout << std::endl; } std::vector< OCRepresentation > children = rep.getChildren(); for(auto oit = children.begin() ; oit != children.end() ; ++oit) { attributeMap = oit->getAttributeMap(); for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it) { std::cout << "\tAttribute name: " << it->first << " value: "; for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr) { std::cout << "\t" << *valueItr << " "; } std::cout << std::endl; } } if(OBSERVE_TYPE_TO_USE == ObserveType::Observe) std::cout << std::endl << "Observe is used." << std::endl << std::endl; else if(OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll) std::cout << std::endl << "ObserveAll is used." << std::endl << std::endl; QueryParamsMap test; g_curResource->observe(ObserveType::Observe , test , &onObserve); } else { std::cout << "onPut Response error: " << eCode << std::endl; std::exit(-1); } }
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const AttributeMap &map, const std::string &attributeName) { StyleSheetTable::AttributeMap::const_iterator it = map.find(attributeName); if (it == map.end()) { return; } const std::vector<std::string> &values = it->second; if (!values.empty() && !values[0].empty()) { short size; ZLTextStyleEntry::SizeUnit unit; parseLength(values[0], size, unit); entry.setLength(name, size, unit); } }
void SerializingParser::handleStartElement(const std::string& tag, const std::string& ns, const AttributeMap& attributes) { boost::shared_ptr<XMLElement> element(new XMLElement(tag, ns)); for (AttributeMap::const_iterator i = attributes.begin(); i != attributes.end(); ++i) { element->setAttribute((*i).first, (*i).second); } if (elementStack_.empty()) { rootElement_ = element; } else { (*(elementStack_.end() - 1))->addNode(element); } elementStack_.push_back(element); }
Error Stream::createConsumerGLTextureExternal(const AttributeMap &attributes, gl::Context *context) { ASSERT(mState == EGL_STREAM_STATE_CREATED_KHR); ASSERT(mConsumerType == ConsumerType::NoConsumer); ASSERT(mProducerType == ProducerType::NoProducer); ASSERT(context != nullptr); const auto &glState = context->getState(); EGLenum bufferType = attributes.getAsInt(EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER); if (bufferType == EGL_RGB_BUFFER) { mPlanes[0].texture = glState.getTargetTexture(gl::TextureType::External); ASSERT(mPlanes[0].texture != nullptr); mPlanes[0].texture->bindStream(this); mConsumerType = ConsumerType::GLTextureRGB; mPlaneCount = 1; } else { mPlaneCount = attributes.getAsInt(EGL_YUV_NUMBER_OF_PLANES_EXT, 2); ASSERT(mPlaneCount <= 3); for (EGLint i = 0; i < mPlaneCount; i++) { // Fetch all the textures mPlanes[i].textureUnit = attributes.getAsInt(EGL_YUV_PLANE0_TEXTURE_UNIT_NV + i, -1); if (mPlanes[i].textureUnit != EGL_NONE) { mPlanes[i].texture = glState.getSamplerTexture(mPlanes[i].textureUnit, gl::TextureType::External); ASSERT(mPlanes[i].texture != nullptr); } } // Bind them to the stream for (EGLint i = 0; i < mPlaneCount; i++) { if (mPlanes[i].textureUnit != EGL_NONE) { mPlanes[i].texture->bindStream(this); } } mConsumerType = ConsumerType::GLTextureYUV; } mContext = context; mState = EGL_STREAM_STATE_CONNECTING_KHR; return NoError(); }
static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*, const xmlChar* xmlns, int, const xmlChar**, int nbAttributes, int nbDefaulted, const xmlChar ** attributes) { AttributeMap attributeValues; if (nbDefaulted != 0) { // Just because i don't understand what this means yet :-) std::cerr << "Unexpected nbDefaulted on XML element" << std::endl; } for (int i = 0; i < nbAttributes*5; i += 5) { std::string attributeNS = ""; if (attributes[i+2]) { attributeNS = std::string(reinterpret_cast<const char*>(attributes[i+2])); } attributeValues.addAttribute(std::string(reinterpret_cast<const char*>(attributes[i])), attributeNS, std::string(reinterpret_cast<const char*>(attributes[i+3]), attributes[i+4]-attributes[i+3])); } static_cast<XMLParser*>(parser)->getClient()->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues); }
bool TemplateBuilder::getRequiredBooleanAttribute( const AttributeMap& attributes, const std::string& name) { AttributeMap::const_iterator it = attributes.find(name); if(it == attributes.end()) { std::string errMsg; errMsg += "[ERR S1] Missing required attribute \"" + name + "\""; throw TemplateDefinitionError(errMsg); } return getOptionalBooleanAttribute(attributes, name, false); }