Compare commits

..

1 commit

Author SHA1 Message Date
9d95d08ab7 Add message serialization and deserialization
All checks were successful
PR Check / on-push-commit-check (push) Successful in 11m53s
2024-12-23 01:37:24 +11:00
3 changed files with 7 additions and 1 deletions

View file

@ -111,6 +111,9 @@ struct Client {
get_roster_response);
co_return;
}
[[nodiscard]] auto Roster() const -> const std::vector<iq::RosterItem>& {
return this->roster.items;
}
private:
bool active = true;

View file

@ -6,6 +6,7 @@ struct XmlLanguage : std::string {
static constexpr auto kDefaultName = "lang";
static constexpr auto kDefaultNamespace = "xml";
using std::string::basic_string;
constexpr XmlLanguage() : std::string{"en"} {};
constexpr XmlLanguage(std::string str) : std::string(std::move(str)) {
}
static constexpr auto Parse(std::string_view view) -> XmlLanguage {

View file

@ -41,7 +41,9 @@ TEST(Parse, Message) {
}
TEST(Serialize, Message) {
auto expected = CreateTestData()->write_to_string();
auto expected =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message from=\"user1@server.i2p\" to=\"user2@server.i2p\" type=\"chat\" id=\"1\" "
"xml:lang=\"en\"><body>hello</body></message>\n";
xmlpp::Document doc;
auto node = doc.create_root_node("message");
Serialization<Message<BareJid, BareJid>>::Serialize(node, kMessage);