helper function to get atribute value as a string, blank if attribute missing
| 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 |
nothing calls this directly
no test coverage detected