line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##-*- Mode: CPerl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## File: DDC::Format::Raw.pm |
4
|
|
|
|
|
|
|
## Author: Bryan Jurish |
5
|
|
|
|
|
|
|
## Description: |
6
|
|
|
|
|
|
|
## + DDC Query utilities: output formatting: Data::Raw |
7
|
|
|
|
|
|
|
##====================================================================== |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package DDC::Format::Raw; |
10
|
26
|
|
|
26
|
|
191
|
use IO::File; |
|
26
|
|
|
|
|
58
|
|
|
26
|
|
|
|
|
3291
|
|
11
|
26
|
|
|
26
|
|
183
|
use Carp; |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
1356
|
|
12
|
26
|
|
|
26
|
|
163
|
use strict; |
|
26
|
|
|
|
|
69
|
|
|
26
|
|
|
|
|
5422
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
##====================================================================== |
15
|
|
|
|
|
|
|
## Globals |
16
|
|
|
|
|
|
|
our @ISA = qw(DDC::Format); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
##====================================================================== |
19
|
|
|
|
|
|
|
## Constructors, etc. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## $fmt = $CLASS_OR_OBJ->new(%args) |
22
|
|
|
|
|
|
|
## + %args: |
23
|
|
|
|
|
|
|
## ( |
24
|
|
|
|
|
|
|
## hitSeparator => $sep, ##-- raw hit separator (default="\n\n") |
25
|
|
|
|
|
|
|
## ) |
26
|
|
|
|
|
|
|
sub new { |
27
|
0
|
|
|
0
|
1
|
|
my $that = shift; |
28
|
0
|
|
0
|
|
|
|
my $fmt = bless { |
29
|
|
|
|
|
|
|
hitSeparator => "\n\n", |
30
|
|
|
|
|
|
|
@_ |
31
|
|
|
|
|
|
|
}, ref($that)||$that; |
32
|
0
|
|
|
|
|
|
return $fmt; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## $fmt = $fmt->reset() |
36
|
|
|
|
|
|
|
## + reset counters, etc. |
37
|
|
|
|
|
|
|
#sub reset { |
38
|
|
|
|
|
|
|
# return $_[0]->SUPER::reset(); |
39
|
|
|
|
|
|
|
#} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
##====================================================================== |
42
|
|
|
|
|
|
|
## Helper functions |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
## $hitStr = $fmt->hitString($hit) |
45
|
|
|
|
|
|
|
## + increments $fmt->{start} |
46
|
|
|
|
|
|
|
sub hitString { |
47
|
0
|
|
|
0
|
1
|
|
return $_[1]{$_[0]{raw}}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
##====================================================================== |
51
|
|
|
|
|
|
|
## API |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## $str = $fmt->toString(\@hits) |
54
|
|
|
|
|
|
|
sub toString { |
55
|
0
|
|
|
0
|
1
|
|
return join('',map {$_->{raw}.$_[0]{hitSeparator}} @{$_[1]->{hits_}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; ##-- be happy |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |