--- parser3/src/include/pa_pool.h 2001/09/20 14:25:06 1.55 +++ parser3/src/include/pa_pool.h 2001/09/21 14:46:09 1.59 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_pool.h,v 1.55 2001/09/20 14:25:06 parser Exp $ + $Id: pa_pool.h,v 1.59 2001/09/21 14:46:09 parser Exp $ */ #ifndef PA_POOL_H @@ -13,10 +13,11 @@ #include "pa_config_includes.h" +#ifdef XML #include #include #include - +#endif // forwards @@ -24,8 +25,6 @@ class Exception; class Temp_exception; class String; -void Pool_cleanup(void *); - /** Pool mechanizm allows users not to free up allocated memory, leaving that problem to 'pools'. @@ -38,16 +37,11 @@ void Pool_cleanup(void *); class Pool { friend Temp_exception; - friend void Pool_cleanup(void *); public: Pool(void *astorage); + ~Pool(); -private: - void cleanup() { - delete transcoder; - } -public: void set_context(void *acontext) { fcontext=acontext; } void *context() { return fcontext; } @@ -72,25 +66,11 @@ public: /// current exception object of the pool Exception& exception() const { return *fexception; } - /// resets transcoder if they change charset - void set_charset(const String &charset); - /// converts Xalan string to char * - const char *transcode(const XalanDOMString& s); - /// converts XSL exception to parser exception - void _throw(const String *source, const XSLException& e); - -private: - - void set_charset(const char *charset); - void update_transcoder(); - private: void *fstorage; void *fcontext; void *ftag; - const char *charset; - XMLTranscoder *transcoder; private: @@ -137,6 +117,32 @@ private: // current request's exception object Exception *fexception; +#ifdef XML + +public: + /// resets transcoder if they change charset + void set_charset(const String &charset); + /// returns current charset + const String& get_charset() { return *charset; } + /// converts Xalan string to char * + const char *transcode_cstr(const XalanDOMString& s); + /// converts Xalan string to parser String + String& transcode(const XalanDOMString& s); + /// converts XSL exception to parser exception + void _throw(const String *source, const XSLException& e); + +private: + + void set_charset(const char *new_scharset); + void update_transcoder(); + +private: + + const String *charset; + XMLTranscoder *transcoder; + +#endif + private: //disabled // Pool(const Pool&) {} @@ -171,20 +177,18 @@ public: */ void set_pool(Pool *apool) { fpool=apool; } - /// useful wrapper around pool + //{ + /// @name useful wrapper around pool void *malloc(size_t size) const { return fpool->malloc(size); } - /// useful wrapper around pool void *calloc(size_t size) const { return fpool->calloc(size); } - /// useful wrapper around pool - void register_cleanup(void (*cleanup) (void *), void *data) { - fpool->register_cleanup(cleanup, data); - } - /// useful wrapper around pool + void register_cleanup(void (*cleanup) (void *), void *data) { fpool->register_cleanup(cleanup, data); } Exception& exception() const { return fpool->exception(); } - /// useful wrapper around pool - const char *transcode(const XalanDOMString& s) { return fpool->transcode(s); } - /// useful wrapper around pool +#ifdef XML + const char *transcode_cstr(const XalanDOMString& s) { return fpool->transcode_cstr(s); } + String& transcode(const XalanDOMString& s) { return fpool->transcode(s); } void _throw(const String *source, const XSLException& e) { fpool->_throw(source, e); } +#endif + //} }; /// useful macro for creating objects on current Pooled object Pooled::pool() #define NEW new(pool())