12 #ifndef DOCWIRE_XML_NODE_REF_H
13 #define DOCWIRE_XML_NODE_REF_H
16 #include "xml_iterator_state.h"
19 #include "convert_base.h"
31 template <safety_policy safety_level = default_safety_level>
40 : m_state(std::move(
state)) {}
42 std::string_view
name()
const {
return m_state->xml_reader.name(); }
44 std::string_view
full_name()
const {
return m_state->xml_reader.full_name(); }
46 std::string_view
content()
const {
return m_state->xml_reader.content(); }
48 std::string_view
string_value()
const {
return m_state->xml_reader.string_value(); }
66 template<
typename T, safety_policy safety_level>
67 requires convert::conversion_implementation_exists<T, std::string_view>
70 return convert::try_to<T>(node.string_value());
A wrapper for pointer-like types that enforces a non-null invariant.
A wrapper for numeric types that enforces a range [Min, Max].
A reference to the current XML node in the reader.
non_negative< int, safety_level > depth() const
Returns the depth of the node in the XML tree.
const not_null< std::shared_ptr< iterator_state< safety_level > >, safety_level > & state() const
Returns the shared iterator state associated with this node reference.
std::string_view name() const
Returns the local name of the node.
node_ref(not_null< std::shared_ptr< iterator_state< safety_level >>, safety_level > state)
Constructs a reference from an iterator state.
node_type type() const
Returns the type of the node.
std::string_view content() const
Returns the content of the node (e.g., text content).
std::string_view full_name() const
Returns the full name (including namespace prefix) of the node.
std::string_view string_value() const
Returns the string value of the node (concatenated text of children).
XML processing utilities.
node_type
Represents the type of an XML node.
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.
Shared state for XML iterators to coordinate traversal.