/[Sack]/trunk/lib/Sack/Digest.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Sack/Digest.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88 - (show annotations)
Wed Sep 30 19:53:12 2009 UTC (14 years, 9 months ago) by dpavlin
File size: 880 byte(s)
added sync stub
1 package Sack::Digest;
2
3 use warnings;
4 use strict;
5
6 use Digest::MD5 qw(md5);
7 use Exporter;
8
9 our $debug = 0;
10 our $port = '?';
11
12 our @EXPORT = qw($debug $port);
13
14 sub new {
15 my $class = shift;
16 my $self = bless {@_}, $class;
17 die "no port" unless defined $self->{port};
18 $port = $self->{port};
19
20 $self->clean if $self->{clean};
21
22 $self->open if $self->can('open');
23
24 return $self;
25 }
26
27
28 sub to_int { die "need implementation" }
29 sub from_int { die "need implementation" }
30
31 sub sync { warn "# sync stub" }
32
33 sub undigest_out {
34 my ( $self, $out ) = @_;
35
36 foreach my $k1 ( grep { m/#/ } keys %$out ) {
37 my @k2 = keys %{ $out->{$k1} };
38 foreach my $k2 ( @k2 ) {
39 my $v = delete $out->{$k1}->{$k2};
40 # warn "## k2 $k2 = $v";
41 $out->{$k1}->{ $self->from_int($k2) } = $v;
42 }
43 }
44
45 return $out;
46 }
47
48
49 sub undigest_node_k_v {
50 my ( $self, $node, $k, $v ) = @_;
51 $self->from_int( $v );
52 }
53
54 1;

  ViewVC Help
Powered by ViewVC 1.1.26