| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright (c) 2004 - 2013 by Steffen Beyer. ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## All rights reserved. ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## This package is free software; you can redistribute it ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## and/or modify it under the same terms as Perl itself. ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package Bit::Vector::String; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Bit::Vector; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | @ISA = qw(Exporter Bit::Vector); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | @EXPORT_OK = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | $VERSION = '7.5'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | package Bit::Vector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use Carp::Clan '^Bit::Vector\b'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my $Factor = log(10) / log(2); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | sub to_Oct | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 108 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_Oct: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 108 | ▶ | croak('Usage: $vector->to_Oct();') unless (@_ == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 108 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 108 | my($string) = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 108 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 108 | eval { $string = reverse(join('', $self->Chunk_List_Read(3))); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 108 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $string = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $string =~ s!\s+at\s.*$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | croak($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 108 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub from_Oct | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 27 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_Oct: called CC=4 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 27 | ▶ | croak('Usage: $vector->from_Oct($string);') unless (@_ == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 27 | my($self,$string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 27 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 27 | ▶ | if ($string =~ /^[0-7]+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 27 | eval { $self->Chunk_List_Store(3, split(//, reverse($string))); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 27 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $string = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $string =~ s!\s+at\s.*$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | croak($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | croak("unknown string type"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 27 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | sub new_Oct | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 54 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_Oct: called CC=5 SCAR=17.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 54 | ▶ | croak('Usage: Bit::Vector->new_Oct($bits,$string);') unless (@_ == 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 54 | my($class,$bits,$string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 54 | my($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 54 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 54 | ▶ | if ($string =~ /^[0-7]+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 54 | ▶ | unless (defined $bits) { $bits = 3 * length($string); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 54 | eval { $self = Bit::Vector->new($bits); $self->Chunk_List_Store(3, split(//, reverse($string))); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 54 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $string = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $string =~ s!\s+at\s.*$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | croak($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | croak("unknown string type"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 54 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | sub String_Export | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 486 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
String_Export: called CC=18 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 486 | ▶ | croak('Usage: $vector->String_Export($type);') unless (@_ == 1 or @_ == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table33%1/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 486 | my($self,$type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 486 | my($string) = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 486 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 486 | ▶ | if (not defined $type or not $type) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition33%1/3
defined $type && $type
MC/DC0%0/2
defined $type && $type
defined $type
$type
Truth table33%1/3
A && B
A= defined $typeB= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | eval { $string = '0x' . $self->to_Hex(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ▶ | elsif ($type eq '1' or $type =~ /^b(?:in)?$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq 1 or $type =~ /^b(?:in)?$/i
MC/DC50%1/2
$type eq 1 or $type =~ /^b(?:in)?$/i
$type eq 1
$type =~ /^b(?:in)?$/i
Truth table66%2/3
A or B
A= $type eq 1B= $type =~ /^b(?:in)?$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 81 | eval { $string = '0b' . $self->to_Bin(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ▶ | elsif ($type eq '2' or $type =~ /^o(?:ct)?$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq 2 or $type =~ /^o(?:ct)?$/i
MC/DC50%1/2
$type eq 2 or $type =~ /^o(?:ct)?$/i
$type eq 2
$type =~ /^o(?:ct)?$/i
Truth table66%2/3
A or B
A= $type eq 2B= $type =~ /^o(?:ct)?$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 81 | eval { $string = '0o' . reverse(join('', $self->Chunk_List_Read(3))); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ▶ | elsif ($type eq '3' or $type =~ /^d(?:ec)?$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq 3 or $type =~ /^d(?:ec)?$/i
MC/DC50%1/2
$type eq 3 or $type =~ /^d(?:ec)?$/i
$type eq 3
$type =~ /^d(?:ec)?$/i
Truth table66%2/3
A or B
A= $type eq 3B= $type =~ /^d(?:ec)?$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 81 | eval { $string = $self->to_Dec(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ▶ | elsif ($type eq '4' or $type =~ /^(?:h(?:ex)?|x)$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq 4 or $type =~ /^(?:h(?:ex)?|x)$/i
MC/DC50%1/2
$type eq 4 or $type =~ /^(?:h(?:ex)?|x)$/i
$type eq 4
$type =~ /^(?:h(?:ex)?|x)$/i
Truth table66%2/3
A or B
A= $type eq 4B= $type =~ /^(?:h(?:ex)?|x)$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 81 | eval { $string = '0x' . $self->to_Hex(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ▶ | elsif ($type eq '5' or $type =~ /^e(?:num)?$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq 5 or $type =~ /^e(?:num)?$/i
MC/DC50%1/2
$type eq 5 or $type =~ /^e(?:num)?$/i
$type eq 5
$type =~ /^e(?:num)?$/i
Truth table66%2/3
A or B
A= $type eq 5B= $type =~ /^e(?:num)?$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 81 | eval { $string = '{' . $self->to_Enum() . '}'; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ▶ | elsif ($type eq '6' or $type =~ /^p(?:ack)?$/i) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$type eq 6 or $type =~ /^p(?:ack)?$/i
MC/DC0%0/2
$type eq 6 or $type =~ /^p(?:ack)?$/i
$type eq 6
$type =~ /^p(?:ack)?$/i
Truth table33%1/3
A or B
A= $type eq 6B= $type =~ /^p(?:ack)?$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 81 | eval { $string = ':' . $self->Size() . ':' . $self->Block_Read(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | croak("unknown string type '$type'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 486 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $string = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $string =~ s!\s+at\s.*$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | croak($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 486 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | sub String_Import | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 306 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
String_Import: called CC=9 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 306 | ▶ | croak('Usage: $vector->String_Import($string);') unless (@_ == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 306 | my($self,$string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 306 | my($type) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 306 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 306 | ▶ | if ($string =~ /^(?:0[bB])?([01]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 54 | $type = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 54 | eval { $self->from_Bin($1); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | elsif ($string =~ /^(?:0[oO])?([0-7]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 45 | $type = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 45 | eval { $self->Chunk_List_Store(3, split(//, reverse($1))); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | elsif ($string =~ /^(?:[+-])?[0-9]+$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 54 | $type = 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 54 | eval { $self->from_Dec($string); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | elsif ($string =~ /^(?:0[hHxX])?([0-9A-Fa-f]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 45 | $type = 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 45 | eval { $self->from_Hex($1); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif ($string =~ /^[(<{\[]?([0-9]+(?:-[0-9]+)?(?:,[0-9]+(?:-[0-9]+)?)*)[)>}\]]?$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 54 | $type = 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 54 | eval { $self->from_Enum($1); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif ($string =~ s!^:\d+:!!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 54 | $type = 6; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 54 | eval { $self->Block_Store($string); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | croak("unknown string type"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 306 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $string = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $string =~ s!\s+at\s.*$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | croak($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 306 | return $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub new_String | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 324 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_String: called CC=18 SCAR=29.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 324 | ▶ | croak('Usage: Bit::Vector->new_String($bits,$string);') unless (@_ == 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 324 | my($class,$bits,$string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 324 | my($type) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 324 | my($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 324 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 324 | ▶ | if ($string =~ /^(?:0[bB])?([01]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 54 | $type = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 54 | ▶ | unless (defined $bits) { $bits = length($1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 54 | eval { $self = Bit::Vector->new_Bin($bits,$1); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | elsif ($string =~ /^(?:0[oO])?([0-7]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 54 | $type = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 54 | ▶ | unless (defined $bits) { $bits = 3 * length($1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 54 | eval { $self = Bit::Vector->new($bits); $self->Chunk_List_Store(3, split(//, reverse($1))); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | elsif ($string =~ /^(?:[+-])?([0-9]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 54 | $type = 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 54 | ▶ | unless (defined $bits) { $bits = int( length($1) * $Factor + 1 ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 54 | eval { $self = Bit::Vector->new_Dec($bits,$string); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | elsif ($string =~ /^(?:0[hHxX])?([0-9A-Fa-f]+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 54 | $type = 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 54 | ▶ | unless (defined $bits) { $bits = 4 * length($1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 54 | eval { $self = Bit::Vector->new_Hex($bits,$1); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | elsif ($string =~ /^[(<{\[]?([0-9]+(?:-[0-9]+)?(?:,[0-9]+(?:-[0-9]+)?)*)[)>}\]]?$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 54 | $type = 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 54 | $string = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 54 | ▶ | unless (defined $bits) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 27 | $bits = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 27 | ▶ | while ($string =~ /([0-9]+)/g) { $bits = $1 if ($1 > $bits); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 27 | $bits++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 54 | eval { $self = Bit::Vector->new_Enum($bits,$string); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | elsif ($string =~ s!^:(\d+):!!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 54 | $type = 6; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 54 | ▶ | $bits = $1 unless (defined $bits); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 54 | eval { $self = Bit::Vector->new($bits); $self->Block_Store($string); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | croak("unknown string type"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 324 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $string = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $string =~ s!\s+at\s.*$!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | croak($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 324 | ▶ | if (wantarray) { return($self,$type); } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||