NAME

MS::Reader::XML - Base class for XML-based parsers

SYNOPSIS

    package MS::Reader::Foo;

    use parent MS::Reader::XML;

    sub _init {}
    sub _finalize{}

    package main;

    use MS::Reader::Foo;

    my $run = MS::Reader::Foo->new('run.foo');

    while (my $record = $foo->next_record('bar') {
       
        # etc

    }

DESCRIPTION

MS::Reader::XML is the base class for XML-based parsers in the package. The class and its methods are not generally called directly, but publicly available methods are documented below.

METHODS

fetch_record

    my $r = $parser->fetch_record($ref => $idx);

Takes two arguments (record reference and zero-based index) and returns a record object. The types of records available and class of the object returned depends on the subclass implementation.

next_record

    while (my $r = $parser->next_record($ref);

Takes a single argument (record reference) and returns the next record in the parser, or undef if the end of records has been reached. Types of records available depend on the subclass implementation.

record_count

    my $n = $parser->record_count($ref);

Takes a single argument (record reference) and returns the number of records of that type present. Types of records available depend on the subclass implementation.

get_index_by_id

    my $i = $parser->get_index_by_id($ref => 'bar');

Takes two arguments (record reference and record ID) and returns the zero-based index associated with that record ID, or undef if not found. Types of records available and format of the ID string depend on the subclass implementation.

curr_index

    my $i = $parser->curr_index($ref);

Takes a single argument (record reference) and returns the zero-based index of the "current" record. This is similar to the "tell" function on an iterable filehandle and is generally used in conjuction with next_record.

goto

    $parser->goto($ref => $i);

Takes two arguments (record reference and zero-based index) and sets the current index position for that record reference. This is similar to the "seek" function on an iterable filehandle and is generally used in conjuction with next_record.

dump

    $parser->dump();

Returns a textual serialization of the underlying data structure (via Data::Dumper) as a string. This is useful for developers who want to access data details not available by accessor.

WARNING WARNING WARNING: This is a destructive process - don't try to use the object after dumping its contents!!!

CAVEATS AND BUGS

The API is in alpha stage and is not guaranteed to be stable.

Please reports bugs or feature requests through the issue tracker at https://github.com/jvolkening/p5-MS/issues.

AUTHOR

Jeremy Volkening <jdv@base2bio.com>

COPYRIGHT AND LICENSE

Copyright 2015-2016 Jeremy Volkening

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.