40 lines
1.4 KiB
C++
40 lines
1.4 KiB
C++
#pragma once
|
|
#include <libxml++/libxml++.h>
|
|
|
|
#include <optional>
|
|
#include <variant>
|
|
|
|
namespace larra::xmpp::client::starttls {
|
|
|
|
struct Failure : std::exception {
|
|
static constexpr auto kDefaultName = "failure";
|
|
static constexpr auto kDefaultNamespace = "urn:ietf:params:xml:ns:xmpp-sasl";
|
|
static constexpr auto TryParse(xmlpp::Element* element) -> std::optional<Failure> {
|
|
return element->get_name() == kDefaultName ? std::optional{Failure{}} : std::nullopt;
|
|
}
|
|
static constexpr auto Parse(xmlpp::Element* element) -> Failure {
|
|
return TryParse(element).value();
|
|
}
|
|
friend constexpr auto operator<<(xmlpp::Element* element, const Failure& failure) {
|
|
}
|
|
[[nodiscard]] constexpr auto what() const noexcept -> const char* override {
|
|
return "StartTLS Failure";
|
|
}
|
|
};
|
|
|
|
struct Success {
|
|
static constexpr auto kDefaultName = "success";
|
|
static constexpr auto kDefaultNamespace = "urn:ietf:params:xml:ns:xmpp-tls";
|
|
static constexpr auto TryParse(xmlpp::Element* element) -> std::optional<Success> {
|
|
return element->get_name() == kDefaultName ? std::optional{Success{}} : std::nullopt;
|
|
}
|
|
static constexpr auto Parse(xmlpp::Element* element) -> Success {
|
|
return TryParse(element).value();
|
|
}
|
|
friend constexpr auto operator<<(xmlpp::Element* element, const Success& failure) {
|
|
}
|
|
};
|
|
|
|
using Response = std::variant<Failure, Success>;
|
|
|
|
} // namespace larra::xmpp::client::starttls
|