Annotation of parser3/src/include/pa_charset_connection.h, revision 1.3

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.3     ! paf         7:        $Id: pa_charset_connection.h,v 1.2 2001/10/22 16:44:42 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.3     ! paf        35:        const String& get_file_spec() { return ffile_spec; }
1.1       parser     36:        
                     37:        void up_to_date(Pool& pool) { 
                     38:                time_t new_disk_time=get_new_disk_time();
                     39:                if(new_disk_time)
                     40:                        load(pool, new_disk_time);
                     41:        }
                     42: 
                     43:        unsigned char *pcre_tables() { return fpcre_tables; }
                     44: 
                     45: private:
                     46: 
                     47:        time_t get_new_disk_time() {
                     48:                time_t now_disk_time=get_disk_time();
                     49:                return now_disk_time>prev_disk_time?now_disk_time:0;
                     50:        }
                     51: 
                     52:        void load(Pool& pool, time_t new_disk_time);
                     53:        
                     54:        time_t get_disk_time() {
                     55:                size_t size;
                     56:                time_t atime, mtime, ctime;
                     57:                // {file_spec} modification time
1.2       parser     58:                file_stat(ffile_spec, 
1.1       parser     59:                        size,
                     60:                        atime, mtime, ctime,
1.2       parser     61:                        true/*exception on error*/);
1.1       parser     62:                return mtime;
                     63:        }
                     64: 
                     65: private:
                     66: 
                     67:        const String& fname;
                     68:        const String& ffile_spec;
                     69:        time_t prev_disk_time;
                     70: 
                     71:        unsigned char fpcre_tables[tables_length];
                     72: };
                     73: 
                     74: #endif

E-mail: