Skip to content

Commit

Permalink
Item10009: a little more docco now
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@12339 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Aug 19, 2011
1 parent 6fc6b84 commit 88e8faf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
46 changes: 39 additions & 7 deletions core/lib/Foswiki/Serialise.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,62 @@ use strict;
use warnings;
use Foswiki ();

=begin TML
---+ package Foswiki::Serialise
API to allow structures to be serialised and de-serialized. This API will only return
basic types like hashes and arrarys
=cut

#lets only load the serialiser once per execution
our %serialisers = ();

#should this really be a register/request?


=begin TML
---++ StaticMethod serialise( $session, $value, $style ) -> $cereal
* =$session= Foswiki Session object
* =$value= the perl object we're serializing (typically a ref/obj)
* =$style= serialization format
#TODO: do we need to use Foswiki, or can we throw a Simple exception instead?
#I think to be reusable we catually have to throw..
=cut

sub serialise {
my $session = shift;
my $result = shift;
my $value = shift;
my $style = shift;

my $data = getSerialiser( $session, $style )->write( $session, $result );
return $data;
return getSerialiser( $session, $style )->write( $session, $value );
}

#TODO: ok, ugly, and incomplete

=begin TML
---++ StaticMethod deserialise( $session, $cereal, $style ) -> $data
* =$session= Foswiki Session object
* =$cereal= the perl object we're serializing (typically a ref/obj)
* =$style= serialization format
#TODO: do we need to use Foswiki, or can we throw a Simple exception instead?
#I think to be reusable we actually have to throw..
#TODO: please work out how to add _some_ autodetection of format
=cut

sub deserialise {
my $session = shift;
my $result = shift;
my $cereal = shift;
my $style = shift;

my $data = getSerialiser( $session, $style )->read( $session, $result );
return $data;
return getSerialiser( $session, $style )->read( $session, $cereal );
}

#in the event of trouble, return 'Simplified'
Expand Down
2 changes: 2 additions & 0 deletions core/lib/Foswiki/Serialise/Embedded.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
This is __the__ on disk format serialiser and deserialise for TWiki and Foswiki topics legacy .txt format.
__WARNING__ this is only for Foswiki::Meta objects.
=cut

package Foswiki::Serialise::Embedded;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Serialise/Json.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
---+ package Foswiki::Serialise::Json
serialise from and to JSON
=cut

Expand Down
4 changes: 3 additions & 1 deletion core/lib/Foswiki/Serialise/Perl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
---+ package Foswiki::Serialise::Perl
This is __the__ on disk format serialiser and deserialise for TWiki and Foswiki topics legacy .txt format.
This is a Data::Dumper style
#TODO: rename?
=cut

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Serialise/Simplified.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
---+ package Foswiki::Serialise::Simplified
This is __the__ on disk format serialiser and deserialise for TWiki and Foswiki topics legacy .txt format.
This is the style=perl serialiseation used by System.VarQUERY
=cut

Expand Down

0 comments on commit 88e8faf

Please sign in to comment.