Skip to content

Commit aebbbfb

Browse files
committed
Add [[nodiscard]] to html_utils.h
1 parent d12c97d commit aebbbfb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/html_utils.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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]]
3536
std::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]]
3840
std::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]]
4144
std::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]]
4448
std::optional<std::string_view> get_attribute_of(std::string_view attr, std::string_view elem,
4549
std::string_view xml);
4650

0 commit comments

Comments
 (0)