The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

 Tags::Output - Base class for Tags::Output::*.

SYNOPSIS

 use Tags::Output;

 my $obj = Tags::Output->new(%parameters);
 $obj->finalize;
 my $ret = $obj->flush($reset_flag);
 my @elements = $obj->open_elements;
 $obj->put(@data);
 $obj->reset;

 # Deprecated methods.
 my @tags = $obj->open_tags;

METHODS

new(%parameters)
  • auto_flush

     Auto flush flag.
     Default value is 0.
  • input_tags_item_callback

     Input 'Tags' item callback.
     Callback is processing before main 'Tags' put().
     It's usefull for e.g. validation.
     Default value is undef.
  • output_callback

     Output callback.
     Default value is callback which encode to output encoding, if parameter 'output_encoding' is present.
    
     Arguments of callback:
     - $data_sr - Reference to data
     - $self - Object
    
     Example for output encoding in iso-8859-2:
     'output_callback' => sub {
             my ($data_sr, $self) = @_;
    
             ${$data_sr} = encode('iso-8859-2', ${$data_sr});
    
             return;
     }
  • output_encoding

     Output encoding.
     Default value is undef, which mean not encode.
  • output_handler

     Set output handler.
     Default value is undef.
  • output_sep

     Output separator.
     Default value is newline (\n).
  • skip_bad_tags

     Skip bad tags.
     Default value is 0.
  • strict_instruction

     Strict instruction.
     Default value is 1.
finalize()
 Finalize Tags output.
 Automaticly puts end of all opened tags.
 Returns undef.
flush($reset_flag)
 Flush tags in object.
 If defined 'output_handler' flush to its.
 Or return code.
 If enabled $reset_flag, then resets internal variables via reset method.
open_elements()
 Return array of opened elements.
put(@data)
 Put tags code in tags format.
 Returns undef.
reset($reset_flag)
 Resets internal variables.
 Returns undef.

DEPRECATED METHODS

open_tags()
 Return array of opened tags.

METHODS TO OVERWRITE

new(%parameters)

Constructor.

_check_params()
 Check parameters to rigth values.
 Can check constructor parameters.
 Returns undef.
_default_parameters()
 Default parameters.
 Set list of constructor parameters with default value.
 e.g.:
 $self->{'foo'} = 'bar';
 Returns undef.
_put_attribute($attr, $value)
 Attribute callback.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_begin_of_tag($tag)
 Begin of tag.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_cdata(@cdata)
 CData.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_comment(@comment)
 Comment.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_data(@data)
 Data.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_end_of_tag($tag)
 End of tag.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_instruction($target, $code)
 Instruction.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.
_put_raw(@raw_data)
 Raw data.
 Method can write output to 'flush_code' object parameter as array or scalar.
 Returns undef.

ERRORS

 new():
         Auto-flush can't use without output handler.
         Output handler is bad file handler.
         From Class::Utils::set_params():
                 Unknown parameter '%s'.

 flush():
         Cannot write to output handler.

 put():
         Bad data.
         Bad type of data.
         Bad number of arguments. 'Tags' structure %s

EXAMPLE

 use strict;
 use warnings;

 use Tags::Output;

 # Object.
 my $tags = Tags::Output->new;

 # Put all tag types.
 $tags->put(
         ['b', 'tag'],
         ['a', 'par', 'val'],
         ['c', 'data', \'data'],
         ['e', 'tag'],
         ['i', 'target', 'data'],
         ['b', 'tag'],
         ['d', 'data', 'data'],
         ['e', 'tag'],
 );

 # Print out.
 print $tags->flush."\n";

 # Output:
 # Begin of tag
 # Attribute
 # Comment
 # End of tag
 # Instruction
 # Begin of tag
 # Data
 # End of tag

DEPENDENCIES

Class::Utils, Encode, Error::Pure.

SEE ALSO

Task::Tags

Install the Tags modules.

REPOSITORY

https://github.com/michal-josef-spacek/Tags

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2005-2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.15