File Coverage

File:C4/TmplTokenType.pm
Coverage:75.5%

linestmtbrancondsubtimecode
1package C4::TmplTokenType;
2
3
2
2
2
15
10
98
use strict;
4#use warnings; FIXME - Bug 2505
5require Exporter;
6
7
2
2
2
15
8
380
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
2
578
use vars qw( $_text $_text_parametrized $_cdata
42
2
2
16
9
    $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
43
44BEGIN {
45    my $new = sub {
46
18
23
        my $this = 'C4::TmplTokenType';#shift;
47
18
84
        my $class = ref($this) || $this;
48
18
33
        my $self = {};
49
18
47
        bless $self, $class;
50
18
54
        ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
51
18
495
        return $self;
52
2
42
    };
53
2
5
    $_text = &$new(0, 'TEXT');
54
2
4
    $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
55
2
40
    $_cdata = &$new(1, 'CDATA');
56
2
4
    $_tag = &$new(2, 'TAG');
57
2
3
    $_decl = &$new(3, 'DECL');
58
2
4
    $_pi = &$new(4, 'PI');
59
2
3
    $_directive = &$new(5, 'DIRECTIVE');
60
2
5
    $_comment = &$new(6, 'COMMENT');
61
2
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
3
53
sub TEXT () { $_text }
70
1
25
sub TEXT_PARAMETRIZED () { $_text_parametrized }
71
1
26
sub CDATA () { $_cdata }
72
1
8
sub TAG () { $_tag }
73
0
0
sub DECL () { $_decl }
74
0
0
sub PI () { $_pi }
75
1
16
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;