IDS peak ICV v1.1.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{
49{
50public:
65 PEAK_COMMON_NO_DISCARD std::shared_ptr<peak::common::serialization::IArchive> Read(std::istream& stream) override;
66};
67
68inline std::shared_ptr<peak::common::serialization::IArchive> Deserializer::Read(std::istream& stream)
69{
70 std::string buffer((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
71
72 peak_icv_archive_handle archiveHandle{};
73
74 detail::ExecuteAndMapReturnCodes([&buffer, &archiveHandle] {
75 return PEAK_ICV_C_ABI_PREFIX peak_icv_Archive_CreateFromString(
76 &archiveHandle, peak_icv_serialization_type::PEAK_ICV_SERIALIZATION_TYPE_JSON, buffer.data());
77 });
78
79 return std::make_shared<Archive>(peak::common::detail::BackendAccessor<Archive>::CreateInstance(archiveHandle));
80}
81
82} /* namespace icv */
83} /* namespace peak */
Interface for deserializing structured data from an input stream into an archive.
A deserializer that reads serialized data and converts it to IArchive objects.
std::shared_ptr< peak::common::serialization::IArchive > Read(std::istream &stream) override
Reads and deserializes data from an input stream.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)