DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
serialization_mail_elements.h
1 /*********************************************************************************************************************************************/
2 /* DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. */
3 /* Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, */
4 /* document analysis. Offline processing possible for security and confidentiality */
5 /* */
6 /* Copyright (c) SILVERCODERS Ltd, http://silvercoders.com */
7 /* Project homepage: https://github.com/docwire/docwire */
8 /* */
9 /* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DocWire-Commercial */
10 /*********************************************************************************************************************************************/
11 
12 #ifndef DOCWIRE_SERIALIZATION_MAIL_ELEMENTS_H
13 #define DOCWIRE_SERIALIZATION_MAIL_ELEMENTS_H
14 
15 #include "mail_elements.h"
16 #include "serialization_base.h"
17 #include "serialization_file_extension.h" // IWYU pragma: keep
18 
19 namespace docwire::serialization
20 {
21 
22 template<>
23 struct serializer<mail::attachment>
24 {
25  value full(const mail::attachment& attachment) const
26  {
27  return object{{
28  {"name", serialization::full(attachment.name)},
29  {"size", static_cast<int64_t>(attachment.size)},
30  {"extension", serialization::full(attachment.extension)}
31  }};
32  }
33  value typed_summary(const mail::attachment& attachment) const { return decorate_with_typeid(full(attachment), type_name::pretty<mail::attachment>()); }
34 };
35 
36 template<>
37 struct serializer<mail::mail>
38 {
39  value full(const mail::mail& mail) const
40  {
41  return object{{
42  {"subject", serialization::full(mail.subject)},
43  {"date", serialization::full(mail.date)},
44  {"level", serialization::full(mail.level)}
45  }};
46  }
47  value typed_summary(const mail::mail& mail) const { return decorate_with_typeid(full(mail), type_name::pretty<mail::mail>()); }
48 };
49 
50 template<>
51 struct serializer<mail::folder>
52 {
53  value full(const mail::folder& folder) const
54  {
55  return object{{
56  {"name", serialization::full(folder.name)},
57  {"level", serialization::full(folder.level)}
58  }};
59  }
60  value typed_summary(const mail::folder& folder) const { return decorate_with_typeid(full(folder), type_name::pretty<mail::folder>()); }
61 };
62 
63 }
64 
65 #endif // DOCWIRE_SERIALIZATION_MAIL_ELEMENTS_H
Provides a generic, concept-based serialization framework.
value decorate_with_typeid(const value &base_val, const std::string &typeid_str)
Helper to decorate a serialized value with a typeid string.
std::variant< std::nullptr_t, bool, std::int64_t, std::uint64_t, double, std::string, array, object > value
A variant type representing any serialized value.
value full(const T &value)
Serializes a value of type T into a docwire::serialization::value.
Primary template for the serializer.