1package Text::Template::Simple::Constants;
2$Text::Template::Simple::Constants::VERSION = '0.91';
3use strict;
4use warnings;
5
6my($FIELD_ID);
7
8use constant RESET_FIELD         => -1;
9
10# object fields
11BEGIN { $FIELD_ID = RESET_FIELD } # init object field id counter
12use constant DELIMITERS          => ++$FIELD_ID;
13use constant AS_STRING           => ++$FIELD_ID;
14use constant DELETE_WS           => ++$FIELD_ID;
15use constant FAKER               => ++$FIELD_ID;
16use constant FAKER_HASH          => ++$FIELD_ID;
17use constant FAKER_SELF          => ++$FIELD_ID;
18use constant FAKER_WARN          => ++$FIELD_ID;
19use constant MONOLITH            => ++$FIELD_ID;
20use constant CACHE               => ++$FIELD_ID;
21use constant CACHE_DIR           => ++$FIELD_ID;
22use constant CACHE_OBJECT        => ++$FIELD_ID;
23use constant IO_OBJECT           => ++$FIELD_ID;
24use constant STRICT              => ++$FIELD_ID;
25use constant SAFE                => ++$FIELD_ID;
26use constant HEADER              => ++$FIELD_ID;
27use constant ADD_ARGS            => ++$FIELD_ID;
28use constant CAPTURE_WARNINGS    => ++$FIELD_ID;
29use constant WARN_IDS            => ++$FIELD_ID;
30use constant TYPE                => ++$FIELD_ID;
31use constant TYPE_FILE           => ++$FIELD_ID;
32use constant COUNTER             => ++$FIELD_ID;
33use constant COUNTER_INCLUDE     => ++$FIELD_ID;
34use constant INSIDE_INCLUDE      => ++$FIELD_ID;
35use constant NEEDS_OBJECT        => ++$FIELD_ID;
36use constant CID                 => ++$FIELD_ID;
37use constant FILENAME            => ++$FIELD_ID;
38use constant IOLAYER             => ++$FIELD_ID;
39use constant STACK               => ++$FIELD_ID;
40use constant USER_THANDLER       => ++$FIELD_ID;
41use constant DEEP_RECURSION      => ++$FIELD_ID;
42use constant INCLUDE_PATHS       => ++$FIELD_ID;
43use constant PRE_CHOMP           => ++$FIELD_ID;
44use constant POST_CHOMP          => ++$FIELD_ID;
45use constant VERBOSE_ERRORS      => ++$FIELD_ID;
46use constant TAINT_MODE          => ++$FIELD_ID;
47use constant MAXOBJFIELD         =>   $FIELD_ID;
48
49# token type ids
50BEGIN { $FIELD_ID = 0 }
51use constant T_DELIMSTART        => ++$FIELD_ID;
52use constant T_DELIMEND          => ++$FIELD_ID;
53use constant T_DISCARD           => ++$FIELD_ID;
54use constant T_COMMENT           => ++$FIELD_ID;
55use constant T_RAW               => ++$FIELD_ID;
56use constant T_NOTADELIM         => ++$FIELD_ID;
57use constant T_CODE              => ++$FIELD_ID;
58use constant T_CAPTURE           => ++$FIELD_ID;
59use constant T_DYNAMIC           => ++$FIELD_ID;
60use constant T_STATIC            => ++$FIELD_ID;
61use constant T_MAPKEY            => ++$FIELD_ID;
62use constant T_COMMAND           => ++$FIELD_ID;
63use constant T_MAXID             =>   $FIELD_ID;
64
65# settings
66use constant MAX_RECURSION       => 50; # recursion limit for dynamic includes
67use constant PARENT              => ( __PACKAGE__ =~ m{ (.+?) ::Constants }xms );
68use constant IS_WINDOWS          => $^O eq 'MSWin32';
69use constant DELIM_START         => 0; # field id
70use constant DELIM_END           => 1; # field id
71use constant RE_NONFILE          => qr{ [ \n \r < > * ? ] }xmso;
72use constant RE_DUMP_ERROR       => qr{
73    \QCan't locate object method "first" via package "B::SVOP"\E
74}xms;
75use constant COMPILER            => PARENT   . '::Compiler';
76use constant COMPILER_SAFE       => COMPILER . '::Safe';
77use constant DUMMY_CLASS         => PARENT   . '::Dummy';
78use constant MAX_FILENAME_LENGTH => 120;
79use constant CACHE_EXT           => '.tts.cache';
80use constant STAT_SIZE           => 7;
81use constant STAT_MTIME          => 9;
82use constant DELIMS              => qw( <% %> );
83use constant UNICODE_PERL        => $] >= 5.008;
84
85use constant CHOMP_NONE          => 0x000000;
86use constant COLLAPSE_NONE       => 0x000000;
87use constant CHOMP_ALL           => 0x000002;
88use constant CHOMP_LEFT          => 0x000004;
89use constant CHOMP_RIGHT         => 0x000008;
90use constant COLLAPSE_LEFT       => 0x000010;
91use constant COLLAPSE_RIGHT      => 0x000020;
92use constant COLLAPSE_ALL        => 0x000040;
93
94use constant TAINT_CHECK_NORMAL  => 0x000000;
95use constant TAINT_CHECK_ALL     => 0x000002;
96use constant TAINT_CHECK_WINDOWS => 0x000004;
97use constant TAINT_CHECK_FH_READ => 0x000008;
98
99# first level directives
100use constant DIR_CAPTURE         => q{=};
101use constant DIR_DYNAMIC         => q{*};
102use constant DIR_STATIC          => q{+};
103use constant DIR_NOTADELIM       => q{!};
104use constant DIR_COMMENT         => q{#};
105use constant DIR_COMMAND         => q{|};
106# second level directives
107use constant DIR_CHOMP           => q{-};
108use constant DIR_COLLAPSE        => q{~};
109use constant DIR_CHOMP_NONE      => q{^};
110
111# token related indexes
112use constant TOKEN_STR           =>  0;
113use constant TOKEN_ID            =>  1;
114use constant TOKEN_CHOMP         =>  2;
115use constant TOKEN_TRIGGER       =>  3;
116
117use constant TOKEN_CHOMP_NEXT    =>  0; # sub-key for TOKEN_CHOMP
118use constant TOKEN_CHOMP_PREV    =>  1; # sub-key for TOKEN_CHOMP
119
120use constant LAST_TOKEN          => -1;
121use constant PREVIOUS_TOKEN      => -2;
122
123use constant CACHE_PARENT        => 0; # object id
124use constant CACHE_FMODE         => 0600;
125
126use constant EMPTY_STRING        => q{};
127
128use constant FMODE_GO_WRITABLE   => 022;
129use constant FMODE_GO_READABLE   => 066;
130use constant FTYPE_MASK          => 07777;
131
132use constant MAX_PATH_LENGTH     => 255;
133use constant DEVEL_SIZE_VERSION  => 0.72;
134
135use constant DEBUG_LEVEL_NORMAL  => 1;
136use constant DEBUG_LEVEL_VERBOSE => 2;
137use constant DEBUG_LEVEL_INSANE  => 3;
138
139
140# SHA seems to be more accurate, so we'll try them first.
141# Pure-Perl ones are slower, but they are fail-safes.
142# However, Digest::SHA::PurePerl does not work under $perl < 5.6.
143# But, Digest::Perl::MD5 seems to work under older perls (5.5.4 at least).
144use constant DIGEST_MODS => qw(
145   Digest::SHA
146   Digest::SHA1
147   Digest::SHA2
148   Digest::SHA::PurePerl
149   Digest::MD5
150   MD5
151   Digest::Perl::MD5
152);
153
154use constant RE_PIPE_SPLIT   => qr/ [|] (?:\s+)? (NAME|PARAM|FILTER|SHARE) : /xms;
155use constant RE_FILTER_SPLIT => qr/ \, (?:\s+)? /xms;
156use constant RE_INVALID_CID  =>
157    qr{[^A-Za-z_0-9]}xms; ## no critic (ProhibitEnumeratedClasses)
158
159use constant DISK_CACHE_MARKER => q{# This file is automatically generated by }
160                               .  PARENT
161                               ;
162
163use base qw( Exporter );
164
165BEGIN {
166
167   our %EXPORT_TAGS = (
168      info      =>   [qw(
169                        UNICODE_PERL
170                        IS_WINDOWS
171                        COMPILER
172                        COMPILER_SAFE
173                        DUMMY_CLASS
174                        MAX_FILENAME_LENGTH
175                        CACHE_EXT
176                        PARENT
177                     )],
178      templates =>   [qw(
179                        DISK_CACHE_MARKER
180                     )],
181      delims    =>   [qw(
182                        DELIM_START
183                        DELIM_END
184                        DELIMS
185                     )],
186      fields    =>   [qw(
187                        DELIMITERS
188                        AS_STRING
189                        DELETE_WS
190                        FAKER
191                        FAKER_HASH
192                        FAKER_SELF
193                        FAKER_WARN
194                        CACHE
195                        CACHE_DIR
196                        CACHE_OBJECT
197                        MONOLITH
198                        IO_OBJECT
199                        STRICT
200                        SAFE
201                        HEADER
202                        ADD_ARGS
203                        WARN_IDS
204                        CAPTURE_WARNINGS
205                        TYPE
206                        TYPE_FILE
207                        COUNTER
208                        COUNTER_INCLUDE
209                        INSIDE_INCLUDE
210                        NEEDS_OBJECT
211                        CID
212                        FILENAME
213                        IOLAYER
214                        STACK
215                        USER_THANDLER
216                        DEEP_RECURSION
217                        INCLUDE_PATHS
218                        PRE_CHOMP
219                        POST_CHOMP
220                        VERBOSE_ERRORS
221                        TAINT_MODE
222                        MAXOBJFIELD
223                     )],
224      chomp     =>   [qw(
225                        CHOMP_NONE
226                        COLLAPSE_NONE
227                        CHOMP_ALL
228                        CHOMP_LEFT
229                        CHOMP_RIGHT
230                        COLLAPSE_LEFT
231                        COLLAPSE_RIGHT
232                        COLLAPSE_ALL
233                     )],
234      directive =>   [qw(
235                        DIR_CHOMP
236                        DIR_COLLAPSE
237                        DIR_CHOMP_NONE
238                        DIR_CAPTURE
239                        DIR_DYNAMIC
240                        DIR_STATIC
241                        DIR_NOTADELIM
242                        DIR_COMMENT
243                        DIR_COMMAND
244                     )],
245      token     =>   [qw(
246                        TOKEN_ID
247                        TOKEN_STR
248                        TOKEN_CHOMP
249                        TOKEN_TRIGGER
250                        TOKEN_CHOMP_NEXT
251                        TOKEN_CHOMP_PREV
252                        LAST_TOKEN
253                        PREVIOUS_TOKEN
254
255                        T_DELIMSTART
256                        T_DELIMEND
257                        T_DISCARD
258                        T_COMMENT
259                        T_RAW
260                        T_NOTADELIM
261                        T_CODE
262                        T_CAPTURE
263                        T_DYNAMIC
264                        T_STATIC
265                        T_MAPKEY
266                        T_COMMAND
267                        T_MAXID
268                      )],
269      taint     =>   [qw(
270                        TAINT_CHECK_NORMAL
271                        TAINT_CHECK_ALL
272                        TAINT_CHECK_WINDOWS
273                        TAINT_CHECK_FH_READ
274                     )],
275      etc       =>   [qw(
276                        DIGEST_MODS
277                        STAT_MTIME
278                        RE_DUMP_ERROR
279                        RE_PIPE_SPLIT
280                        RE_FILTER_SPLIT
281                        RE_NONFILE
282                        RE_INVALID_CID
283                        STAT_SIZE
284                        MAX_RECURSION
285                        CACHE_FMODE
286                        CACHE_PARENT
287                        RESET_FIELD
288                        EMPTY_STRING
289                        MAX_PATH_LENGTH
290                        DEVEL_SIZE_VERSION
291                     )],
292      fmode     =>   [qw(
293                        FMODE_GO_WRITABLE
294                        FMODE_GO_READABLE
295                        FTYPE_MASK
296                     )],
297      debug     =>   [qw(
298                        DEBUG_LEVEL_NORMAL
299                        DEBUG_LEVEL_VERBOSE
300                        DEBUG_LEVEL_INSANE
301                     )],
302   );
303
304   our @EXPORT_OK    = map { @{ $EXPORT_TAGS{$_} } } keys %EXPORT_TAGS;
305   our @EXPORT       = @EXPORT_OK;
306   $EXPORT_TAGS{all} = \@EXPORT_OK;
307}
308
3091;
310
311__END__
312
313=pod
314
315=encoding UTF-8
316
317=head1 NAME
318
319Text::Template::Simple::Constants
320
321=head1 VERSION
322
323version 0.91
324
325=head1 SYNOPSIS
326
327   TODO
328
329=head1 DESCRIPTION
330
331Constants for Text::Template::Simple.
332
333=head1 NAME
334
335Text::Template::Simple::Constants - Constants
336
337=head1 AUTHOR
338
339Burak Gursoy <burak@cpan.org>
340
341=head1 COPYRIGHT AND LICENSE
342
343This software is copyright (c) 2004 by Burak Gursoy.
344
345This is free software; you can redistribute it and/or modify it under
346the same terms as the Perl 5 programming language system itself.
347
348=cut
349