module Oomarshal: sig
.. end
Object-oriented marshalling support.
This module contains two distinct marshalling facilities.
val flags : 'a list
Marshalling flags: we want to support sharing but no closures.
An intuitive but unsafe marshalling facility
The abstract superclass of any marshallable object. Objects can be safely
marshalled via methods, but unmarshalling produces results of unconstrained
polymorphic types, which must be manually cast by the user.
class virtual marshallable :
object
.. end
The virtual marshallable class, which should be the base class of all
classes intended for marshalling with this technique.
val from_string : string -> 'a
Unmarshal (what we hope to be) a marshallable
object from the given
string, and return the object with an unconstrained polymorphic
type.
val from_channel : Pervasives.in_channel -> 'a
Unmarshal (what we hope to be) a marshallable
object from the given
channel, and return the object with an unconstrained polymorphic
type.
val from_file : string -> 'a
Unmarshal (what we hope to be) a marshallable
object from the given
file, and return the object with an unconstrained polymorphic
type.
An uglier but safe marshalling facility
This implementation uses casts only internally, but requires the creation
of a marshaller object which serves the single purpose of marshalling and
unmarshalling the objects it's given, without keeping any internal state;
all of this is, put honestly, quite ugly.
Marshallers for non-object types are also supported.
The marshaller type is correctly inferred.
class ['a]
marshaller :
object
.. end
The marshaller class, instances of which can marshal and unmarshal objects
of a given type when requested.
A small example
let m = new marshaller;;
print_float (m#from_string (m#to_string 3.2));;