| 1 | package Finnigan::GenericRecord; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings FATAL => qw( all ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | our $VERSION = 0.0206; | |
| 6 | |||
| 7 | 2 | ▶ | use Finnigan; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | use base 'Finnigan::Decoder'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 34 | ▶ | sub decode { |
|
Subroutine
decode: called CC=1 SCAR=0.0
Pod
documented
| |||
| 11 | 34 | my ($class, $stream, $field_templates) = @_; | |
| 12 | |||
| 13 | # This is a sleazy way of decoding this structure. The result will | ||
| 14 | # be a hash whose keys start with the ordinal numbers of elements; | ||
| 15 | # this answers the need to preserve order and to introduce gaps and | ||
| 16 | # section titles commanded by the GenericDataHeader but not present | ||
| 17 | # in the actual record. The field_templates() method of | ||
| 18 | # GenericDataHeader modifies all keys by adding ordinals to them. | ||
| 19 | |||
| 20 | # To decode a combination of specific and generic content, simply | ||
| 21 | # create a copy of this object and in it, combine | ||
| 22 | # $header->field_templates with specific fields and call | ||
| 23 | # Decoder->read. Just make sure the specific fields' keys start with | ||
| 24 | # a number and have the form 'x|key', and that number is unique in | ||
| 25 | # each field (does not co-incide with the range of numbers in the | ||
| 26 | # header (which is 1 .. n). | ||
| 27 | 34 | my $self = Finnigan::Decoder->read($stream, $field_templates); | |
| 28 | 34 | return bless $self, $class; | |
| 29 | } | ||
| 30 | |||
| 31 | 2 | 1; | |
| 32 | __END__ | ||