@@ -6,15 +6,15 @@ namespace lwg
66{
77// Replace reserved characters with entities, for use as an attribute value.
88// Use for attributes like title="..." and content="...".
9- inline std::string replace_reserved_char (std::string text, char c, std::string_view repl) {
9+ [[nodiscard]] inline std::string replace_reserved_char (std::string text, char c, std::string_view repl) {
1010 for (auto p = text.find (c); p != text.npos ; p = text.find (c, p+repl.size ()))
1111 text.replace (p, 1 , repl);
1212 return text;
1313}
1414
1515// Remove XML elements from the argument to just get the text nodes.
1616// Used to generate plain text versions of elements like <title>.
17- inline std::string strip_xml_elements (std::string xml) {
17+ [[nodiscard]] inline std::string strip_xml_elements (std::string xml) {
1818 for (auto p = xml.find (' <' ); p != xml.npos ; p = xml.find (' <' , p))
1919 xml.erase (p, xml.find (' >' , p) + 1 - p);
2020 return xml;
@@ -32,15 +32,19 @@ struct xml_element
3232};
3333
3434// Find "<elem>...</elem>" in xml and return as two string views.
35+ [[nodiscard]]
3536std::optional<xml_element> get_element (std::string_view elem, std::string_view xml);
3637
3738// As above, but only return the inner part.
39+ [[nodiscard]]
3840std::optional<std::string_view> get_element_content (std::string_view elem, std::string_view xml);
3941
4042// Find attr="..." in xml and return the attribute's value
43+ [[nodiscard]]
4144std::optional<std::string_view> get_attribute (std::string_view attr, std::string_view xml);
4245
4346// Find <elem attr="..."> in xml and return the attribute's value
47+ [[nodiscard]]
4448std::optional<std::string_view> get_attribute_of (std::string_view attr, std::string_view elem,
4549 std::string_view xml);
4650
0 commit comments