TTErr TTObjectBase::removeAttribute(const TTSymbol name) { TTAttribute* attribute = NULL; TTErr err = findAttribute(name, &attribute); if (!err) { err = attributes->remove(name); delete attribute; } return err; }
map<string, double> getConditionalProbability(string attribute) { int index = findAttribute(attribute); map<string, double> prob, cnt; FOR (iter, data) { string value = iter->values[index]; string isBad = iter->values[INDEX_IS_BAD]; if (isBad == "1") { prob[value] += 1; } cnt[value] += 1; }
bool ossimXmlNode::getAttributeValue(ossimString& value, const ossimString& name)const { ossimRefPtr<ossimXmlAttribute> attribute = findAttribute(name); if(attribute.valid()) { value = attribute->getValue(); } return attribute.valid(); }
TTErr TTObjectBase::getAttributeGetterFlags(const TTSymbol name, TTAttributeFlags& value) { TTAttributePtr attribute = NULL; TTErr err; err = findAttribute(name, &attribute); if (!err) attribute->getGetterFlags(value); return err; }
/** * Return the documentation from a petal node with carriage * return handling and removed surrounding quotation marks * if present. */ QString PetalNode::documentation() const { QString s = findAttribute(QLatin1String("documentation")).string.trimmed(); if (s.isEmpty()) return s; s.replace(QLatin1String("\\n"), QLatin1String("\n")); if (s.startsWith(QLatin1Char('\"')) && s.endsWith(QLatin1Char('\"'))) return s.mid(1 ,s.length()-2); else return s; }
TTSymbol TTObjectBase::getAttributeType(const TTSymbol name) { TTAttributePtr attributeObject; if (!findAttribute(name, &attributeObject)) return *(ttDataTypeInfo[attributeObject->type]->name); else return kTTSymEmpty; }
NS_IMETHODIMP nsLDAPURL::HasAttribute(const nsACString &aAttribute, bool *_retval) { NS_ENSURE_ARG_POINTER(_retval); nsAutoCString findAttribute(","); findAttribute.Append(aAttribute); findAttribute.Append(','); *_retval = mAttributes.Find(findAttribute, CaseInsensitiveCompare) != -1; return NS_OK; }
Boolean XmlEntry::getAttributeValue( const char* name, const char*& value) const { const XmlAttribute* attr = findAttribute(name); if (!attr) return false; value = attr->value; return true; }
static long readNumberAttribute(xmlNode *node, const char *name) { xmlAttr *attr = findAttribute(node, name); assert(attr); errno = 0; long value = std::strtol((char*)attr->children->content, 0, 0); if (errno != 0) { std::cerr << "Invalid " << name << '"' << (char*)attr->children->content << "\"\n"; exit(1); } return value; }
void MapReader::createGroup(const size_t line, const Model::EntityAttribute::List& attributes, const ExtraAttributes& extraAttributes) { const String& name = findAttribute(attributes, Model::AttributeNames::GroupName); if (StringUtils::isBlank(name)) { if (logger() != NULL) logger()->warn("Skipping group entity at line %u: missing name", static_cast<unsigned int>(line)); return; } const String& idStr = findAttribute(attributes, Model::AttributeNames::GroupId); if (StringUtils::isBlank(idStr)) { if (logger() != NULL) logger()->warn("Skipping group entity at line %u: missing id", static_cast<unsigned int>(line)); return; } const long rawId = std::atol(idStr.c_str()); if (rawId <= 0) { if (logger() != NULL) logger()->warn("Skipping group entity at line %u: invalid id", static_cast<unsigned int>(line), name.c_str()); return; } const Model::IdType groupId = static_cast<Model::IdType>(rawId); if (m_groups.count(groupId) > 0) { if (logger() != NULL) logger()->warn("Skipping group entity at line %u: a group with id '%s' already exists", static_cast<unsigned int>(line), idStr.c_str()); return; } Model::Group* group = m_factory->createGroup(name); setExtraAttributes(group, extraAttributes); storeNode(group, attributes); m_groups.insert(std::make_pair(groupId, group)); m_currentNode = group; m_brushParent = group; }
void MapReader::createLayer(const size_t line, const Model::EntityAttribute::List& attributes, const ExtraAttributes& extraAttributes) { const String& name = findAttribute(attributes, Model::AttributeNames::LayerName); if (StringUtils::isBlank(name)) { if (logger() != NULL) logger()->warn("Skipping layer entity at line %u: missing name", static_cast<unsigned int>(line)); return; } const String& idStr = findAttribute(attributes, Model::AttributeNames::LayerId); if (StringUtils::isBlank(idStr)) { if (logger() != NULL) logger()->warn("Skipping layer entity at line %u: missing id", static_cast<unsigned int>(line)); return; } const long rawId = std::atol(idStr.c_str()); if (rawId <= 0) { if (logger() != NULL) logger()->warn("Skipping layer entity at line %u: invalid id", static_cast<unsigned int>(line), name.c_str()); return; } const Model::IdType layerId = static_cast<Model::IdType>(rawId); if (m_layers.count(layerId) > 0) { if (logger() != NULL) logger()->warn("Skipping layer entity at line %u: a layer with id '%s' already exists", static_cast<unsigned int>(line), idStr.c_str()); return; } Model::Layer* layer = m_factory->createLayer(name, m_worldBounds); setExtraAttributes(layer, extraAttributes); m_layers.insert(std::make_pair(layerId, layer)); onLayer(layer); m_currentNode = layer; m_brushParent = layer; }
void NeoHardware::uevent() { #define UEVENT_BUFFER_SIZE 1024 char buffer[UEVENT_BUFFER_SIZE]; char *value; int bytesAvail = ueventSocket->bytesAvailable(); int readCount = UEVENT_BUFFER_SIZE; if (bytesAvail < readCount) readCount = bytesAvail; ueventSocket->read(&buffer[0],readCount); if(strcmp(buffer,"change@/devices/platform/s3c2440-i2c/i2c-0/0-0073/pcf50633-mbc.0/power_supply/usb")==0) { qLog(PowerManagement)<<"usb change event"; cableConnected(getCableStatus()); }else if(strcmp(buffer,"change@/devices/platform/s3c2440-i2c/i2c-0/0-0073/pcf50633-mbc.0/power_supply/ac")==0) { qLog(PowerManagement)<<"ac change event"; cableConnected(getCableStatus()); }else if(strcmp(buffer,"change@/devices/platform/s3c2440-i2c/i2c-0/0-0073/pcf50633-mbc.0/power_supply/adapter")==0) { value=findAttribute(buffer,readCount,"POWER_SUPPLY_ONLINE="); qLog(PowerManagement)<<"power_supply change event; online="<<value; }else if(strcmp(buffer,"change@/devices/platform/s3c2440-i2c/i2c-0/0-0073/hdq/bq27000-battery.0/power_supply/battery")==0) { value=findAttribute(buffer,readCount,"POWER_SUPPLY_CAPACITY="); qLog(PowerManagement)<<"battery change event charge%="<<value<<"%"; }else if(strcmp(buffer,"change@/class/switch/headset")==0) { value=findAttribute(buffer,readCount,"SWITCH_STATE="); qDebug()<<"headset change event, switch_state="<<value; } QString currentNowStr = qReadFile("/sys/class/power_supply/battery/current_now"); int currentNow = currentNowStr.toInt() / 1000; batteryVso.setAttribute("current_now", QString::number(currentNow)); }
MapReader::ParentInfo::Type MapReader::storeNode(Model::Node* node, const Model::EntityAttribute::List& attributes) { const String& layerIdStr = findAttribute(attributes, Model::AttributeNames::Layer); if (!StringUtils::isBlank(layerIdStr)) { const long rawId = std::atol(layerIdStr.c_str()); if (rawId > 0) { const Model::IdType layerId = static_cast<Model::IdType>(rawId); Model::Layer* layer = MapUtils::find(m_layers, layerId, static_cast<Model::Layer*>(NULL)); if (layer != NULL) onNode(layer, node); else m_unresolvedNodes.push_back(std::make_pair(node, ParentInfo::layer(layerId))); return ParentInfo::Type_Layer; } if (logger() != NULL) logger()->warn("Entity at line %u has invalid parent id", static_cast<unsigned int>(node->lineNumber()), layerIdStr.c_str()); } else { const String& groupIdStr = findAttribute(attributes, Model::AttributeNames::Group); if (!StringUtils::isBlank(groupIdStr)) { const long rawId = std::atol(groupIdStr.c_str()); if (rawId > 0) { const Model::IdType groupId = static_cast<Model::IdType>(rawId); Model::Group* group = MapUtils::find(m_groups, groupId, static_cast<Model::Group*>(NULL)); if (group != NULL) onNode(group, node); else m_unresolvedNodes.push_back(std::make_pair(node, ParentInfo::group(groupId))); return ParentInfo::Type_Group; } if (logger() != NULL) logger()->warn("Entity at line %u has invalid parent id", static_cast<unsigned int>(node->lineNumber()), groupIdStr.c_str()); } } onNode(NULL, node); return ParentInfo::Type_None; }
status_t ASessionDescription::getSessionUrl(String8& uri) const{ AString line; if(findAttribute(0, "a=control", &line)) { // rtsp without aggregation control url will be considered as pure RTP if (!line.startsWith("rtsp://")) return ERROR_UNSUPPORTED; uri.setTo(line.c_str()); } else { // assume as rtp streaming uri.setTo("rtp://0.0.0.0"); } return OK; }
u32 generateIndexInfo(FILE *output, SVGGenElement *elt, u32 index, u32 start) { u32 i = start; int k; for (k=0; k < generic_attributes[index].array_length; k++) { char *att_name = generic_attributes[index].array[k]; SVGGenAttribute *a = findAttribute(elt, att_name); if (a) { fprintf(output, "\tif(!strcmp(\"%s\", name)) return %d;\n", att_name, i); i++; } } return i; }
/** @return Tag created from raw text without '<' and '>'. */ Tag Parser::create(string text) { string key, value; stringstream stream; Tag tag; // Remove ending slash if (Text::endsWith(text, '/')) { text = text.substr(0, text.length()-1); tag.setLeaf(true); } // Put text in stream stream.str(text); // Name stream >> text; if (text[0] == '/') { tag.setName(text.substr(1)); tag.setClosing(true);; } else { tag.setName(text); } // Attributes text = findAttribute(stream); while (stream) { key = findKeyIn(text); value = findValueIn(text); tag[key] = value; text = findAttribute(stream); } // Finish return tag; }
bool SkSVGParser::onAddAttributeLen(const char name[], const char value[], size_t len) { if (fCurrElement == NULL) // this signals we should ignore attributes for this element return true; if (fCurrElement->fIsDef == false && fCurrElement->fIsNotDef == false) return false; // also an ignored element size_t nameLen = strlen(name); int attrIndex = findAttribute(fCurrElement, name, nameLen, false); if (attrIndex == -1) { attrIndex = findAttribute(&fCurrElement->fPaintState, name, nameLen, true); if (attrIndex >= 0) { fCurrElement->fPaintState.addAttribute(*this, attrIndex, value, len); return false; } if (nameLen == 2 && strncmp("id", name, nameLen) == 0) { fCurrElement->f_id.set(value, len); return false; } if (strchr(name, ':') != 0) // part of a different namespace return false; } SkASSERT(attrIndex >= 0); fCurrElement->addAttribute(*this, attrIndex, value, len); return false; }
void generateGenericAttrib(FILE *output, SVGGenElement *elt, u32 index) { int k; for (k=0; k < generic_attributes[index].array_length; k++) { char *att_name = generic_attributes[index].array[k]; SVGGenAttribute *a = findAttribute(elt, att_name); if (a) { s32 type = get_lsr_att_name_type(att_name); /*SMIL anim fill not updatable*/ if ((index==6) && !strcmp(att_name, "fill")) { type = -1; } fprintf(output, ", %d", type); } } }
TTErr TTObjectBase::getAttributeValue(const TTSymbol name, TTValue& value) { TTAttributePtr attribute = NULL; TTErr err; err = findAttribute(name, &attribute); if (!err) { if (attribute->getterFlags & kTTAttrPassObject) err = (this->*attribute->getter)(*attribute, value); else { TTMethodOutputValue getter = (TTMethodOutputValue)attribute->getter; err = (this->*getter)(value); } } return err; }
CssmDbAttributeData& CssmAutoDbRecordAttributeData::getAttributeReference (const CSSM_DB_ATTRIBUTE_INFO &info) { // Either find an existing reference to an attribute in the list, or make a new one. CssmDbAttributeData *anAttr = findAttribute (info); if (anAttr) // was this already in the list? { // clean it up anAttr->deleteValues (mValueAllocator); } else { // make a new one anAttr = &add(); } return *anAttr; }
std::string getAttributeValue(SmartPtrElement& element, const std::string& name) { CAF_CM_STATIC_FUNC("MarkupParser", "getAttributeValue"); CAF_CM_VALIDATE_SMARTPTR(element); CAF_CM_VALIDATE_STRING(name); std::string rc; AttributeIterator iter = findAttribute(element->attributes, name); if (iter != element->attributes.end()) { rc = iter->second; } else { CAF_CM_EXCEPTION_VA2(ERROR_TAG_NOT_FOUND, "Element %s does not contain attribute %s", element->name.c_str(), name.c_str()); } return rc; }
TTErr TTObjectBase::setAttributeValue(const TTSymbol name, TTValue& value) { TTAttributePtr attribute = NULL; // Retreive the registered attribute TTErr err = findAttribute(name, &attribute); if (!err) { // If no value : use attribute default value if (value.empty()) return setAttributeValue(name, attribute->mDefaultValue); // Can't set read only attribute if (attribute->readOnly) err = kTTErrReadOnly; else { // Clipping if (attribute->rangeChecking == kTTSym_clip) value.clip(attribute->rangeLowBound, attribute->rangeHighBound); else if (attribute->rangeChecking == kTTSym_cliplow) value.cliplow(attribute->rangeLowBound); else if (attribute->rangeChecking == kTTSym_cliphigh) value.cliphigh(attribute->rangeHighBound); // Calling the attribute accessor of the object depending of the arguments it takes // Passing attribute structure with the value if (attribute->setterFlags & kTTAttrPassObject) err = (this->*attribute->setter)(*attribute, value); // Or passing the value only else { TTMethodInputValue setter = (TTMethodInputValue)attribute->setter; err = (this->*setter)(value); } } } return err; }
int isMatchingObject(struct p11Object_t *pObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) { struct p11Attribute_t *pAttribute; int i, rv; for (i = 0; i < ulCount; i++) { rv = findAttribute(pObject, pTemplate + i, &pAttribute); if (rv < 0) { return CK_FALSE; } if (pTemplate[i].ulValueLen != pAttribute->attrData.ulValueLen) { return CK_FALSE; } if (memcmp(pAttribute->attrData.pValue, pTemplate[i].pValue, pAttribute->attrData.ulValueLen)) { return CK_FALSE; } } return CK_TRUE; }
void AnalyzeTask::parseTrackInfo(QXmlStreamReader &xmlStream, const MI_trackType_t trackType, AudioFileModel &audioFile) { QString coverMimeType; while (xmlStream.readNextStartElement()) { const MI_propertyId_t idx = m_mediaInfoIdx.value(qMakePair(trackType, xmlStream.name().toString().simplified().toLower()), MI_propertyId_t(-1)); if (idx != MI_propertyId_t(-1)) { const QString encoding = findAttribute(QLatin1String("dt"), xmlStream.attributes()); const QString value = xmlStream.readElementText(QXmlStreamReader::SkipChildElements).simplified(); if (!value.isEmpty()) { parseProperty(encoding.isEmpty() ? value : decodeStr(value, encoding), idx, audioFile, coverMimeType); } } else { xmlStream.skipCurrentElement(); } } }
bool ossimXmlNode::setAttribute(const ossimString& name, const ossimString& value, bool addIfNotPresentFlag) { bool result = false; ossimRefPtr<ossimXmlAttribute> attribute = findAttribute(name); if(attribute.valid()) { attribute->setValue(value); result = true; } else { if(addIfNotPresentFlag) { addAttribute(name, value); result = true; } } return result; }
Boolean XmlEntry::getAttributeValue( const char* name, Uint32& value) const { const XmlAttribute* attr = findAttribute(name); if (!attr) return false; const char* first; const char* last; _findEnds(attr->value, first, last); char* end = 0; long tmp = strtol(first, &end, 10); if (!end || end != last) return false; value = Uint32(tmp); return true; }
Boolean XmlEntry::getAttributeValue( const char* name, Real32& value) const { const XmlAttribute* attr = findAttribute(name); if (!attr) return false; const char* first; const char* last; _findEnds(attr->value, first, last); char* end = 0; double tmp = strtod(first, &end); if (!end || end != last) return false; value = static_cast<Real32>(tmp); return true; }
void TTObjectBase::getAttributeNames(TTValue& attributeNameList) { TTValue unfilteredNameList; TTUInt32 attributeCount; attributes->getKeys(unfilteredNameList); attributeCount = unfilteredNameList.size(); attributeNameList.clear(); for (TTUInt32 i=0; i<attributeCount; i++) { TTAttributePtr attribute = NULL; TTSymbol attributeName = kTTSymEmpty; attributeName = unfilteredNameList[i]; // getAttribute(attributeName, &attribute); findAttribute(attributeName, &attribute); if (attribute->hidden == NO) attributeNameList.append(attributeName); } }
bool ASessionDescription::getDurationUs(int64_t *durationUs) const { *durationUs = 0; CHECK(mIsValid); AString value; if (!findAttribute(0, "a=range", &value)) { return false; } if (value == "npt=now-") { return false; } if (value == "npt=0-") { return false; } if (strncmp(value.c_str(), "npt=", 4)) { return false; } const char *s = value.c_str() + 4; char *end; double from = strtod(s, &end); CHECK_GT(end, s); CHECK_EQ(*end, '-'); s = end + 1; double to = strtod(s, &end); CHECK_GT(end, s); CHECK_EQ(*end, '\0'); CHECK_GE(to, from); *durationUs = (int64_t)((to - from) * 1E6); return true; }
Tag * AdhocTag::generateResponse(const std::string &action) { IQ _response(IQ::Result, m_from, m_id); _response.setFrom(Transport::instance()->jid()); Tag *response = _response.tag(); if (action != "") { response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), action) ); return response; } if (hasAttribute("action", "cancel")) response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "canceled") ); else response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "completed") ); return response; }