| 1 | package RPC::Lite::Serializer; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use RPC::Lite::Request; | ||
| 6 | use RPC::Lite::Response; | ||
| 7 | use RPC::Lite::Notification; | ||
| 8 | use RPC::Lite::Error; | ||
| 9 | |||
| 10 | =pod | ||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | RPC::Lite::Serializer -- Base class for RPC::Lite::Serializers. | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | RPC::Lite::Serializer outlines the basic functionality any serializer | ||
| 19 | must implement. | ||
| 20 | |||
| 21 | =head1 METHODS | ||
| 22 | |||
| 23 | =over 4 | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | =pod | ||
| 28 | |||
| 29 | =item C<new> | ||
| 30 | |||
| 31 | Creates a new serializer object. | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | sub new | ||
| 36 | { | ||
| 37 | my $class = shift; | ||
| 38 | my $self = {}; | ||
| 39 | bless $self, $class; | ||
| 40 | } | ||
| 41 | |||
| 42 | =pod | ||
| 43 | |||
| 44 | =item C<VersionSupported( $version )> | ||
| 45 | |||
| 46 | Returns a boolean indicating whether the given serialization version is | ||
| 47 | supported. | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | sub VersionSupported | ||
| 52 | { | ||
| 53 | die( "Unimplemented virtual function!" ); | ||
| 54 | } | ||
| 55 | |||
| 56 | =pod | ||
| 57 | |||
| 58 | =item C<GetVersion> | ||
| 59 | |||
| 60 | Returns the current version of the serializer. | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | sub GetVersion | ||
| 65 | { | ||
| 66 | die( "Unimplemented virtual function!" ); | ||
| 67 | } | ||
| 68 | |||
| 69 | =pod | ||
| 70 | |||
| 71 | =item C<Serialize( $data )> | ||
| 72 | |||
| 73 | Takes a reference to an object and serializes it, returning the result. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | sub Serialize | ||
| 78 | { | ||
| 79 | die( "Unimplemented virtual function!" ); | ||
| 80 | } | ||
| 81 | |||
| 82 | =pod | ||
| 83 | |||
| 84 | =item C<Deserialize( $data )> | ||
| 85 | |||
| 86 | Takes serialized data and returns a deserialized object. | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | sub Deserialize | ||
| 91 | { | ||
| 92 | die( "Unimplemented virtual function!" ); | ||
| 93 | } | ||
| 94 | |||
| 95 | =pod | ||
| 96 | |||
| 97 | =back | ||
| 98 | |||
| 99 | =head1 NOTE | ||
| 100 | |||
| 101 | RPC::Lite::Servers automatically instantiate any of the supported serializers | ||
| 102 | as necessary to communicate with clients. | ||
| 103 | |||
| 104 | =head1 SUPPORTED SERIALIZERS | ||
| 105 | |||
| 106 | =over 4 | ||
| 107 | |||
| 108 | =item JSON (client default) | ||
| 109 | |||
| 110 | "JSON (JavaScript Object Notation) is a lightweight data-interchange format. | ||
| 111 | It is easy for humans to read and write. It is easy for machines to parse | ||
| 112 | and generate. It is based on a subset of the JavaScript Programming Language, | ||
| 113 | Standard ECMA-262 3rd Edition - December 1999." | ||
| 114 | -- http://www.json.org/ | ||
| 115 | |||
| 116 | =item XML | ||
| 117 | |||
| 118 | "Extensible Markup Language (XML) is a simple, very flexible text format | ||
| 119 | derived from SGML (ISO 8879). Originally designed to meet the challenges | ||
| 120 | of large-scale electronic publishing, XML is also playing an increasingly | ||
| 121 | important role in the exchange of a wide variety of data on the Web and elsewhere." | ||
| 122 | -- http://www.w3.org/XML/ | ||
| 123 | |||
| 124 | =item Null | ||
| 125 | |||
| 126 | The Null serializer is for communicating with native perl RPC::Lite servers | ||
| 127 | on the same machine. It does nothing (and is largely untested, its use is | ||
| 128 | not currently recommended unless you are a developer wishing to improve it). | ||
| 129 | |||
| 130 | =back | ||
| 131 | |||
| 132 | =cut | ||
| 133 | |||
| 134 | 1; |