File: GenericHashSerializer.pm

package info (click to toggle)
libsoap-perl 0.23-1.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 192 kB
  • ctags: 158
  • sloc: perl: 1,886; makefile: 35
file content (76 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package SOAP::GenericHashSerializer;

use strict;
use vars qw($VERSION);
use SOAP::Defs;

$VERSION = '0.23';

sub new {
    my ($class, $hash) = @_;
    
    my $self = {
        hash => $hash,
    };
    bless $self, $class;
}

my $g_intrusive_hash_keys = {
    $soapperl_intrusive_hash_key_typeuri  => undef,
    $soapperl_intrusive_hash_key_typename => undef,
};

sub serialize {
    my ($self, $stream) = @_;

    my $hash = $self->{hash};

    while (my ($k, $v) = each %$hash) {
        next if exists $g_intrusive_hash_keys->{$k};
        if (ref $v) {
            $stream->reference_accessor(undef, $k, $v);
        }
        else {
            $stream->simple_accessor(undef, $k, undef, undef, $v);
        }
    }
}

sub get_typeinfo {
    my $self = shift;
    my $hash = $self->{hash};

    my $typeuri  = exists $hash->{$soapperl_intrusive_hash_key_typeuri} ?
                          $hash->{$soapperl_intrusive_hash_key_typeuri} : undef;

    my $typename = exists $hash->{$soapperl_intrusive_hash_key_typename} ?
                          $hash->{$soapperl_intrusive_hash_key_typename} : undef;

    ($typeuri, $typename);
}

sub is_package {
    0;
}

sub get_accessor_type {
    $soapperl_accessor_type_compound;
}

1;
__END__


=head1 NAME

SOAP::GenericHashSerializer - Generic serializer for Perl hashes

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 AUTHOR

Keith Brown

=cut