PerlPoint-Package

 view release on metacpan or  search on metacpan

lib/PerlPoint/Generator/SDF/Default.pm  view on Meta::CPAN


  # check parameters
  confess "[BUG] Missing class name.\n" unless $class;
  confess "[BUG] Missing options hash.\n" unless exists $params{options};

  # build object
  my $me=fields::new($class);

  # store options of interest
  $me->{options}{$_}=$params{options}{$_}
   for grep(exists $params{options}{$_}, qw(
                                           ),
           );

  # supply new object
  $me;
 }



# check usage
sub checkUsage
 {
  # get and check parameters
  (my __PACKAGE__ $me)=@_;
  confess "[BUG] Missing object parameter.\n" unless $me;
  confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);

  # don't forget the base class
  $me->SUPER::checkUsage;

  # check your own options, if necessary
 }


# sub bootstrap
#  {
#   # get and check parameters
#   (my __PACKAGE__ $me)=@_;
#   confess "[BUG] Missing object parameter.\n" unless $me;
#   confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);

#   # don't forget the base class
#   $me->SUPER::bootstrap;
#  }

# initializations done when a backend is available
sub initBackend
 {
  # get and check parameters
  (my __PACKAGE__ $me)=@_;
  confess "[BUG] Missing object parameter.\n" unless $me;
  confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);

  # don't forget the base class
  $me->SUPER::initBackend;

  # open result file(s): docstreams to handle?
  if (
          (
              not exists $me->{options}{dstreaming}
           or $me->{options}{dstreaming}==DSTREAM_DEFAULT
          )
      and $me->{backend}->docstreams
     )
    {
     # scopies
     my ($c, $d)=(0, 1);

     # open a target file for each handle
     foreach my $docstream (grep(($_ ne 'main'), sort $me->{backend}->docstreams))
       {
        # build filename
        my $filename="$me->{options}{targetdir}/$me->{options}{prefix}-stream-$d$me->{options}{suffix}";

        # inform user, if necessary
        warn qq([Info] Document stream "$docstream" generates result file $filename.\n) unless exists $me->{options}{noinfo};

        # open file
        $me->{targethandles}[$c]=new IO::File(">$filename");

        # store handle
        $me->{docstreamhandles}{$docstream}=$me->{targethandles}[$c];

        # update counters
        $c++; $d++;
       }
    }
  else
    {
     # default output file, named as specified
     $me->{docstreamhandles}{main}=$me->{targethandles}[0]=new IO::File(">$me->{options}{targetdir}/$me->{options}{prefix}$me->{options}{suffix}");
    }
 }


# docstream entry formatter
{
 # define a call counter
 my $dstreamCounter;

 sub formatDStreamEntrypoint
  {
   # get and check parameters
   ((my __PACKAGE__ $me), my ($page, $item))=@_;
   confess "[BUG] Missing object parameter.\n" unless $me;
   confess "[BUG] Object parameter is no ", __PACKAGE__, " object.\n" unless ref $me and $me->isa(__PACKAGE__);
   confess "[BUG] Missing page data parameter.\n" unless $page;
   confess "[BUG] Missing item parameter.\n" unless $item;

   # provide this part in a simple structure (avoid to use a hash reference),
   # but skip the stream name if this is the first stream (initial entry point
   # of the default main stream)
   [$dstreamCounter++ ? $item->{cfg}{data}{name} : (), join('', @{$item->{parts}})];
  }


# we have an own headline formatter to reset the docstream counter
sub formatHeadline
 {
  # get and check parameters
  my ($me, $page, $item)=@_;



( run in 0.751 second using v1.01-cache-2.11-cpan-140bd7fdf52 )