| 1 | ##-*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | ##====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## top-level | ||||||||||||||||||||||||||||||||||||||||||||
| 5 | package DDC::PP::CQueryOptions; | ||||||||||||||||||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use DDC::PP::Constants; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 7 | 20 | ▶ | use DDC::PP::Object; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use DDC::Utils qw(); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use Carp qw(carp confess); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | ##====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||
| 13 | ## CQueryOptions | ||||||||||||||||||||||||||||||||||||||||||||
| 14 | package DDC::PP::CQueryOptions; | ||||||||||||||||||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | our @ISA = qw(DDC::PP::Object); | |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | __PACKAGE__->defprop($_) | ||||||||||||||||||||||||||||||||||||||||||||
| 19 | 20 | foreach (qw(ContextSentencesCount EnableBibliography DebugRank SeparateHits Filters Subcorpora Comments LexerComments)); #Within | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | sub getWithin { return $_[0]{Within}; } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getWithin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | sub setWithin { return $_[0]{Within} = UNIVERSAL::isa($_[1],'ARRAY') ? $_[1] : [$_[1]]; } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setWithin: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 20 | __PACKAGE__->defalias('ContextCount'=>'ContextSentencesCount',0,1); | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 452 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 452 | my ($that,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 452 | return $that->SUPER::new(EnableBibliography=>1,Filters=>[],Subcorpora=>[],Within=>[],Comments=>[],LexerComments=>[],%opts); | |||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub swap { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
swap: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my ($a,$b) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my %tmp = %$b; | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | %$b = %$a; | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | %$a = %tmp; | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return $a; | |||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub Clear { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Clear: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | @{$_[0]{Filters}} = @{$_[0]{Subcorpora}} = @{$_[0]{Comments}} = @{$_[0]{LexerComments}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub ClearComments { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ClearComments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | @{$_[0]{Comments}} = @{$_[0]{LexerComments}} = qw(); | |||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 20 | __PACKAGE__->nomethod('CanFilterByFile'); | |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub Children { return [ @{$_[0]{Filters}||[]} ]; } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Children: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
$_[0]{'Filters'} || []
MC/DC0%0/1
$_[0]{'Filters'} || []
$_[0]{'Filters'}
Truth table0%0/2
A
A= $_[0]{'Filters'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub sqString { return DDC::Utils::escapeq(defined($_[1]) ? $_[1] : ''); } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sqString: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | sub toString { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toString: called CC=11 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | my $qo = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 51 | return ( | ||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | ($qo->{Within} ? join('', map {" #WITHIN ".$qo->sqString($_)} @{$qo->{Within}}) : '') | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 53 | .($qo->{ContextSentencesCount} ? " #CNTXT $qo->{ContextSentencesCount}" : '') | ||||||||||||||||||||||||||||||||||||||||||||
| 54 | .($qo->{SeparateHits} ? " #SEPARATE" : '') | ||||||||||||||||||||||||||||||||||||||||||||
| 55 | .(!$qo->{EnableBibliography} ? " #FILENAMES" : '') | ||||||||||||||||||||||||||||||||||||||||||||
| 56 | .($qo->{DebugRank} ? " #DEBUG_RANK" : '') | ||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | .join('', map {" ".$_->toString} @{$qo->{Filters}||[]}) | ||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$qo->{'Filters'} || []
MC/DC0%0/1
$qo->{'Filters'} || []
$qo->{'Filters'}
Truth table50%1/2
A
A= $qo->{'Filters'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | .join('', map {" #CMT ".$qo->sqString($_)} @{$qo->{Comments}||[]}) | ||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$qo->{'Comments'} || []
MC/DC0%0/1
$qo->{'Comments'} || []
$qo->{'Comments'}
Truth table50%1/2
A
A= $qo->{'Comments'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | .join('', map {" $_"} @{$qo->{LexerComments}//[]}) | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$qo->{"LexerComments"} // []
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
MC/DC0%0/1
$qo->{"LexerComments"} // []
$qo->{"LexerComments"}
MC/DC0%0/2
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
$qo->{"Subcorpora"}
@{$qo->{"Subcorpora"};}
Truth table50%1/2
A
A= $qo->{"LexerComments"}
Truth table33%1/3
A and B
A= $qo->{"Subcorpora"}B= @{$qo->{"Subcorpora"};}
| |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | .($qo->{Subcorpora} && @{$qo->{Subcorpora}} ? (" :".join(',', map {$qo->sqString($_)} @{$qo->{Subcorpora}})) : '') | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | ##-- ddc-compatible hash-conversion (for toJson()) | ||||||||||||||||||||||||||||||||||||||||||||
| 65 | 198 | ▶ | sub toHash { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toHash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 198 | my ($obj,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 198 | ▶ | return $obj->SUPER::toHash(%opts) if (!$opts{json}); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 196 | return { class=>$obj->jsonClass, $obj->jsonData }; | |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 70 | 196 | ▶ | sub jsonData { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jsonData: called CC=14 SCAR=31.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 196 | my $qo = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 72 | return (($qo->{Within} && $qo->{Within} ? (Within=>$qo->{Within}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||
| 73 | ($qo->{ContextSentencesCount} ? (ContextCount=>$qo->{ContextSentencesCount}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||
| 74 | ($qo->{SeparateHits} ? (SeparateHits=>$qo->{SeparateHits}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||
| 75 | ($qo->{EnableBibliography} ? (EnableBibliography=>$qo->{EnableBibliography}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||
| 76 | ($qo->{DebugRank} ? (DebugRank=>$qo->{DebugRank}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||
| 77 | 16 | ▶ | (Filters=>[map {($_->toHash(json=>1))} @{$qo->{Filters}||[]}]), | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$qo->{'Filters'} || []
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
MC/DC0%0/1
$qo->{'Filters'} || []
$qo->{'Filters'}
MC/DC50%1/2
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
$qo->{"Subcorpora"}
@{$qo->{"Subcorpora"};}
Truth table50%1/2
A
A= $qo->{'Filters'}
Truth table66%2/3
A and B
A= $qo->{"Subcorpora"}B= @{$qo->{"Subcorpora"};}
| |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 196 | ▶ | ($qo->{Subcorpora} && @{$qo->{Subcorpora}} ? (Subcorpora=>$qo->{Subcorpora}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$qo->{"Comments"} and @{$qo->{"Comments"};}
MC/DC50%1/2
$qo->{"Comments"} and @{$qo->{"Comments"};}
$qo->{"Comments"}
@{$qo->{"Comments"};}
Truth table66%2/3
A and B
A= $qo->{"Comments"}B= @{$qo->{"Comments"};}
| |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 196 | ▶ | ($qo->{Comments} && @{$qo->{Comments}} ? (Comments=>$qo->{Comments}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$qo->{"LexerComments"} and @{$qo->{"LexerComments"};}
MC/DC0%0/2
$qo->{"LexerComments"} and @{$qo->{"LexerComments"};}
$qo->{"LexerComments"}
@{$qo->{"LexerComments"};}
Truth table33%1/3
A and B
A= $qo->{"LexerComments"}B= @{$qo->{"LexerComments"};}
| |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 196 | ▶ | ($qo->{LexerComments} && @{$qo->{LexerComments}} ? (LexerComments=>$qo->{LexerComments}) : qw()), | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition33%1/3
$qo->{"Within"} and $qo->{"Within"}
MC/DC0%0/2
$qo->{"Within"} and $qo->{"Within"}
$qo->{"Within"}
$qo->{"Within"}
Truth table33%1/3
A and B
A= $qo->{"Within"}B= $qo->{"Within"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 20 | 1; ##-- be happy | |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | =pod | ||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | DDC::PP::CQueryOptions - pure-perl implementation of DDC::XS::CQueryOptions | ||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | use DDC::PP::CQueryOptions; | ||||||||||||||||||||||||||||||||||||||||||||
| 96 | #... stuff happens ... | ||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | The DDC::PP::CQueryOptions class is a pure-perl fork of the L<DDC::XS::CQueryOptions|DDC::XS::CQueryOptions> class, | ||||||||||||||||||||||||||||||||||||||||||||
| 102 | which see for details. | ||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | perl(1), | ||||||||||||||||||||||||||||||||||||||||||||
| 107 | DDC::PP(3perl), | ||||||||||||||||||||||||||||||||||||||||||||
| 108 | DDC::XS::CQueryOptions(3perl). | ||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | Bryan Jurish E<lt>moocow@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | Copyright (C) 2016-2020 by Bryan Jurish | ||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||
| 119 | it under the same terms as Perl itself, either Perl version 5.14.2 or, | ||||||||||||||||||||||||||||||||||||||||||||
| 120 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||