#include namespace larra::xmpp::iq { auto operator<<(xmlpp::Element* element, const Bind& bind) -> void { element->set_namespace_declaration(Bind::kDefaultNamespace); if(bind.jid) { auto* jid_el = element->add_child_element("jid"); jid_el->add_child_text(ToString(*bind.jid)); } } [[nodiscard]] auto Bind::Parse(xmlpp::Element* element) -> Bind { const auto* jid_node = element->get_first_child("jid"); if(!jid_node) { SPDLOG_DEBUG("No Jid Node at Iq::Bind"); return {}; } auto* jid_el = dynamic_cast(jid_node); if(!jid_el) { throw std::runtime_error("dynamic_cast to const xmlpp::Element* failed"); } const auto* text = jid_el->get_first_child_text(); if(!jid_el) { throw std::runtime_error("No text at Iq::Bind jid child"); } return {.jid = (jid_node ? std::optional{FullJid::Parse(text->get_content())} : std::nullopt)}; } } // namespace larra::xmpp::iq