line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###############################################################################
|
2
|
|
|
|
|
|
|
#Value.pm
|
3
|
|
|
|
|
|
|
#Last Change: 2009-01-19
|
4
|
|
|
|
|
|
|
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
|
5
|
|
|
|
|
|
|
#Version 0.8
|
6
|
|
|
|
|
|
|
####################
|
7
|
|
|
|
|
|
|
#This file is part of the Dotiac::DTL project.
|
8
|
|
|
|
|
|
|
#http://search.cpan.org/perldoc?Dotiac::DTL
|
9
|
|
|
|
|
|
|
#
|
10
|
|
|
|
|
|
|
#Value.pm is published under the terms of the MIT license, which basically
|
11
|
|
|
|
|
|
|
#means "Do with it whatever you want". For more information, see the
|
12
|
|
|
|
|
|
|
#license.txt file that should be enclosed with libsofu distributions. A copy of
|
13
|
|
|
|
|
|
|
#the license is (at the time of writing) also available at
|
14
|
|
|
|
|
|
|
#http://www.opensource.org/licenses/mit-license.php .
|
15
|
|
|
|
|
|
|
###############################################################################
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Dotiac::DTL::Value;
|
18
|
12
|
|
|
12
|
|
59
|
use strict;
|
|
12
|
|
|
|
|
36
|
|
|
12
|
|
|
|
|
454
|
|
19
|
12
|
|
|
12
|
|
63
|
use warnings;
|
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
35499
|
|
20
|
|
|
|
|
|
|
require Scalar::Util;
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = 0.8;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new {
|
25
|
3815
|
|
|
3815
|
1
|
5283
|
my $class=shift;
|
26
|
3815
|
|
|
|
|
4463
|
my $data=shift;
|
27
|
3815
|
|
|
|
|
4854
|
my $safe=shift;
|
28
|
3815
|
100
|
|
|
|
7664
|
$safe=0 unless $safe;
|
29
|
3815
|
100
|
|
|
|
7341
|
$safe=1 if $safe;
|
30
|
3815
|
|
|
|
|
7425
|
my $r=Scalar::Util::reftype($data);
|
31
|
3815
|
100
|
|
|
|
8609
|
$r="" unless $r;
|
32
|
3815
|
100
|
|
|
|
20032
|
my $self=[$data,$safe,$r,Scalar::Util::blessed($data),($r?0:Scalar::Util::looks_like_number($data))];
|
33
|
3815
|
|
|
|
|
9342
|
bless $self,$class;
|
34
|
3815
|
|
|
|
|
14620
|
return $self;
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub safe {
|
39
|
1721
|
|
|
1721
|
1
|
3604
|
my $self=shift;
|
40
|
1721
|
100
|
|
|
|
5769
|
return Dotiac::DTL::Value->new(shift(@_),1) unless ref $self;
|
41
|
80
|
50
|
66
|
|
|
247
|
if (@_ and $_[0]) {
|
42
|
48
|
|
|
|
|
74
|
$self->[1]=1;
|
43
|
|
|
|
|
|
|
}
|
44
|
80
|
|
|
|
|
180
|
return $self->[1];
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub escape {
|
48
|
92
|
|
|
92
|
1
|
132
|
my $self=shift;
|
49
|
92
|
100
|
|
|
|
261
|
return Dotiac::DTL::Value->new(shift(@_),0) unless ref $self;
|
50
|
84
|
50
|
33
|
|
|
306
|
if (@_ and $_[0]) {
|
51
|
84
|
|
|
|
|
132
|
$self->[1]=0;
|
52
|
|
|
|
|
|
|
}
|
53
|
84
|
|
|
|
|
188
|
return !$self->[1];
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub array {
|
57
|
312
|
|
|
312
|
1
|
1173
|
return $_[0]->[2] eq "ARRAY"
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub hash {
|
61
|
172
|
|
|
172
|
1
|
697
|
return $_[0]->[2] eq "HASH"
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub object {
|
65
|
386
|
|
|
386
|
1
|
1747
|
return !(!$_[0]->[3]);
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub number {
|
69
|
404
|
|
|
404
|
1
|
1535
|
return $_[0]->[4];
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub undef {
|
73
|
3205
|
|
|
3205
|
1
|
12227
|
return !defined $_[0]->[0];
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub defined {
|
77
|
12
|
|
|
12
|
1
|
52
|
return defined $_[0]->[0];
|
78
|
|
|
|
|
|
|
}
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub scalar {
|
81
|
3227
|
0
|
|
3227
|
1
|
9209
|
return !$_[0]->[2] and defined $_[0]->[0];
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub true {
|
85
|
660
|
100
|
|
660
|
1
|
1963
|
return "" unless $_[0]->[0];
|
86
|
440
|
100
|
|
|
|
2674
|
return $_[0]->[0] unless $_[0]->[2];
|
87
|
112
|
50
|
66
|
|
|
308
|
return $_[0]->[0]->count() if $_[0]->[3] and $_[0]->[0]->can("count");
|
88
|
112
|
100
|
|
|
|
256
|
return 1 if $_[0]->[3];
|
89
|
108
|
100
|
|
|
|
235
|
return scalar @{$_[0]->[0]} if $_[0]->[2] eq "ARRAY";
|
|
52
|
|
|
|
|
193
|
|
90
|
56
|
100
|
|
|
|
117
|
return scalar keys %{$_[0]->[0]} if $_[0]->[2] eq "HASH";
|
|
52
|
|
|
|
|
223
|
|
91
|
4
|
|
|
|
|
9
|
return 1;
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub get {
|
95
|
0
|
|
|
0
|
1
|
0
|
return $_[0]->[0];
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub content {
|
99
|
706
|
|
|
706
|
1
|
3080
|
return $_[0]->[0];
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#Recursive string rendering
|
103
|
|
|
|
|
|
|
sub str {
|
104
|
68
|
|
|
68
|
1
|
88
|
my $data=shift;
|
105
|
68
|
|
|
|
|
70
|
my $level=shift;
|
106
|
68
|
50
|
|
|
|
122
|
return unless $level;
|
107
|
68
|
50
|
|
|
|
117
|
if (not defined $data) {
|
108
|
0
|
|
|
|
|
0
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID;
|
109
|
|
|
|
|
|
|
}
|
110
|
68
|
50
|
|
|
|
120
|
if (not ref $data) {
|
111
|
68
|
|
|
|
|
232
|
return $data;
|
112
|
|
|
|
|
|
|
}
|
113
|
0
|
0
|
|
|
|
0
|
if (Scalar::Util::blessed($data)) {
|
114
|
0
|
0
|
|
|
|
0
|
return $data->string() if $data->can("string");
|
115
|
0
|
0
|
|
|
|
0
|
return $data->__str__() if $data->can("__str__");
|
116
|
0
|
0
|
|
|
|
0
|
return $data->ToString() if $data->can("ToString");
|
117
|
0
|
0
|
|
|
|
0
|
return $data->repr() if $data->can("repr");
|
118
|
0
|
0
|
|
|
|
0
|
return $data->__repr__() if $data->can("__repr__");
|
119
|
0
|
|
|
|
|
0
|
return $data;
|
120
|
|
|
|
|
|
|
}
|
121
|
0
|
0
|
0
|
|
|
0
|
if (Scalar::Util::reftype($data) eq "HASH" and $level > 1) {
|
122
|
0
|
|
|
|
|
0
|
return join(" ",map {str($data->{$_},$level-1)} sort keys %{$data});
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
123
|
|
|
|
|
|
|
}
|
124
|
0
|
0
|
0
|
|
|
0
|
if (Scalar::Util::reftype($data) eq "ARRAY" and $level > 1) {
|
125
|
0
|
|
|
|
|
0
|
return join(" ",map {str($_,$level-1)} @{$data});
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
126
|
|
|
|
|
|
|
}
|
127
|
0
|
|
|
|
|
0
|
return $data;
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub string {
|
131
|
2257
|
|
|
2257
|
1
|
2919
|
my $self=shift;
|
132
|
2257
|
|
|
|
|
3747
|
my $data=$self->[0];
|
133
|
2257
|
|
|
|
|
2629
|
my $value="Error";
|
134
|
2257
|
100
|
33
|
|
|
4292
|
if ($self->undef()) {
|
|
|
100
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
135
|
44
|
|
|
|
|
60
|
$value=$Dotiac::DTL::TEMPLATE_STRING_IF_INVALID;
|
136
|
44
|
|
|
|
|
69
|
$self->[1]=1;
|
137
|
|
|
|
|
|
|
}
|
138
|
|
|
|
|
|
|
elsif ($self->scalar()) {
|
139
|
2177
|
|
|
|
|
3176
|
$value=$data;
|
140
|
|
|
|
|
|
|
}
|
141
|
|
|
|
|
|
|
elsif ($self->object and $data->can("string")) {
|
142
|
0
|
|
|
|
|
0
|
$value=$data->string();
|
143
|
|
|
|
|
|
|
}
|
144
|
|
|
|
|
|
|
elsif ($self->object and $data->can("__str__")) {
|
145
|
0
|
|
|
|
|
0
|
return $data->__str__();
|
146
|
|
|
|
|
|
|
}
|
147
|
|
|
|
|
|
|
elsif ($self->object and $data->can("ToString")) {
|
148
|
0
|
|
|
|
|
0
|
return $data->ToString();
|
149
|
|
|
|
|
|
|
}
|
150
|
|
|
|
|
|
|
elsif ($self->object and $data->can("repr")) {
|
151
|
0
|
|
|
|
|
0
|
return $data->repr();
|
152
|
|
|
|
|
|
|
}
|
153
|
|
|
|
|
|
|
elsif ($self->object and $data->can("__repr__")) {
|
154
|
0
|
|
|
|
|
0
|
return $data->__repr__();
|
155
|
|
|
|
|
|
|
}
|
156
|
|
|
|
|
|
|
elsif ($self->array) {
|
157
|
36
|
50
|
|
|
|
77
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID unless $Dotiac::DTL::Max_Depth;
|
158
|
36
|
|
|
|
|
40
|
$value=join(" ",map {str($_,$Dotiac::DTL::Max_Depth)} @{$data});
|
|
68
|
|
|
|
|
113
|
|
|
36
|
|
|
|
|
56
|
|
159
|
|
|
|
|
|
|
}
|
160
|
|
|
|
|
|
|
elsif ($self->hash) {
|
161
|
0
|
0
|
|
|
|
0
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID unless $Dotiac::DTL::Max_Depth;
|
162
|
0
|
|
|
|
|
0
|
$value=join(" ",map {str($data->{$_},$Dotiac::DTL::Max_Depth)} sort keys %{$data});
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
163
|
|
|
|
|
|
|
}
|
164
|
2257
|
100
|
|
|
|
5762
|
unless ($self->[1]) {
|
165
|
1280
|
|
|
|
|
2204
|
$value=~s/&/&/g;
|
166
|
1280
|
|
|
|
|
1963
|
$value=~s/</g;
|
167
|
1280
|
|
|
|
|
1733
|
$value=~s/>/>/g;
|
168
|
1280
|
|
|
|
|
1495
|
$value=~s/\"/"/g;
|
169
|
1280
|
|
|
|
|
1786
|
$value=~s/\'/'/g;
|
170
|
|
|
|
|
|
|
}
|
171
|
2257
|
|
|
|
|
9558
|
return $value;
|
172
|
|
|
|
|
|
|
}
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#Recursive repr rendering
|
176
|
|
|
|
|
|
|
sub rep {
|
177
|
96
|
|
|
96
|
1
|
105
|
my $data=shift;
|
178
|
96
|
|
|
|
|
98
|
my $level=shift;
|
179
|
96
|
50
|
|
|
|
141
|
return unless $level;
|
180
|
96
|
50
|
|
|
|
164
|
if (not defined $data) {
|
181
|
0
|
|
|
|
|
0
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID;
|
182
|
|
|
|
|
|
|
}
|
183
|
96
|
50
|
|
|
|
166
|
if (not ref $data) {
|
184
|
96
|
|
|
|
|
221
|
return $data;
|
185
|
|
|
|
|
|
|
}
|
186
|
0
|
0
|
|
|
|
0
|
if (Scalar::Util::blessed($data)) {
|
187
|
0
|
0
|
|
|
|
0
|
return $data->string() if $data->can("string");
|
188
|
0
|
0
|
|
|
|
0
|
return $data->__str__() if $data->can("__str__");
|
189
|
0
|
0
|
|
|
|
0
|
return $data->ToString() if $data->can("ToString");
|
190
|
0
|
0
|
|
|
|
0
|
return $data->repr() if $data->can("repr");
|
191
|
0
|
0
|
|
|
|
0
|
return $data->__repr__() if $data->can("__repr__");
|
192
|
0
|
|
|
|
|
0
|
return $data;
|
193
|
|
|
|
|
|
|
}
|
194
|
0
|
0
|
0
|
|
|
0
|
if (Scalar::Util::reftype($data) eq "HASH" and $level > 1) {
|
195
|
0
|
|
|
|
|
0
|
return join(" ",map {rep($data->{$_},$level-1)} sort keys %{$data});
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
196
|
|
|
|
|
|
|
}
|
197
|
0
|
0
|
0
|
|
|
0
|
if (Scalar::Util::reftype($data) eq "ARRAY" and $level > 1) {
|
198
|
0
|
|
|
|
|
0
|
return join(" ",map {rep($_,$level-1)} @{$data});
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
199
|
|
|
|
|
|
|
}
|
200
|
0
|
|
|
|
|
0
|
return $data;
|
201
|
|
|
|
|
|
|
}
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub repr {
|
204
|
888
|
|
|
888
|
1
|
1124
|
my $self=shift;
|
205
|
888
|
|
|
|
|
1266
|
my $data=$self->[0];
|
206
|
888
|
50
|
33
|
|
|
1675
|
if ($self->undef()) {
|
|
|
100
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
207
|
0
|
|
|
|
|
0
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID;
|
208
|
|
|
|
|
|
|
}
|
209
|
|
|
|
|
|
|
elsif ($self->scalar()) {
|
210
|
872
|
|
|
|
|
3078
|
return $data;
|
211
|
|
|
|
|
|
|
}
|
212
|
|
|
|
|
|
|
elsif ($self->object and $data->can("string")) {
|
213
|
0
|
|
|
|
|
0
|
return $data->string();
|
214
|
|
|
|
|
|
|
}
|
215
|
|
|
|
|
|
|
elsif ($self->object and $data->can("__str__")) {
|
216
|
0
|
|
|
|
|
0
|
return $data->__str__();
|
217
|
|
|
|
|
|
|
}
|
218
|
|
|
|
|
|
|
elsif ($self->object and $data->can("ToString")) {
|
219
|
0
|
|
|
|
|
0
|
return $data->ToString();
|
220
|
|
|
|
|
|
|
}
|
221
|
|
|
|
|
|
|
elsif ($self->object and $data->can("repr")) {
|
222
|
0
|
|
|
|
|
0
|
return $data->repr();
|
223
|
|
|
|
|
|
|
}
|
224
|
|
|
|
|
|
|
elsif ($self->object and $data->can("__repr__")) {
|
225
|
0
|
|
|
|
|
0
|
return $data->__repr__();
|
226
|
|
|
|
|
|
|
}
|
227
|
|
|
|
|
|
|
elsif ($self->array) {
|
228
|
16
|
50
|
|
|
|
31
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID unless $Dotiac::DTL::Max_Depth;
|
229
|
16
|
|
|
|
|
17
|
return join(" ",map {rep($_,$Dotiac::DTL::Max_Depth)} @{$data});
|
|
96
|
|
|
|
|
142
|
|
|
16
|
|
|
|
|
27
|
|
230
|
|
|
|
|
|
|
}
|
231
|
|
|
|
|
|
|
elsif ($self->hash) {
|
232
|
0
|
0
|
|
|
|
0
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID unless $Dotiac::DTL::Max_Depth;
|
233
|
0
|
|
|
|
|
0
|
return join(" ",map {rep($data->{$_},$Dotiac::DTL::Max_Depth)} sort keys %{$data});
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
234
|
|
|
|
|
|
|
}
|
235
|
0
|
|
|
|
|
0
|
return $data;
|
236
|
|
|
|
|
|
|
}
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub pyrep {
|
240
|
12
|
|
|
12
|
1
|
16
|
my $data=shift;
|
241
|
12
|
|
|
|
|
10
|
my $level=shift;
|
242
|
12
|
50
|
|
|
|
25
|
return unless $level;
|
243
|
12
|
50
|
|
|
|
31
|
if (not defined $data) {
|
244
|
0
|
|
|
|
|
0
|
return "null";
|
245
|
|
|
|
|
|
|
}
|
246
|
12
|
50
|
|
|
|
22
|
if (not ref $data) {
|
247
|
12
|
50
|
|
|
|
35
|
return $data if Scalar::Util::looks_like_number($data);
|
248
|
12
|
|
|
|
|
44
|
return '"'.$data.'"';
|
249
|
|
|
|
|
|
|
}
|
250
|
0
|
0
|
|
|
|
0
|
if (Scalar::Util::blessed($data)) {
|
251
|
0
|
0
|
|
|
|
0
|
return $data->repr() if $data->can("repr");
|
252
|
0
|
0
|
|
|
|
0
|
return $data->__repr__() if $data->can("__repr__");
|
253
|
0
|
0
|
|
|
|
0
|
return $data->string() if $data->can("string");
|
254
|
0
|
0
|
|
|
|
0
|
return $data->__str__() if $data->can("__str__");
|
255
|
0
|
0
|
|
|
|
0
|
return $data->ToString() if $data->can("ToString");
|
256
|
0
|
|
|
|
|
0
|
return $data;
|
257
|
|
|
|
|
|
|
}
|
258
|
0
|
0
|
0
|
|
|
0
|
if (Scalar::Util::reftype($data) eq "HASH" and $level > 1) {
|
259
|
0
|
|
|
|
|
0
|
return "(".join(", ",map {"$_:".pyrep($data->{$_},$level-1)} sort keys %{$data}).")";
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
260
|
|
|
|
|
|
|
}
|
261
|
0
|
0
|
0
|
|
|
0
|
if (Scalar::Util::reftype($data) eq "ARRAY" and $level > 1) {
|
262
|
0
|
|
|
|
|
0
|
return "(".join(", ",map {pyrep($_,$level-1)} @{$data}).")";
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
263
|
|
|
|
|
|
|
}
|
264
|
0
|
|
|
|
|
0
|
return $data;
|
265
|
|
|
|
|
|
|
}
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub pyrepr {
|
268
|
4
|
|
|
4
|
1
|
7
|
my $self=shift;
|
269
|
4
|
|
|
|
|
10
|
my $data=$self->[0];
|
270
|
4
|
50
|
33
|
|
|
15
|
if ($self->undef()) {
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
271
|
0
|
|
|
|
|
0
|
return "null";
|
272
|
|
|
|
|
|
|
}
|
273
|
|
|
|
|
|
|
elsif ($self->number()) {
|
274
|
0
|
|
|
|
|
0
|
return $data;
|
275
|
|
|
|
|
|
|
}
|
276
|
|
|
|
|
|
|
elsif ($self->scalar()) {
|
277
|
0
|
|
|
|
|
0
|
return '"'.$data.'"';
|
278
|
|
|
|
|
|
|
}
|
279
|
|
|
|
|
|
|
elsif ($self->object and $data->can("repr")) {
|
280
|
0
|
|
|
|
|
0
|
return $data->repr();
|
281
|
|
|
|
|
|
|
}
|
282
|
|
|
|
|
|
|
elsif ($self->object and $data->can("__repr__")) {
|
283
|
0
|
|
|
|
|
0
|
return $data->__repr__();
|
284
|
|
|
|
|
|
|
}
|
285
|
|
|
|
|
|
|
elsif ($self->object and $data->can("string")) {
|
286
|
0
|
|
|
|
|
0
|
return $data->string();
|
287
|
|
|
|
|
|
|
}
|
288
|
|
|
|
|
|
|
elsif ($self->object and $data->can("__str__")) {
|
289
|
0
|
|
|
|
|
0
|
return $data->__str__();
|
290
|
|
|
|
|
|
|
}
|
291
|
|
|
|
|
|
|
elsif ($self->object and $data->can("ToString")) {
|
292
|
0
|
|
|
|
|
0
|
return $data->ToString();
|
293
|
|
|
|
|
|
|
}
|
294
|
|
|
|
|
|
|
elsif ($self->array) {
|
295
|
4
|
50
|
|
|
|
10
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID unless $Dotiac::DTL::Max_Depth;
|
296
|
4
|
|
|
|
|
6
|
return "(".join(", ",map {pyrep($_,$Dotiac::DTL::Max_Depth)} @{$data}).")";
|
|
12
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
6
|
|
297
|
|
|
|
|
|
|
}
|
298
|
|
|
|
|
|
|
elsif ($self->hash) {
|
299
|
0
|
0
|
|
|
|
0
|
return $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID unless $Dotiac::DTL::Max_Depth;
|
300
|
0
|
|
|
|
|
0
|
return "(".join(", ",map {"$_:".pyrep($data->{$_},$Dotiac::DTL::Max_Depth)} sort keys %{$data}).")";
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
301
|
|
|
|
|
|
|
}
|
302
|
0
|
|
|
|
|
0
|
return $data;
|
303
|
|
|
|
|
|
|
}
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub stringnodefault {
|
307
|
0
|
|
|
0
|
1
|
0
|
my $self=shift;
|
308
|
0
|
0
|
|
|
|
0
|
if ($self->undef) {
|
309
|
0
|
|
|
|
|
0
|
return undef;
|
310
|
|
|
|
|
|
|
}
|
311
|
0
|
|
|
|
|
0
|
return $self->string();
|
312
|
|
|
|
|
|
|
}
|
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub set {
|
315
|
648
|
|
|
648
|
1
|
831
|
my $self=shift;
|
316
|
648
|
|
|
|
|
772
|
my $data=shift;
|
317
|
648
|
|
|
|
|
877
|
$self->[0]=$data;
|
318
|
648
|
|
|
|
|
1182
|
my $r=Scalar::Util::reftype($data);
|
319
|
648
|
100
|
|
|
|
1571
|
$r="" unless $r;
|
320
|
648
|
|
|
|
|
894
|
$self->[2]=$r;
|
321
|
648
|
|
|
|
|
1155
|
$self->[3]=Scalar::Util::blessed($data);
|
322
|
648
|
100
|
|
|
|
1500
|
$self->[4]=($r?0:Scalar::Util::looks_like_number($data));
|
323
|
648
|
|
|
|
|
2336
|
return $self;
|
324
|
|
|
|
|
|
|
}
|
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
1;
|
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
__END__
|