IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
peak_icv_deserializer.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <istream>
14
16
17#include <peak_common_c/detail/peak_common_defines.h>
23
24namespace peak
25{
26namespace icv
27{
65{
66public:
82 PEAK_COMMON_NO_DISCARD std::shared_ptr<peak::common::serialization::IArchive> Read(std::istream& stream) override;
83};
84
85inline std::shared_ptr<peak::common::serialization::IArchive> Deserializer::Read(std::istream& stream)
86{
87 std::string buffer((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
88
89 peak_icv_archive_handle archiveHandle{};
90
91 detail::ExecuteAndMapReturnCodes([&buffer, &archiveHandle] {
92 return PEAK_ICV_C_ABI_PREFIX peak_icv_Archive_CreateFromString(
93 &archiveHandle, peak_icv_serialization_type::PEAK_ICV_SERIALIZATION_TYPE_JSON, buffer.data());
94 });
95
96 return std::make_shared<Archive>(peak::common::detail::BackendAccessor<Archive>::CreateInstance(archiveHandle));
97}
98
99} /* namespace icv */
100} /* namespace peak */
Interface for deserializing structured data from an input stream into an archive.
Deserializer for reading serialized data and converting it into an IArchive object.
std::shared_ptr< peak::common::serialization::IArchive > Read(std::istream &stream) override
Reads serialized data from the specified stream and deserializes it into an archive.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)