Annotation of parser3/src/main/pa_stylesheet_connection.C, revision 1.7

1.1       paf         1: /** @file
                      2:        Parser: Stylesheet connection implementation.
                      3: 
1.7     ! moko        4:        Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.1       paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
1.2       paf         8: #include "pa_config_includes.h"
                      9: #ifdef XML
1.1       paf        10: 
                     11: #include "pa_stylesheet_connection.h"
                     12: #include "pa_xml_exception.h"
                     13: 
1.7     ! moko       14: volatile const char * IDENT_PA_STYLESHEET_CONNECTION_C="$Id: 2009-05-14 11:27:23 $" IDENT_PA_STYLESHEET_CONNECTION_H;
        !            15: 
1.1       paf        16: void Stylesheet_connection::load(time_t new_disk_time) {
                     17:        xsltStylesheet *nstylesheet;
                     18:        {
                     19:                pa_xmlStartMonitoringDependencies();
                     20:                {
                     21:                        int saved=xmlDoValidityCheckingDefaultValue;//
                     22:                        xmlDoValidityCheckingDefaultValue=0;//
                     23:                        nstylesheet=xsltParseStylesheetFile(BAD_CAST ffile_spec.cstr());
                     24:                        xmlDoValidityCheckingDefaultValue = saved;//
                     25:                }
                     26:                dependencies=pa_xmlGetDependencies();
                     27:        }
1.4       paf        28:        if(xmlHaveGenericErrors())
                     29:                throw XmlException(new String(ffile_spec, String::L_TAINTED));
1.1       paf        30:        if(!nstylesheet)
                     31:                throw Exception("file.missing",
                     32:                        new String(ffile_spec, String::L_TAINTED),
                     33:                        "stylesheet failed to load");
                     34: 
                     35:        xsltFreeStylesheet(fstylesheet);  
                     36:        fstylesheet=nstylesheet;
                     37:        prev_disk_time=new_disk_time;
                     38: }
                     39: 
1.6       misha      40: static void update_max_mtime(HashStringValue::key_type stat_file_spec_cstr, bool /*value*/, time_t* max) {
1.1       paf        41:        size_t size;
                     42:        time_t atime, mtime, ctime;
                     43:        file_stat(*new String(stat_file_spec_cstr, String::L_AS_IS), 
                     44:                size,
                     45:                atime, mtime, ctime,
                     46:                true/*exception on error*/);
                     47: 
                     48:        if(mtime>*max)
                     49:                *max=mtime;
                     50: }
                     51: 
                     52: time_t Stylesheet_connection::get_disk_time() {
                     53:        assert(dependencies);
                     54: 
                     55:        time_t result=0;
1.5       paf        56:        dependencies->for_each<time_t*>(update_max_mtime, &result);
1.1       paf        57:        return result;
                     58: }
1.2       paf        59: 
                     60: #endif

E-mail: