# ./library/serialize/serializer.tcl

## Package/File Information

No package provided/required
Defined Objects/Classes:

- Serializer: all, deepSerialize, exportMethods, methodSerialize, serialize.

Filename: ./library/serialize/serializer.tcl

Description: | This package provides the class Serializer, which can be used to generate a snapshot of the current state of the workspace in the form of XOTcl source code.
Authors: | Gustaf Neumann, Gustaf.Neumann@wu-wien.ac.at

## Class: Serializer

Procs/Instprocs: all, deepSerialize, exportMethods, methodSerialize, serialize.

### Instprocs

- serialize entity

  Arguments: | entity: Object or Class
  Description: | Serialize the specified object or class.
  Return: | Object or Class with all currently defined methods, variables, invariants, filters and mixins

### Procs

- all ?-ignoreVarsRE RE? ?-ignore obj1 obj2 ...?

  Arguments: | ?-ignoreVarsRE RE?: provide regular expression; matching vars are ignored
  | ?-ignore obj1 obj2 ...?: provide a list of objects to be omitted
  Description: | Serialize all objects and classes that are currently defined (except the specified omissions and the current Serializer object). Examples:
      Serializer all -ignoreVarsRE {::b$}
  Do not serialize any instance variable named b (of any object).
      Serializer all -ignoreVarsRE {^::o1::.*text.*$|^::o2::x$}
  Do not serialize any variable of c1 whose name contains the string "text" and do not serialze the variable x of o2.
      Serializer all -ignore obj1 obj2 ...
  do not serizalze the specified objects
  Return: | script

- deepSerialize ?-ignoreVarsRE RE? ?-ignore obj1 obj2 ...? ?-map list? objs

  Arguments: | ?-ignoreVarsRE RE?: provide regular expression; matching vars are ignored
  | ?-ignore obj1 obj2 ...?: provide a list of objects to be omitted
  | ?-map list?: translate object names in serialized code
  | objs: Objects to be serialized
  Description: | Serialize object with all child objects (deep operation) except the specified omissions. For the description of `ignore` and `ignoreVarsRE` see `Serizalizer all`. `map` can be used in addition to provide pairs of old-string and new-string (like in the tcl command `string map`). This option can be used to regenerate the serialized object under a different object or under a different name, or to translate relative object names in the serialized code.

  Examples:

      Serializer deepSerialize -map {::a::b ::x::y} ::a::b::c

  Serialize the object `c` which is a child of `a::b`; the object will be reinitialized as object `::x::y::c`, all references `::a::b` will be replaced by `::x::y`.

      Serializer deepSerialize -map {::a::b [self]} ::a::b::c

  The serizalized object can be reinstantiated under some current object, under which the script is evaluated.

      Serializer deepSerialize -map {::a::b::c ${var} ::a::b::c}

  The serizalized object will be reinstantiated under a name specified by the variable `var`in the recreation context.``
  Return: | script

- methodSerialize object method prefix

  Arguments: | object: object or class
  | method: name of method
  | prefix: either empty or 'inst' (latter for instprocs)
  Description: | Serialize the specified method. In order to serialize an instproc, `prefix` should be 'inst'; to serialze procs, it should be empty. Examples:
      Serializer methodSerialize Serializer deepSerialize ""
  This command serializes the proc `deepSerialize` of the Class `Serializer`.
      Serializer methodSerialize Serializer serialize inst
  This command serializes the instproc `serialize` of the Class `Serializer`.
  Return: | Script, which can be used to recreate the specified method

- exportMethods list

  Arguments: | list: list of methods of the form 'object proc|instproc methodname'
  Description: | This method can be used to specify methods that should be exported in every `Serializer all`. The rationale behind this is that the serializer does not serialize objects from the namespaces of the basic object systems, which are used for the object system internals and volatile objects. TODO It is however often useful to define methods on ::xotcl::Class or ::xotcl::Objects, which should be exported. One can export procs, instprocs, forward and instforward

  Example:

            Serializer exportMethods {
      	::xotcl::Object instproc __split_arguments
      	::xotcl::Object instproc __make_doc
      	::xotcl::Object instproc ad_proc
      	::xotcl::Class  instproc ad_instproc
      	::xotcl::Object forward  expr
            }

Back to index page.