12 #ifndef DOCWIRE_XML_ATTRIBUTE_REF_H
13 #define DOCWIRE_XML_ATTRIBUTE_REF_H
15 #include "safety_policy.h"
16 #include "xml_reader.h"
18 #include <string_view>
20 #include "convert_base.h"
31 template <safety_policy safety_level = default_safety_level>
41 std::string_view
name()
const {
return m_reader.get().name(); }
43 std::string_view
value()
const {
return m_reader.get().content(); }
46 std::reference_wrapper<const reader<safety_level>> m_reader;
55 template<
typename T, safety_policy safety_level>
56 requires convert::conversion_implementation_exists<T, std::string_view>
59 return convert::try_to<T>(attr.value());
A reference to an XML attribute.
std::string_view value() const
Returns the value of the attribute.
std::string_view name() const
Returns the name of the attribute.
attribute_ref(const reader< safety_level > &reader)
Constructs a reference from a reader positioned at an attribute.
XML processing utilities.
requires convert::conversion_implementation_exists< T, std::string_view > std::optional< T > convert_impl(const attribute_ref< safety_level > &attr, convert::dest_type_tag< T >) noexcept
Conversion implementation to convert an attribute_ref to another type T. This is done by attempting t...
requires(!string_method_equipped< T >) struct stringifier< T >
Specialization for types that are streamable to std::ostream.
A tag type used for dispatching convert_impl overloads based on the destination type.