Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
OpenXPKI::SerializatioUseriContributed Perl OpenXPKI::Serialization::Simple(3)

Name
       OpenXPKI::Serialization::Simple

Description
       Really simple serialization class for scalars, arrays and hashes.  This
       is a platform neutral example implementation. It	mainly demonstrates
       the interface and can easily be ported to other scripting languages.

Functions
   new
       Initializes the object.

   serialize
       Returns the serialization of data passed	as argument.

   deserialize
       Returns the deserialization of data passed as argument.

   is_serialized (static!)
       This checks if a	given argument is a serialized string. This method is
       static!

Internal Functions
   Serialization
       __write_data

       This function returns the serialization of data passed as argument by
       calling one or more of the following functions. Each of those functions
       serializes a specific data type according to the	syntax (see below). An
       exception is thrown if the data type cannot be recognized.

       __write_scalar

       __write_array

       __write_hash

       __write_undef

   Deserialization
       __read_data

       This function returns the deserialization of data passed	as argument by
       calling one or more of the following functions. Each of those functions
       deserializes a specific data type according to the syntax (see below).
       An exception is thrown if the data type cannot be recognized.

       Basically, the deserialization works as follows:	While scalars and
       undefs are easily deserialized upon recognition,	it's a bit more	tricky
       with arrays and hashes. Since they can possibly contain more (complex)
       data, each of the functions below returns two values: "$data" holds the
       deserialized data, and "$returnmessage" returns the (serialized)	string
       that was	used to	deserialize the	data. The latter value is important to
       keep track of which part	of the serialized string has already been
       deserialized.

       __read_scalar

       __read_array

       __read_hash

       __read_undef

Syntax
       We support scalars, array references and	hash references	in any
       combination. The	syntax is the following	one:

       scalar	     ::= 'SCALAR'.SEPARATOR.
			 [0-9]+.SEPARATOR. /* length of	data */
			 data.SEPARATOR

       array	     ::= 'ARRAY'.SEPARATOR.
			 [0-9]+.SEPARATOR. /* length of	array data */
			 array_element+

       array_element ::= [0-9]+.SEPARATOR. /* position in the array */
			 (hash|array|scalar)

       hash	     ::= 'HASH'.SEPARATOR.
			 [0-9]+.SEPARATOR. /* length of	hash data */
			 hash_element+

       hash_element  ::= [1-9][0-9]*.SEPARATOR.	   /* length of	the hash key
       */
			 [a-zA-Z0-9_]+.SEPARATOR.  /* the hash key */
			 (hash|array|undef|scalar)

       undef	     ::= 'UNDEF'.SEPARATOR.

       The SEPARATOR is	one character long. It can be any non number.  The
       default separator is newline. The important thing is that you can parse
       every structure without knowing the used	SEPARATOR.

       Perhaps the good	mathmatics notice that the last	SEPARATOR in the
       definition of a scalar is not necessary.	This SEPARATOR is only used to
       make the	resulting structure better readable for	humans.

perl v5.24.1			  2017-07-03OpenXPKI::Serialization::Simple(3)

Name | Description | Functions | Internal Functions | Syntax

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=OpenXPKI::Serialization::Simple&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help