| 1 | package Hessian::Serializer::String; | ||
| 2 | |||
| 3 | 33 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 35 | ▶ | sub write_chunk { #{{{ |
|
Subroutine
write_chunk: called CC=1 SCAR=0.0
Pod
documented
| |||
| 6 | 35 | my $string = shift; | |
| 7 | 35 | my $hessian_message = pack 'n/a*', $string; | |
| 8 | 35 | return $hessian_message; | |
| 9 | } | ||
| 10 | |||
| 11 | 35 | ▶ | sub write_string { #{{{ |
|
Subroutine
write_string: called CC=1 SCAR=0.0
Pod
documented
| |||
| 12 | 35 | my ($self, $params) = @_; | |
| 13 | 35 | my $prefixes = {}; | |
| 14 | 35 | @{$prefixes}{qw/prefix last_prefix/} | |
| 15 | = ($self->string_chunk_prefix(), $self->string_final_chunk_prefix()); | ||
| 16 | 35 | my @string_chunks = @{ $params->{chunks} }; | |
| 17 | 35 | my $message = $self->hessianify_chunks( $prefixes, @string_chunks ); | |
| 18 | 35 | return join "" => @{$message}; | |
| 19 | } | ||
| 20 | |||
| 21 | 0 | ▶ | sub write_xml { #{{{ |
|
Subroutine
write_xml: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 22 | 0 | my ($self, $params) = @_; | |
| 23 | |||
| 24 | 0 | my @xml_chunks = @{ $params->{chunks} }; | |
| 25 | 0 | my $message = | |
| 26 | $self->hessianify_chunks( | ||
| 27 | { prefix => 'x', last_prefix => 'X' }, | ||
| 28 | @xml_chunks | ||
| 29 | ); | ||
| 30 | 0 | return join "" => @{$message}; | |
| 31 | } | ||
| 32 | |||
| 33 | 0 | ▶ | sub write_packet { #{{{ |
|
Subroutine
write_packet: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 34 | 0 | my ($self, $params) = @_; | |
| 35 | 0 | my @packets = @{ $params->{packets}}; | |
| 36 | 0 | my $message = | |
| 37 | $self->hessianify_chunks({ | ||
| 38 | prefix => "\x4f", last_prefix => "P" | ||
| 39 | }, @packets); | ||
| 40 | 0 | return $message; | |
| 41 | } | ||
| 42 | |||
| 43 | 35 | ▶ | sub hessianify_chunks { #{{{ |
|
Subroutine
hessianify_chunks: called CC=1 SCAR=0.0
Pod
documented
| |||
| 44 | 35 | my ($self, $prefixes, @chunks ) = @_; | |
| 45 | 35 | my $last_chunk = pop @chunks; | |
| 46 | 35 | my $prefix = $prefixes->{prefix}; | |
| 47 | my @message = map { | ||
| 48 | 0 | ( $prefixes->{prefix} ) . write_chunk($_); | |
| 49 | } | ||
| 50 | @chunks[ 0 .. ( $#chunks ) ]; | ||
| 51 | 35 | my $last_prefix = $prefixes->{last_prefix}; | |
| 52 | 35 | my $processed_last_chunk = ($last_prefix . write_chunk($last_chunk)); | |
| 53 | 35 | push @message, $processed_last_chunk; | |
| 54 | 35 | return \@message; | |
| 55 | } | ||
| 56 | |||
| 57 | 33 | "one, but we're not the same"; | |
| 58 | |||
| 59 | __END__ | ||