#include "sax_attributes.hh" namespace modxml { namespace sax { Attribute::Attribute(std::string_view name, std::string_view value) : name(name), value(value) {} std::optional Attributes::find_first(std::string_view name) const { for (auto it = begin(); it != end(); ++it) { if (it->name == name) return it->value; } return std::nullopt; } std::optional Attributes::find_last(std::string_view name) const { for (size_t i = size(); i > 0; --i) { auto const& a = at(i - 1); if (a.name == name) return a.value; } return std::nullopt; } std::optional Attributes::find(std::string_view name, std::size_t index) const { for (; index < size(); ++index) { if (at(index).name == name) return index; } return std::nullopt; } } // namespace sax } // namespace modxml