How can I serialize and deserialize a private type?

Jack M

I'm working with the GNAT.OS_Lib module to implement a process manager for Linux. I'm using the subprograms in that module to spawn processes and get back PIDs, and now I want to save those PIDs to a file so they can be retrieved later to kill the process, get its status, etc. The problem is, the Process_Id type is private:

type Process_Id is private; -- s-os_lib.ads, line 743

The module provides a Pid_To_Integer function, but not the inverse. How can I serialize and deserialize Process_Ids?

Jim Rogers

Study section K.2 "Language Defined Attributes" in the Ada Language Reference Manual http://www.ada-auth.org/standards/12rm/html/RM-K-2.html

The attributes to study are S'Read, S'Write.

Your file must be created as a stream file. The Process_Id'Write attribute will serialize and write to the stream file. The Process_Id'Read attribute will read and de-serialize the data in the file.

If S'Read and S'Write do not work for you because of the nature of a compound type you should use the S'Input and S'Output attributes, which will read and write any bounds or discriminants.

S'Input and S'Output will work correctly with all types.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I serialize and deserialize a type with a string member that contains "raw" JSON, without escaping the JSON in the process

How do I, using XStream, serialize/deserialize objects in a type hierarchy?

How can I serialize and deserialize components in Vaadin Flow 14?

How can I serialize and deserialize a JVM object to a String?

Can I serialize/deserialize System Types to XML?

How to serialize/deserialize "splashed" complex type?

How to serialize/deserialize an ArrayList and properties that are of an Object type

How do I serialize & deserialize CSV properly?

How could I serialize/deserialize complex objects in Typescript such as the deserialized object is of the same type as the object that was serialized

How can I serialize/deserialize a dictionary with custom keys using Json.Net?

How can I serialize/deserialize a Proto object to a local storage in Android project?

How can i deserialize and serialize complex json data bu Newton json?

How can I serialize/deserialize a kind of json mixing object and list of object at the same level in c#?

Can I serialize a subset of fields and use a function to deserialize the other fields without manually implementing Serialize or Deserialize?

How can I deserialize JSON when the object type is not known beforehand?

Can I serialize a closure to Vec<u8> then deserialize and execute it?

Can I serialize a struct camel_case and deserialize PascalCase in Rust

How to serialize and deserialize a Hashtable?

How to Serialize and Deserialize a Type class object in C# into YAML?

How can we serialize & deserialize a Haskell Data Struct to Bytestring?

How can I serialize an interface?

How do I serialize and deserialize a remote crate's enum as a number?

How do I serialize / deserialize a class in XML with Woodstox StAX 2

How do I serialize or deserialize an Arc<T> in Serde?

How I can deserialize this json?

How can I make Json.NET serialize and deserialize declared properties of custom dynamic types that also implement IDictionary<string, object>?

how to serialize/deserialize arrayList(Object)

how to serialize/deserialize a map in go

How to serialize and deserialize an object as a string?