Annotation of parser3/src/include/pa_charset_connection.h, revision 1.2
1.1 parser 1: /** @file
2: Parser: Charset connection decl.
3:
4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
5: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
6:
1.2 ! parser 7: $Id: pa_charset_connection.h,v 1.1 2001/10/01 10:53:16 parser Exp $
1.1 parser 8: */
9:
10: #ifndef PA_CHARSET_CONNECTION_H
11: #define PA_CHARSET_CONNECTION_H
12:
13: #include "pcre.h"
14: # include "internal.h"
15:
16: #include "pa_config_includes.h"
17: #include "pa_pool.h"
18: #include "pa_exception.h"
19: #include "pa_common.h"
20:
21: // defines
22:
23: /** Connection with charset file:
24: remembers time and can figure out that it needs recompilation
25: */
26: class Charset_connection : public Pooled {
27: public:
28:
29: Charset_connection(Pool& pool, const String& aname, const String& afile_spec) : Pooled(pool),
30: fname(aname),
31: ffile_spec(afile_spec),
32: prev_disk_time(0) {
33: }
1.2 ! parser 34: ~Charset_connection() {}
1.1 parser 35:
36: void up_to_date(Pool& pool) {
37: time_t new_disk_time=get_new_disk_time();
38: if(new_disk_time)
39: load(pool, new_disk_time);
40: }
41:
42: unsigned char *pcre_tables() { return fpcre_tables; }
43:
44: private:
45:
46: time_t get_new_disk_time() {
47: time_t now_disk_time=get_disk_time();
48: return now_disk_time>prev_disk_time?now_disk_time:0;
49: }
50:
51: void load(Pool& pool, time_t new_disk_time);
52:
53: time_t get_disk_time() {
54: size_t size;
55: time_t atime, mtime, ctime;
56: // {file_spec} modification time
1.2 ! parser 57: file_stat(ffile_spec,
1.1 parser 58: size,
59: atime, mtime, ctime,
1.2 ! parser 60: true/*exception on error*/);
1.1 parser 61: return mtime;
62: }
63:
64: private:
65:
66: const String& fname;
67: const String& ffile_spec;
68: time_t prev_disk_time;
69:
70: unsigned char fpcre_tables[tables_length];
71: };
72:
73: #endif
E-mail: