MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / attribute_value

Function attribute_value

native/thirdpart/tinyxml2/tixml2ex.h:446–461  ·  view source on GitHub ↗

helper function to get atribute value as a string, blank if attribute missing

Source from the content-addressed store, hash-verified

444
445 // helper function to get atribute value as a string, blank if attribute missing
446 inline std::string attribute_value (const XMLElement * element, const std::string & name, bool throwIfUnknown = false)
447 {
448 if (!element)
449 throw XmlException ("null element"s);
450
451 if (name .empty())
452 throw XmlException ("missing attribute name"s);
453
454 if (auto value = element -> Attribute (name .c_str()))
455 return std::string (value);
456
457 if (!throwIfUnknown)
458 return ""s;
459 else
460 throw XmlException ("attribute not present"s);
461 }
462
463
464 // helper function to get element text as a string, blank if none

Callers

nothing calls this directly

Calls 4

XmlExceptionClass · 0.85
emptyMethod · 0.80
AttributeMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected