add serializer (setup) for the basic message components

This commit is contained in:
Green Sky 2024-04-14 12:41:54 +02:00
parent 4039239c16
commit 5b9909a989
No known key found for this signature in database
4 changed files with 74 additions and 0 deletions

View File

@ -5,6 +5,11 @@ project(solanaceae)
add_library(solanaceae_message_serializer
./solanaceae/message3/message_serializer.hpp
./solanaceae/message3/message_serializer.cpp
# TODO: extract?
./solanaceae/message3/nj/message_components.hpp
./solanaceae/message3/nj/message_components_serializer.hpp
./solanaceae/message3/nj/message_components_serializer.cpp
)
target_include_directories(solanaceae_message_serializer PUBLIC .)

View File

@ -0,0 +1,29 @@
#pragma once
#include <solanaceae/util/utils.hpp>
#include <solanaceae/message3/components.hpp>
#include <nlohmann/json.hpp>
namespace Message::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Timestamp, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TimestampProcessed, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TimestampWritten, ts)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactFrom, c)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ContactTo, c)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Read, ts)
// TODO: SyncedBy
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MessageText, text)
// TODO: remove
//namespace Transfer {
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FileInfo::FileDirEntry, file_name, file_size)
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FileInfo, file_list, total_size)
//NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FileInfoLocal, file_list)
//} // Transfer
} // Message::Components

View File

@ -0,0 +1,34 @@
#include "./message_components_serializer.hpp"
#include "./message_components.hpp"
void registerMessageComponents(MessageSerializerNJ& msnj) {
msnj.registerSerializer<Message::Components::Timestamp>();
msnj.registerDeserializer<Message::Components::Timestamp>();
msnj.registerSerializer<Message::Components::TimestampProcessed>();
msnj.registerDeserializer<Message::Components::TimestampProcessed>();
msnj.registerSerializer<Message::Components::TimestampWritten>();
msnj.registerDeserializer<Message::Components::TimestampWritten>();
msnj.registerSerializer<Message::Components::ContactFrom>();
msnj.registerDeserializer<Message::Components::ContactFrom>();
msnj.registerSerializer<Message::Components::ContactTo>();
msnj.registerDeserializer<Message::Components::ContactTo>();
msnj.registerSerializer<Message::Components::TagUnread>();
msnj.registerDeserializer<Message::Components::TagUnread>();
msnj.registerSerializer<Message::Components::Read>();
msnj.registerDeserializer<Message::Components::Read>();
msnj.registerSerializer<Message::Components::MessageText>();
msnj.registerDeserializer<Message::Components::MessageText>();
msnj.registerSerializer<Message::Components::TagMessageIsAction>();
msnj.registerDeserializer<Message::Components::TagMessageIsAction>();
// files
//_sc.registerSerializerJson<Message::Components::Transfer::FileID>()
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfo>();
//_sc.registerDeSerializerJson<Message::Components::Transfer::FileInfo>();
//_sc.registerSerializerJson<Message::Components::Transfer::FileInfoLocal>();
//_sc.registerDeSerializerJson<Message::Components::Transfer::FileInfoLocal>();
//_sc.registerSerializerJson<Message::Components::Transfer::TagHaveAll>();
//_sc.registerDeSerializerJson<Message::Components::Transfer::TagHaveAll>();
}

View File

@ -0,0 +1,6 @@
#pragma once
#include <solanaceae/message3/message_serializer.hpp>
void registerMessageComponents(MessageSerializerNJ& msnj);