line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# string::xml Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::String::Xml; |
7
|
1
|
|
|
1
|
|
777
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik::System::Package); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
376
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable encode decode) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
commands => { |
19
|
|
|
|
|
|
|
install => [ ], # Inherited |
20
|
|
|
|
|
|
|
encode => [ qw($data_hash) ], |
21
|
|
|
|
|
|
|
decode => [ qw($data) ], |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
require_modules => { |
24
|
|
|
|
|
|
|
'XML::Simple' => [ ], |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
need_packages => { |
27
|
|
|
|
|
|
|
ubuntu => [ qw(libexpat1-dev libxml2-dev) ], |
28
|
|
|
|
|
|
|
debian => [ qw(libexpat1-dev libxml2-dev) ], |
29
|
|
|
|
|
|
|
kali => [ qw(libexpat1-dev libxml2-dev) ], |
30
|
|
|
|
|
|
|
freebsd => [ qw(expat libxml2) ], |
31
|
|
|
|
|
|
|
centos => [ qw(expat-devel libxml2-devel) ], |
32
|
|
|
|
|
|
|
redhat => [ qw(expat-devel libxml2-devel) ], |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub encode { |
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
39
|
0
|
|
|
|
|
|
my ($data) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('encode', $data) or return; |
42
|
0
|
0
|
|
|
|
|
$self->brik_help_run_invalid_arg('encode', $data, 'HASH') or return; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $xs = XML::Simple->new; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->log->debug("encode: data[$data]"); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $xs->XMLout($data); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub decode { |
52
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
my ($data) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('decode', $data) or return; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $xs = XML::Simple->new; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->log->debug("decode: data[$data]"); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $xs->XMLin($data); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |