line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Print::Value; |
2
|
|
|
|
|
|
|
|
3
|
41
|
|
|
41
|
|
934210
|
use base qw(Exporter); |
|
41
|
|
|
|
|
223
|
|
|
41
|
|
|
|
|
3840
|
|
4
|
41
|
|
|
41
|
|
287
|
use strict; |
|
41
|
|
|
|
|
104
|
|
|
41
|
|
|
|
|
798
|
|
5
|
41
|
|
|
41
|
|
211
|
use warnings; |
|
41
|
|
|
|
|
116
|
|
|
41
|
|
|
|
|
1270
|
|
6
|
|
|
|
|
|
|
|
7
|
41
|
|
|
41
|
|
1103
|
use Error::Pure qw(err); |
|
41
|
|
|
|
|
23041
|
|
|
41
|
|
|
|
|
1648
|
|
8
|
41
|
|
|
41
|
|
396
|
use Readonly; |
|
41
|
|
|
|
|
114
|
|
|
41
|
|
|
|
|
1770
|
|
9
|
41
|
|
|
41
|
|
18335
|
use Wikibase::Datatype::Print::Value::Globecoordinate; |
|
41
|
|
|
|
|
132
|
|
|
41
|
|
|
|
|
1706
|
|
10
|
41
|
|
|
41
|
|
16229
|
use Wikibase::Datatype::Print::Value::Item; |
|
41
|
|
|
|
|
119
|
|
|
41
|
|
|
|
|
1668
|
|
11
|
41
|
|
|
41
|
|
17577
|
use Wikibase::Datatype::Print::Value::Monolingual; |
|
41
|
|
|
|
|
157
|
|
|
41
|
|
|
|
|
1635
|
|
12
|
41
|
|
|
41
|
|
17750
|
use Wikibase::Datatype::Print::Value::Property; |
|
41
|
|
|
|
|
145
|
|
|
41
|
|
|
|
|
1662
|
|
13
|
41
|
|
|
41
|
|
17612
|
use Wikibase::Datatype::Print::Value::Quantity; |
|
41
|
|
|
|
|
117
|
|
|
41
|
|
|
|
|
1686
|
|
14
|
41
|
|
|
41
|
|
17340
|
use Wikibase::Datatype::Print::Value::Sense; |
|
41
|
|
|
|
|
123
|
|
|
41
|
|
|
|
|
1722
|
|
15
|
41
|
|
|
41
|
|
17364
|
use Wikibase::Datatype::Print::Value::String; |
|
41
|
|
|
|
|
133
|
|
|
41
|
|
|
|
|
1810
|
|
16
|
41
|
|
|
41
|
|
18099
|
use Wikibase::Datatype::Print::Value::Time; |
|
41
|
|
|
|
|
160
|
|
|
41
|
|
|
|
|
12695
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(print); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = 0.12; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub print { |
23
|
45
|
|
|
45
|
1
|
17650
|
my ($obj, $opts_hr) = @_; |
24
|
|
|
|
|
|
|
|
25
|
45
|
100
|
|
|
|
234
|
if (! $obj->isa('Wikibase::Datatype::Value')) { |
26
|
1
|
|
|
|
|
6
|
err "Object isn't 'Wikibase::Datatype::Value'."; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
44
|
|
|
|
|
230
|
my $type = $obj->type; |
30
|
44
|
|
|
|
|
224
|
my $ret; |
31
|
44
|
100
|
|
|
|
355
|
if ($type eq 'globecoordinate') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
1
|
|
|
|
|
8
|
$ret = Wikibase::Datatype::Print::Value::Globecoordinate::print($obj, $opts_hr); |
33
|
|
|
|
|
|
|
} elsif ($type eq 'item') { |
34
|
17
|
|
|
|
|
83
|
$ret = Wikibase::Datatype::Print::Value::Item::print($obj, $opts_hr); |
35
|
|
|
|
|
|
|
} elsif ($type eq 'monolingualtext') { |
36
|
1
|
|
|
|
|
5
|
$ret = Wikibase::Datatype::Print::Value::Monolingual::print($obj, $opts_hr); |
37
|
|
|
|
|
|
|
} elsif ($type eq 'property') { |
38
|
1
|
|
|
|
|
6
|
$ret = Wikibase::Datatype::Print::Value::Property::print($obj, $opts_hr); |
39
|
|
|
|
|
|
|
} elsif ($type eq 'quantity') { |
40
|
1
|
|
|
|
|
8
|
$ret = Wikibase::Datatype::Print::Value::Quantity::print($obj, $opts_hr); |
41
|
|
|
|
|
|
|
} elsif ($type eq 'sense') { |
42
|
1
|
|
|
|
|
8
|
$ret = Wikibase::Datatype::Print::Value::Sense::print($obj, $opts_hr); |
43
|
|
|
|
|
|
|
} elsif ($type eq 'string') { |
44
|
17
|
|
|
|
|
93
|
$ret = Wikibase::Datatype::Print::Value::String::print($obj, $opts_hr); |
45
|
|
|
|
|
|
|
} elsif ($type eq 'time') { |
46
|
4
|
|
|
|
|
21
|
$ret = Wikibase::Datatype::Print::Value::Time::print($obj, $opts_hr); |
47
|
|
|
|
|
|
|
} else { |
48
|
1
|
|
|
|
|
12
|
err "Type '$type' is unsupported."; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
43
|
|
|
|
|
377
|
return $ret; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding utf8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Wikibase::Datatype::Print::Value - Wikibase value pretty print helpers. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::Value qw(print); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SUBROUTINES |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C<print> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Construct pretty print output for L<Wikibase::Datatype::Value> |
79
|
|
|
|
|
|
|
object. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns string. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 ERRORS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
print(): |
86
|
|
|
|
|
|
|
Object isn't 'Wikibase::Datatype::Value'. |
87
|
|
|
|
|
|
|
Type '%s' is unsupported. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 EXAMPLE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=for comment filename=create_and_print_value.pl |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use strict; |
94
|
|
|
|
|
|
|
use warnings; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::Value; |
97
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Object. |
100
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Value::Item->new( |
101
|
|
|
|
|
|
|
'value' => 'Q123', |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Print. |
105
|
|
|
|
|
|
|
print Wikibase::Datatype::Print::Value::print($obj)."\n"; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Output: |
108
|
|
|
|
|
|
|
# Q123 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<Error::Pure>, |
113
|
|
|
|
|
|
|
L<Exporter>, |
114
|
|
|
|
|
|
|
L<Readonly>, |
115
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Globecoordinate>, |
116
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Item>, |
117
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Monolingual>, |
118
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Property>, |
119
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Quantity>, |
120
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Sense>, |
121
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::String>, |
122
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Time>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SEE ALSO |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Value> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Wikibase value datatype. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 REPOSITORY |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHOR |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<http://skim.cz> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
BSD 2-Clause License |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 VERSION |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
0.12 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |