IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
Deserializer.cs
Go to the documentation of this file.
1using System.Runtime.InteropServices;
2using System.Text;
4
6
35{
54 public IArchive Read(Stream stream)
55 {
56 var handle = new Archive.Handle();
57
58 using var reader = new StreamReader(stream, Encoding.UTF8, true);
59 var text = reader.ReadToEnd();
60 var utf8Bytes = Encoding.UTF8.GetBytes(text);
61
62 var buffer = new byte[utf8Bytes.Length + 1];
63 Array.Copy(utf8Bytes, buffer, utf8Bytes.Length);
64
65 DllHelper.ExecuteAndMapReturnCodes(() =>
66 CInterface.peak_icv_Archive_CreateFromString(ref handle, (int) SerializationType.Json, buffer));
67
68 return new Archive(handle);
69 }
70
71 private static class CInterface
72 {
73 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
74 public static extern Backend.Types.peak_icv_status peak_icv_Archive_CreateFromString(
75 ref Archive.Handle archiveHandle,
76 int type, byte[] buffer);
77 }
78}
A key-value store that implements the IArchive interface.
Definition Archive.cs:39
Deserializer for reading serialized data and converting it into an IArchive object.
IArchive Read(Stream stream)
Reads serialized data from the specified stream and deserializes it into an archive.
SerializationType
Enumeration of supported serialization formats.
Represents a hierarchical, strongly-typed key-value archive.
Definition IArchive.cs:79
Interface for deserializing structured data from an input stream into an archive.