|
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
|
Provides a generic, concept-based serialization framework. More...
Typedefs | |
| using | value = std::variant< std::nullptr_t, bool, std::int64_t, std::uint64_t, double, std::string, array, object > |
| A variant type representing any serialized value. More... | |
Enumerations | |
| enum class | serializer_kind { value_alternative , arithmetic , string_like , container , dereferenceable } |
| An enum to identify the kind of serializer specialization. | |
Functions | |
| DOCWIRE_CORE_EXPORT std::string | to_json (const value &s_val) |
Converts a docwire::serialization::value to a JSON string. More... | |
| value | decorate_with_typeid (const value &base_val, const std::string &typeid_str) |
| Helper to decorate a serialized value with a typeid string. | |
| template<typename T > | |
| value | full (const T &value) |
Serializes a value of type T into a docwire::serialization::value. More... | |
| template<typename T > | |
| value | typed_summary (const T &value) |
| template<typename T > | |
| requires (std::is_arithmetic_v< T > &&!value_alternative< T >) struct serializer< T > | |
| Specialization for arithmetic types (integers, floats). More... | |
| template<typename T > | |
| requires (dereferenceable< T > &&!container< T > &&!string_like< T > &&!value_alternative< T >) struct serializer< T > | |
| Specialization for dereferenceable types (e.g., pointers, smart pointers). More... | |
| template<typename T > | |
| requires (container< T > &&!string_like< T > &&!value_alternative< T >) struct serializer< T > | |
| Specialization for iterable types (e.g., std::vector, std::list). More... | |
Variables | |
| template<typename T > | |
| concept | value_alternative = variant_alternative<T, value> |
A specific concept to check if a type T is one of the alternatives in docwire::serialization::value. | |
| template<typename T > | |
| concept | with_styling = requires(T t) { t.styling; } |
Concept for types that have a styling member. | |
Provides a generic, concept-based serialization framework.
This namespace contains the tools to convert arbitrary C++ types into a structured, serializable representation. The core of the framework is the docwire::serialization::value type, a std::variant that can hold primitive types, arrays, or objects.
The framework is designed to be non-intrusive. To add serialization support for a new type, you specialize the docwire::serialization::serializer struct for that type. The framework already provides specializations for many standard library types, primitives, and common patterns like containers and pointers.
This serialization mechanism is used extensively by the logging framework and error framework. to capture the state of variables and objects for diagnostic purposes.
| using docwire::serialization::value = typedef std::variant< std::nullptr_t, bool, std::int64_t, std::uint64_t, double, std::string, array, object > |
A variant type representing any serialized value.
This is the cornerstone of the serialization framework, representing a value as one of C++'s primitive types or a container of other docwire::serialization::values.
Definition at line 59 of file serialization_base.h.
| value docwire::serialization::full | ( | const T & | value | ) |
Serializes a value of type T into a docwire::serialization::value.
This function uses the docwire::serialization::serializer struct to perform the conversion.
| T | The type of the value to serialize. |
| value | The value to serialize. |
docwire::serialization::value. Definition at line 115 of file serialization_base.h.
| docwire::serialization::requires | ( | container< T > &&!string_like< T > &&!value_alternative< T > | ) |
Specialization for iterable types (e.g., std::vector, std::list).
Serializes the container into a docwire::serialization::array. It excludes std::string, which is iterable but should be treated as a single value.
Definition at line 244 of file serialization_base.h.
| docwire::serialization::requires | ( | dereferenceable< T > &&!container< T > &&!string_like< T > &&!value_alternative< T > | ) |
Specialization for dereferenceable types (e.g., pointers, smart pointers).
Serializes to nullptr if the pointer is null, otherwise serializes the dereferenced object.
Definition at line 214 of file serialization_base.h.
| docwire::serialization::requires | ( | std::is_arithmetic_v< T > &&!value_alternative< T > | ) |
Specialization for arithmetic types (integers, floats).
This converts various integer and floating-point types to the types supported by the docwire::serialization::value variant.
Definition at line 150 of file serialization_base.h.
| DOCWIRE_CORE_EXPORT std::string docwire::serialization::to_json | ( | const value & | s_val | ) |
Converts a docwire::serialization::value to a JSON string.
This allows the generic serialization mechanism to be used for JSON-specific tasks like stringification or structured logging.
| s_val | The docwire::serialization::value to convert. |