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_data_source.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_DATA_SOURCE_H
13 #define DOCWIRE_SERIALIZATION_DATA_SOURCE_H
14 
15 #include "data_source.h"
16 #include "serialization_base.h"
17 #include "serialization_file_extension.h" // IWYU pragma: keep
18 #include "serialization_filesystem.h" // IWYU pragma: keep
19 
20 namespace docwire::serialization
21 {
22 
23 template <>
25 {
26  value full(const data_source& data) const
27  {
28  return object{{
29  {"path", serialization::full(data.path())},
30  {"file_extension", serialization::full(data.file_extension())}
31  }};
32  }
33 
34  value typed_summary(const data_source& data) const
35  {
36  return decorate_with_typeid(object{{
37  {"path", serialization::typed_summary(data.path())},
38  {"file_extension", serialization::typed_summary(data.file_extension())}
39  }}, type_name::pretty<data_source>());
40  }
41 };
42 
43 } // namespace docwire::serialization
44 
45 #endif // DOCWIRE_SERIALIZATION_DATA_SOURCE_H
std::optional< docwire::file_extension > file_extension() const
Returns the file extension if available.
std::optional< std::filesystem::path > path() const
Returns the file path if the source is a file, otherwise std::nullopt.
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.