File Coverage

File:C4/TmplTokenType.pm
Coverage:75.5%

linestmtbrancondsubtimecode
1package C4::TmplTokenType;
2
3
4
4
4
852
10
240
use strict;
4#use warnings; FIXME - Bug 2505
5require Exporter;
6
7
4
4
4
31
5
527
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
4
1196
use vars qw( $_text $_text_parametrized $_cdata
42
4
4
41
5
    $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
43
44BEGIN {
45    my $new = sub {
46
36
46
        my $this = 'C4::TmplTokenType';#shift;
47
36
223
        my $class = ref($this) || $this;
48
36
46
        my $self = {};
49
36
107
        bless $self, $class;
50
36
115
        ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
51
36
1502
        return $self;
52
4
24
    };
53
4
9
    $_text = &$new(0, 'TEXT');
54
4
11
    $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
55
4
33
    $_cdata = &$new(1, 'CDATA');
56
4
8
    $_tag = &$new(2, 'TAG');
57
4
8
    $_decl = &$new(3, 'DECL');
58
4
9
    $_pi = &$new(4, 'PI');
59
4
8
    $_directive = &$new(5, 'DIRECTIVE');
60
4
8
    $_comment = &$new(6, 'COMMENT');
61
4
8
    $_unknown = &$new(7, 'UNKNOWN');
62}
63
64sub to_string {
65
0
0
    my $this = shift;
66
0
0
    return $this->{'name'}
67}
68
69
6
364247
sub TEXT () { $_text }
70
2
14
sub TEXT_PARAMETRIZED () { $_text_parametrized }
71
2
13
sub CDATA () { $_cdata }
72
2
14
sub TAG () { $_tag }
73
0
0
sub DECL () { $_decl }
74
0
0
sub PI () { $_pi }
75
2
28
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;