--- parser3/src/include/pa_stylesheet_connection.h 2002/08/01 11:41:16 1.30 +++ parser3/src/include/pa_stylesheet_connection.h 2003/11/28 10:27:00 1.37 @@ -1,22 +1,22 @@ /** @file Parser: Stylesheet connection decl. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_STYLESHEET_CONNECTION_H #define PA_STYLESHEET_CONNECTION_H -static const char* IDENT_STYLESHEET_CONNECTION_H="$Date: 2002/08/01 11:41:16 $"; +static const char * const IDENT_STYLESHEET_CONNECTION_H="$Date: 2003/11/28 10:27:00 $"; #include "libxslt/xslt.h" #include "libxslt/xsltInternals.h" -#include "pa_pool.h" -#include "pa_stylesheet_manager.h" -#include "pa_exception.h" + +#include "pa_xml_exception.h" #include "pa_common.h" +#include "pa_globals.h" // defines @@ -25,27 +25,34 @@ static const char* IDENT_STYLESHEET_CONN /** Connection with stylesheet: remembers time and can figure out that it needs recompilation */ -class Stylesheet_connection : public Pooled { +class Stylesheet_connection: public PA_Object { friend class Stylesheet_connection_ptr; +private: + + String::Body ffile_spec; + bool uncachable; + xsltStylesheet *fstylesheet; + time_t time_used; + time_t prev_disk_time; + public: - Stylesheet_connection(Pool& pool, const String& afile_spec) : Pooled(pool), + Stylesheet_connection(String::Body afile_spec): ffile_spec(afile_spec), - prev_disk_time(0), - fservices_pool(0), fstylesheet(0), - time_used(0), used(0) { + time_used(0), + prev_disk_time(0), + used(0) + { + uncachable=ffile_spec.pos("://")!=CORD_NOT_FOUND; } - const String& file_spec() { return ffile_spec; } + String::Body file_spec() { return ffile_spec; } - void set_services(Pool *aservices_pool) { - fservices_pool=aservices_pool; - } bool expired(time_t older_dies) { - return !used && time_usedclose_connection(ffile_spec, *this); - } + void close(); private: @@ -77,17 +82,17 @@ private: } void load(time_t new_disk_time) { - Pool& pool=*fservices_pool; - - xsltStylesheet *nstylesheet= - xsltParseStylesheetFile(BAD_CAST ffile_spec.cstr(String::UL_FILE_SPEC)); + int saved=xmlDoValidityCheckingDefaultValue;// + xmlDoValidityCheckingDefaultValue=0;// + xsltStylesheet *nstylesheet=xsltParseStylesheetFile(BAD_CAST ffile_spec.cstr()); + xmlDoValidityCheckingDefaultValue = saved;// if(xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(&ffile_spec, exc); + throw XmlException(new String(ffile_spec, String::L_TAINTED), exc); } if(!nstylesheet) throw Exception("file.missing", - &ffile_spec, + new String(ffile_spec, String::L_TAINTED), "stylesheet failed to load"); xsltFreeStylesheet(fstylesheet); @@ -98,10 +103,10 @@ private: time_t get_disk_time() { size_t size; time_t atime, mtime, ctime; - String stamp_file_spec(ffile_spec); + String stamp_file_spec(ffile_spec, String::L_AS_IS); stamp_file_spec << STYLESHEET_FILENAME_STAMP_SUFFIX; // {file_spec}.stamp modification time OR {file_spec} - const String& stat_file_spec=file_readable(stamp_file_spec)?stamp_file_spec:ffile_spec; + const String& stat_file_spec=file_readable(stamp_file_spec)?stamp_file_spec:*new String(ffile_spec, String::L_AS_IS); file_stat(stat_file_spec, size, atime, mtime, ctime, @@ -111,6 +116,7 @@ private: private: // connection usage methods + int used; void use() { time_used=time(0); // they started to use at this time used++; @@ -121,24 +127,6 @@ private: // connection usage methods close(); } -private: // connection usage data - - int used; - -private: - - const String& ffile_spec; - xsltStylesheet *fstylesheet; - time_t time_used; - time_t prev_disk_time; - -private: - - Pool *fservices_pool; - -private: - void *malloc(size_t size) { return fservices_pool->malloc(size); } - void *calloc(size_t size) { return fservices_pool->calloc(size); } }; /// Auto-object used to track Stylesheet_connection usage @@ -155,6 +143,9 @@ public: Stylesheet_connection* operator->() { return fconnection; } +/* Stylesheet_connection& operator*() { + return *fconnection; + }*/ // copying Stylesheet_connection_ptr(const Stylesheet_connection_ptr& src) : fconnection(src.fconnection) {