--- parser3/src/include/pa_pool.h 2001/12/14 12:53:47 1.72 +++ parser3/src/include/pa_pool.h 2002/08/01 11:41:15 1.83 @@ -1,28 +1,30 @@ /** @file Parser: pool class decl. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) - - $Id: pa_pool.h,v 1.72 2001/12/14 12:53:47 paf Exp $ + Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_POOL_H #define PA_POOL_H +static const char* IDENT_POOL_H="$Date: 2002/08/01 11:41:15 $"; + #include "pa_config_includes.h" #ifdef XML -#include -#include -#include +# include "gdome.h" +// for xmlChar +# include "libxml/tree.h" #endif // forwards class Exception; class String; +class Charset; +class GdomeDOMString_auto_ptr; /** Pool mechanizm allows users not to free up allocated memory, @@ -35,12 +37,11 @@ class Pool { public: Pool(void *astorage); - ~Pool(); - ///{@ statistics + //{@ statistics size_t total_allocated() { return ftotal_allocated; } unsigned int total_times() { return ftotal_times; } - ///}@ + //}@ void set_context(void *acontext) { fcontext=acontext; } void *get_context() { return fcontext; } @@ -60,16 +61,39 @@ public: fail_register_cleanup(); } - /// resets transcoder if they change charset - void set_charset(const String &charset); - /// returns current charset - const String& get_charset() { return *charset; } + //{@ source charset + void set_source_charset(Charset& acharset); + Charset& get_source_charset(); + //}@ + + //{@ client charset + void set_client_charset(Charset& charset); + Charset& get_client_charset(); + //}@ + +#ifdef XML + + /// @see Charset::transcode_cstr(xmlChar *s); + const char *transcode_cstr(xmlChar *s); + /// @see Charset::transcode(xmlChar *s); + String& transcode(xmlChar *s); + /// @see Charset::transcode_cstr(GdomeDOMString *s); + const char *transcode_cstr(GdomeDOMString *s); + /// @see Charset::transcode(GdomeDOMString *s); + String& transcode(GdomeDOMString *s); + /// @see Charset::transcode_cstr(const char *buf, size_t buf_size=0); + xmlChar *transcode_buf2xchar(const char *buf, size_t buf_size=0); + /// @see Charset::transcode(const String& s) + GdomeDOMString_auto_ptr transcode(const String& s); + +#endif private: void *fstorage; void *fcontext; - const String *charset; + Charset *source_charset; + Charset *client_charset; private: @@ -101,28 +125,6 @@ private: /// throws register cleanup exception void fail_register_cleanup() const; -#ifdef XML - -public: - /// converts Xalan string to char * - const char *transcode_cstr(const XalanDOMString& s); - /// converts Xalan string to parser String - String& transcode(const XalanDOMString& s); - /// converts char * to Xalan string - std::auto_ptr transcode_buf(const char *buf, size_t buf_size); - /// converts parser String to Xalan string - std::auto_ptr transcode(const String& s); - -private: - - void update_transcoder(); - -private: - - XMLTranscoder *transcoder; - -#endif - private: // statistics size_t ftotal_allocated; @@ -141,6 +143,10 @@ private: //disabled @see NEW */ + +// all classes that are members parents of packed class [String] +// sould be packed also to avoid sparc odd st/lduh problem +#include "pa_pragma_pack_begin.h" class Pooled { // the pool i'm allocated on Pool *fpool; @@ -168,11 +174,14 @@ public: void *calloc(size_t size) const { return fpool->calloc(size); } void register_cleanup(void (*cleanup) (void *), void *data) { fpool->register_cleanup(cleanup, data); } #ifdef XML - const char *transcode_cstr(const XalanDOMString& s) { return fpool->transcode_cstr(s); } - String& transcode(const XalanDOMString& s) { return fpool->transcode(s); } + + const char *transcode_cstr(GdomeDOMString *s) { return fpool->transcode_cstr(s); } + String& transcode(GdomeDOMString *s) { return fpool->transcode(s); } + #endif //} }; +#include "pa_pragma_pack_end.h" /// useful macro for creating objects on current Pooled object Pooled::pool() #define NEW new(pool())