line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================== Notepad.pm ================================== |
2
|
|
|
|
|
|
|
# Filename: Notepad.pm |
3
|
|
|
|
|
|
|
# Description: A notepad for random text messages. |
4
|
|
|
|
|
|
|
# Original Author: Dale M. Amon |
5
|
|
|
|
|
|
|
# Revised by: $Author: amon $ |
6
|
|
|
|
|
|
|
# Date: $Date: 2008-08-28 23:20:19 $ |
7
|
|
|
|
|
|
|
# Version: $Revision: 1.7 $ |
8
|
|
|
|
|
|
|
# License: LGPL 2.1, Perl Artistic or BSD |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
#============================================================================= |
11
|
1
|
|
|
1
|
|
1130
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
110
|
|
12
|
1
|
|
|
1
|
|
6
|
use Fault::Msg; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
13
|
1
|
|
|
1
|
|
1328
|
use Fault::Logger; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
53
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Fault::Notepad; |
16
|
1
|
|
|
1
|
|
9
|
use vars qw{@ISA}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1050
|
|
17
|
|
|
|
|
|
|
@ISA = qw( UNIVERSAL ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#============================================================================= |
20
|
|
|
|
|
|
|
# CLASS METHODS |
21
|
|
|
|
|
|
|
#============================================================================= |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new ($) { |
24
|
0
|
|
|
0
|
1
|
|
my ($class) = @_; |
25
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
26
|
0
|
|
|
|
|
|
$self->{'notes'} = []; |
27
|
0
|
|
|
|
|
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#============================================================================= |
31
|
|
|
|
|
|
|
# INSTANCE METHODS |
32
|
|
|
|
|
|
|
#============================================================================= |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub add ($$) { |
35
|
0
|
|
|
0
|
1
|
|
my ($s,$n) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ($::DEBUG) {Fault::Logger->arg_check_noref ($n,"Textline") or return $s;} |
|
0
|
0
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
push @{$s->{'notes'}}, Fault::Msg->new ($n,'NOTE','info'); |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return $s; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub addObject ($$) { |
46
|
0
|
|
|
0
|
0
|
|
my ($s,$msg) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if ($::DEBUG) {Fault::Logger->arg_check_isa ($msg,"Fault::Msg") |
|
0
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
or return $s;} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
push @{$s->{'notes'}}, $msg; |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $s; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub merge ($$) { |
58
|
0
|
|
|
0
|
1
|
|
my ($s,$s2) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ($::DEBUG) { |
61
|
0
|
0
|
|
|
|
|
Fault::Logger->arg_check_isa ($s2,"Notepad","notepad2") or return $s; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
push @{$s->{'notes'}}, @{$s2->{'notes'}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $s; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
1
|
|
sub count ($) {my ($s) = @_; $#{$s->{'notes'}}+1;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
1
|
|
sub print ($) {shift->fprint (*STDOUT);} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub fprint ($\*) { |
74
|
0
|
|
|
0
|
1
|
|
my ($s,$fh) = @_; foreach (@{$s->{'notes'}}) {print $fh $_->msg . "\n";} $s;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub sprint ($) { |
77
|
0
|
|
|
0
|
1
|
|
my ($s) = @_; my $str=""; |
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
foreach (@{$s->{'notes'}}) {$str .= sprintf $_->msg . "\n";} $str;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#============================================================================= |
81
|
|
|
|
|
|
|
# POD DOCUMENTATION |
82
|
|
|
|
|
|
|
#============================================================================= |
83
|
|
|
|
|
|
|
# You may extract and format the documention section with the 'perldoc' cmd. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Fault::Notepad - A notepad for random text messages. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use Fault::Notepad; |
92
|
|
|
|
|
|
|
$obj = Fault::Notepad->new; |
93
|
|
|
|
|
|
|
$obj = $obj->add ($text); |
94
|
|
|
|
|
|
|
$obj = $obj->addObject ($msg); |
95
|
|
|
|
|
|
|
$obj = $obj->merge ($obj2); |
96
|
|
|
|
|
|
|
$obj = $obj->print; |
97
|
|
|
|
|
|
|
$cnt = $obj->count; |
98
|
|
|
|
|
|
|
$obj = $obj->fprint ($fh); |
99
|
|
|
|
|
|
|
$str = $obj->sprint; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 Inheritance |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
UNIVERSAL |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 Description |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
A notepad is a container for random text messages. Notes are added to a |
108
|
|
|
|
|
|
|
list in the sequence recieved and once written are not modifiable. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is a very early form of the class and it does very little at present |
111
|
|
|
|
|
|
|
other than append Fault::Msg objects to it's internal list and dump text |
112
|
|
|
|
|
|
|
from them on demand. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
It is a container for text generated deep in a program which will allow it |
115
|
|
|
|
|
|
|
to be collected and returned to the top level or wherever it may be useful. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 Examples |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
use Fault::Notepad; |
120
|
|
|
|
|
|
|
use Fault::Msg; |
121
|
|
|
|
|
|
|
my $obj = Fault::Notepad->new; |
122
|
|
|
|
|
|
|
my $obj2 = Fault::Notepad->new; |
123
|
|
|
|
|
|
|
my $msg = Fault::Msg->("abridging freedom of speech...\n"); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$obj->add ("Congress shall pass no law "); |
126
|
|
|
|
|
|
|
$obj2->addObject ($msg); |
127
|
|
|
|
|
|
|
$obj->merge ($obj2); |
128
|
|
|
|
|
|
|
$obj->print; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
open $fh, ">notepad.tmp"; |
131
|
|
|
|
|
|
|
$obj->fprint ($fh); |
132
|
|
|
|
|
|
|
close $fh; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 Class Variables |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
None. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 Instance Variables |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
None. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 Class Methods |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over 4 |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B<$obj = Fault::Notepad-Enew> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Create instances of Notepad. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 Instance Methods |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item B<$obj = $obj-Eadd ($note)> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Append a textual note to the notepad. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item B<$obj = $obj-Eadd ($obj)> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Append an Fault::Msg object containing a textual note to the notepad. |
161
|
|
|
|
|
|
|
the current time; if the object has digital signatures, create one. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item B<$cnt = $obj-Ecount> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns a count of the items on the notepad. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item B<$obj = $obj-Efprint ($fh)> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Print contents of Notepad verbatim to file. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item B<$obj = $obj-Emerge ($other)> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Append the contents of the argument notepad object to this notepad. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item B<$obj = $obj-Eprint> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Print contents of Notepad verbatim to stdout. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item B<$str = $obj-Esprint> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Print contents of Notepad verbatim to a string. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back 4 |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 Private Class Method |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
None. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 Private Instance Methods |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
None. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 Errors and Warnings |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
None. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 KNOWN BUGS |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
See TODO. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SEE ALSO |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Fault::Logger, Fault::Msg. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Dale Amon |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#============================================================================= |
212
|
|
|
|
|
|
|
# CVS HISTORY |
213
|
|
|
|
|
|
|
#============================================================================= |
214
|
|
|
|
|
|
|
# $Log: Notepad.pm,v $ |
215
|
|
|
|
|
|
|
# Revision 1.7 2008-08-28 23:20:19 amon |
216
|
|
|
|
|
|
|
# perldoc section regularization. |
217
|
|
|
|
|
|
|
# |
218
|
|
|
|
|
|
|
# Revision 1.6 2008-08-17 21:56:37 amon |
219
|
|
|
|
|
|
|
# Make all titles fit CPAN standard. |
220
|
|
|
|
|
|
|
# |
221
|
|
|
|
|
|
|
# Revision 1.5 2008-07-28 10:57:37 amon |
222
|
|
|
|
|
|
|
# Dropped last of tsag/dsig; new addObject method; sprint bugfix; newlines added to prints. |
223
|
|
|
|
|
|
|
# |
224
|
|
|
|
|
|
|
# Revision 1.4 2008-07-24 21:17:24 amon |
225
|
|
|
|
|
|
|
# Moved all todo notes to elsewhere; made Stderr the default delegate instead |
226
|
|
|
|
|
|
|
# of Stdout. |
227
|
|
|
|
|
|
|
# |
228
|
|
|
|
|
|
|
# Revision 1.3 2008-07-24 19:27:51 amon |
229
|
|
|
|
|
|
|
# Fix edit error in Notepad. |
230
|
|
|
|
|
|
|
# |
231
|
|
|
|
|
|
|
# Revision 1.2 2008-07-24 19:11:29 amon |
232
|
|
|
|
|
|
|
# Notepad now uses Fault::Msg class which moves all the timestamp and |
233
|
|
|
|
|
|
|
# digitalsig issues to Msg. |
234
|
|
|
|
|
|
|
# |
235
|
|
|
|
|
|
|
# Revision 1.1 2008-07-22 14:32:17 amon |
236
|
|
|
|
|
|
|
# Added Notepad and Delegate::Stderr classes |
237
|
|
|
|
|
|
|
# |
238
|
|
|
|
|
|
|
# 20080715 Dale Amon |
239
|
|
|
|
|
|
|
# Created. |
240
|
|
|
|
|
|
|
1; |