IDS peak ICV v1.4.0
Loading...
Searching...
No Matches
Serializer Class Reference

#include <peak_icv/serialization/peak_icv_serializer.hpp>

Inheritance diagram for Serializer:

Public Member Functions

 Serializer (SerializationType type=SerializationType::Json)
 Constructs a Serializer with the specified serialization type.
 
void Write (const peak::common::serialization::IArchive &archive, std::ostream &stream) override
 Serializes an archive and writes it to a stream.
 

Detailed Description

Serializer for writing IArchive objects to an output stream.

This class converts an IArchive object into a specific serialization format and writes the result to a stream.

Example

archive.SetInt("id", 42);
archive.SetString("name", "example");
std::ofstream file("archive.json");
serializer.Write(archive, file);
file.close();
A key-value store that implements the IArchive interface.
Definition peak_icv_archive.hpp:70
void SetInt(const std::string &key, int64_t value) override
Sets an integer value.
Definition peak_icv_archive.ipp:175
Serializer for writing IArchive objects to an output stream.
Definition peak_icv_serializer.hpp:54
void Write(const peak::common::serialization::IArchive &archive, std::ostream &stream) override
Serializes an archive and writes it to a stream.
Definition peak_icv_serializer.hpp:97
@ Json
JSON (JavaScript Object Notation) format.
Since
ids_peak_icv 1.0

Constructor & Destructor Documentation

◆ Serializer()

Constructs a Serializer with the specified serialization type.

The chosen format determines how the archive is written when Write() is called. If no type is provided, JSON is used by default.

Parameters
typeThe serialization format to use (defaults to SerializationType::Json).
Since
ids_peak_icv 1.0

Member Function Documentation

◆ Write()

void Write ( const peak::common::serialization::IArchive & archive,
std::ostream & stream )
inlineoverridevirtual

Serializes an archive and writes it to a stream.

Converts the given IArchive object into the configured format and writes the serialized data to the provided stream.

Parameters
archiveThe archive to serialize.
streamThe stream that receives the serialized data.
Exceptions
NotSupportedExceptionThe serialization type is not supported.
Since
ids_peak_icv 1.0

Implements ISerializer.