Author image Michal Josef Špaček

NAME

 Tags::Output::Structure - Structure class for 'Tags' output.

SYNOPSYS

 use Tags::Output::Structure;

 my $obj = Tags::Output::Structure->new(%parameters);
 $obj->finalize;
 my $ret_ar = $obj->flush($reset_flag);
 my @tags = $obj->open_tags;
 $obj->put(@data);
 $obj->reset;

METHODS

new

 my $obj = Tags::Output::Structure->new(%parameters);

Constructor.

Returns instance of object.

  • auto_flush

     Auto flush flag.
     Default value is 0.
  • output_callback

     Output callback.
     Default value is undef.
  • output_handler

     Set output handler.
     Default value is undef.
  • output_sep

     Output separator.
     Default value is newline.
  • skip_bad_data

     Skip bad tags.
     Default value is 0.
  • strict_instruction

     Strict instruction.
     Default value is 1.

finalize

 $obj->finalize;

Finalize Tags output. Automaticly puts end of all opened tags.

Returns undef.

flush

 my $ret_ar = $obj->flush($reset_flag);

Flush tags in object. Or returns code. If enabled $reset_flag, then resets internal variables via reset method.

Returns undef or code.

open_tags

 my @tags = $obj->open_tags;

Get list of opened tags.

Returns array of opened tags.

put

 $obj->put(@data);

Put tags code in tags format.

Returns undef.

reset

 $obj->reset;

Resets internal variables.

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():
         Ending bad tag: '%s' in block of tag '%s'.

EXAMPLE1

 use strict;
 use warnings;

 use Data::Printer;
 use Tags::Output::Structure;

 # Object.
 my $tags = Tags::Output::Structure->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.
 my $ret_ar = $tags->flush;

 # Dump out.
 p $ret_ar;

 # Output:
 # \ [
 #     [0] [
 #         [0] "b",
 #         [1] "tag"
 #     ],
 #     [1] [
 #         [0] "a",
 #         [1] "par",
 #         [2] "val"
 #     ],
 #     [2] [
 #         [0] "c",
 #         [1] "data",
 #         [2] \ "data"
 #     ],
 #     [3] [
 #         [0] "e",
 #         [1] "tag"
 #     ],
 #     [4] [
 #         [0] "i",
 #         [1] "target",
 #         [2] "data"
 #     ],
 #     [5] [
 #         [0] "b",
 #         [1] "tag"
 #     ],
 #     [6] [
 #         [0] "d",
 #         [1] "data",
 #         [2] "data"
 #     ],
 #     [7] [
 #         [0] "e",
 #         [1] "tag"
 #     ]
 # ]

EXAMPLE2

 use strict;
 use warnings;

 use Tags::Output::Structure;

 # Object.
 my $tags = Tags::Output::Structure->new(
         'output_handler' => \*STDOUT,
 );

 # 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.
 $tags->flush;

 # Output:
 # ['b', 'tag']
 # ['a', 'par', 'val']
 # ['c', 'data', 'SCALAR(0x143d9c0)']
 # ['e', 'tag']
 # ['i', 'target', 'data']
 # ['b', 'tag']
 # ['d', 'data', 'data']
 # ['e', 'tag']

DEPENDENCIES

Error::Pure, Tags::Output.

SEE ALSO

Tags

Structure oriented SGML/XML/HTML/etc. elements manipulation.

Tags::Output

Base class for Tags::Output::*.

Task::Tags

Install the Tags modules.

REPOSITORY

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

AUTHOR

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

http://skim.cz

LICENSE AND COPYRIGHT

© 2012-2022 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.08