line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: Serialize to mixied XML and JSON |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
#$Id$ |
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Flow::To::JXML - serialize flow to JSON+XML |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my ( $s, $s1 ); |
15
|
|
|
|
|
|
|
my $f1 = Flow::create_flow( |
16
|
|
|
|
|
|
|
Splice => 200, |
17
|
|
|
|
|
|
|
Join => { |
18
|
|
|
|
|
|
|
Data => Flow::create_flow( |
19
|
|
|
|
|
|
|
sub { |
20
|
|
|
|
|
|
|
return [ grep { $_ > 10 } @_ ]; |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
Splice => 10 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
), |
25
|
|
|
|
|
|
|
Min => Flow::create_flow( |
26
|
|
|
|
|
|
|
sub { |
27
|
|
|
|
|
|
|
return [ grep { $_ == 1 } @_ ]; |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
Splice => 40, |
30
|
|
|
|
|
|
|
) |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
ToJXML => \$s, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
$f1->run( 1, 3, 11 ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Flow::To::JXML - serialize flow to JSON+XML |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package Flow::To::JXML; |
43
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
66
|
|
44
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
45
|
2
|
|
|
2
|
|
1479
|
use JSON; |
|
2
|
|
|
|
|
14839
|
|
|
2
|
|
|
|
|
11
|
|
46
|
2
|
|
|
2
|
|
262
|
use Flow::To::XML; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
47
|
2
|
|
|
2
|
|
10
|
use base 'Flow::To::XML'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
430
|
|
48
|
|
|
|
|
|
|
sub flow { |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $xfl = $self->{_xml_flow}; |
51
|
0
|
|
|
|
|
|
$xfl->startTag("flow"); |
52
|
0
|
|
|
|
|
|
$xfl->_get_writer->cdata(JSON->new->utf8->pretty(1)->encode(\@_)); |
53
|
0
|
|
|
|
|
|
$xfl->endTag("flow"); |
54
|
0
|
|
|
|
|
|
return $self->Flow::flow(@_) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub ctl_flow { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $xfl = $self->{_xml_flow}; |
61
|
0
|
|
|
|
|
|
$xfl->startTag("ctl_flow"); |
62
|
0
|
|
|
|
|
|
$xfl->_get_writer->cdata(encode_json(\@_)); |
63
|
0
|
|
|
|
|
|
$xfl->endTag("ctl_flow"); |
64
|
0
|
|
|
|
|
|
return $self->Flow::ctl_flow(@_) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |