fdbserver/Status.actor.cpp
// return false on failure; outputs decoded attribute value to `ret`
return false on failure; outputs decoded attribute value to `ret`
return false on failure ; outputs decoded attribute value to ` ret `
bool tryExtractAttribute( StringRef expanded, StringRef attributeToExtract, std::string& ret ) {
	int pos = 0;
	if (pos == expanded.size() || expanded[pos] != '<') return false;
	pos++;
	while (pos != expanded.size() && expanded[pos] != ' ' && expanded[pos] != '/' && expanded[pos] != '>') pos++;
	while (pos != expanded.size() && expanded[pos] != '>' && expanded[pos] != '/') {
		while (pos != expanded.size() && expanded[pos] == ' ') pos++;
		int eq_or_end = pos;
		while (eq_or_end != expanded.size() && expanded[eq_or_end]!='=' && expanded[eq_or_end]!='>') eq_or_end++;
		if ( expanded.substr(pos, eq_or_end-pos) == attributeToExtract ) {
			int end = decodeQuotedAttributeValue(expanded.substr(eq_or_end+1), &ret);
			if (end<0) { ret.clear(); return false; }
			return true;
		}
		int end = decodeQuotedAttributeValue(expanded.substr(eq_or_end+1), NULL);
		if (end<0) return false;
		pos = (eq_or_end+1)+end;
	}
	return false;
}
bool tryExtractAttribute ( StringRef expanded , StringRef attributeToExtract , std :: string & ret ) { int pos = 0 ; if ( pos == expanded . size ( ) || expanded [ pos ] != ' ' ) return false ; pos ++ ; while ( pos != expanded . size ( ) && expanded [ pos ] != ' ' && expanded [ pos ] != ' ' && expanded [ pos ] != ' ' ) pos ++ ; while ( pos != expanded . size ( ) && expanded [ pos ] != ' ' && expanded [ pos ] != ' ' ) { while ( pos != expanded . size ( ) && expanded [ pos ] == ' ' ) pos ++ ; int eq_or_end = pos ; while ( eq_or_end != expanded . size ( ) && expanded [ eq_or_end ] != ' ' && expanded [ eq_or_end ] != ' ' ) eq_or_end ++ ; if ( expanded . substr ( pos , eq_or_end - pos ) == attributeToExtract ) { int end = decodeQuotedAttributeValue ( expanded . substr ( eq_or_end + 1 ) , & ret ) ; if ( end < 0 ) { ret . clear ( ) ; return false ; } return true ; } int end = decodeQuotedAttributeValue ( expanded . substr ( eq_or_end + 1 ) , NULL ) ; if ( end < 0 ) return false ; pos = ( eq_or_end + 1 ) + end ; } return false ; }
return false on failure; outputs decoded attribute value to `ret`
return false on failure ; outputs decoded attribute value to ` ret `
// This is only expected to parse the XML that Trace.cpp actually generates; we haven't looked at the standard to even find out what it doesn't try to do // Consume '<' // Consume tag name // Consume whitespace // We should be looking at an attribute or the end of the string; find '=' at the end of the attribute, if any // Found the attribute we want; decode the value // We don't want this attribute, but we need to skip over its value // It looks like this *could* just be a scan for '"' characters