File Coverage

File:C4/TmplTokenType.pm
Coverage:75.5%

linestmtbrancondsubtimecode
1package C4::TmplTokenType;
2
3
3
3
3
244
4
158
use strict;
4#use warnings; FIXME - Bug 2505
5require Exporter;
6
7
3
3
3
10
6
406
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8
9###############################################################################
10
11 - 20
=head1 NAME

C4::TmplTokenType.pm - Types of TmplToken objects

=head1 DESCRIPTION

This is a Java-style "safe enum" singleton class for types of TmplToken objects.
The predefined constants are

=cut
21
22###############################################################################
23
24$VERSION = 0.01;
25
26@ISA = qw(Exporter);
27@EXPORT_OK = qw(
28    &TEXT
29    &TEXT_PARAMETRIZED
30    &CDATA
31    &TAG
32    &DECL
33    &PI
34    &DIRECTIVE
35    &COMMENT
36    &UNKNOWN
37);
38
39###############################################################################
40
41
3
717
use vars qw( $_text $_text_parametrized $_cdata
42
3
3
32
6
    $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
43
44BEGIN {
45    my $new = sub {
46
27
39
        my $this = 'C4::TmplTokenType';#shift;
47
27
176
        my $class = ref($this) || $this;
48
27
50
        my $self = {};
49
27
67
        bless $self, $class;
50
27
118
        ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
51
27
679
        return $self;
52
3
22
    };
53
3
10
    $_text = &$new(0, 'TEXT');
54
3
7
    $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
55
3
6
    $_cdata = &$new(1, 'CDATA');
56
3
6
    $_tag = &$new(2, 'TAG');
57
3
7
    $_decl = &$new(3, 'DECL');
58
3
5
    $_pi = &$new(4, 'PI');
59
3
5
    $_directive = &$new(5, 'DIRECTIVE');
60
3
6
    $_comment = &$new(6, 'COMMENT');
61
3
7
    $_unknown = &$new(7, 'UNKNOWN');
62}
63
64sub to_string {
65
0
0
    my $this = shift;
66
0
0
    return $this->{'name'}
67}
68
69
3
186094
sub TEXT () { $_text }
70
1
7
sub TEXT_PARAMETRIZED () { $_text_parametrized }
71
1
7
sub CDATA () { $_cdata }
72
1
8
sub TAG () { $_tag }
73
0
0
sub DECL () { $_decl }
74
0
0
sub PI () { $_pi }
75
1
7
sub DIRECTIVE () { $_directive }
76
0
sub COMMENT () { $_comment }
77
0
sub UNKNOWN () { $_unknown }
78
79###############################################################################
80
81 - 127
=over

=item TEXT

normal text (#text in the DTD)

=item TEXT_PARAMETRIZED

parametrized normal text
(result of simple recognition of text interspersed with <TMPL_VAR> directives;
this has to be explicitly enabled in the scanner)

=item CDATA

normal text (CDATA in the DTD)

=item TAG

something that has the form of an HTML tag

=item DECL

something that has the form of an SGML declaration

=item PI

something that has the form of an SGML processing instruction

=item DIRECTIVE

a Template Toolkit directive

=item COMMENT

something that has the form of an HTML comment
(and is not recognized as an HTML::Template directive)

=item UNKNOWN

something that is not recognized at all by the scanner

=back

Note that end of file is currently represented by undef,
instead of a constant predefined by this module.

=cut
128
1291;