--- parser3/src/include/pa_string.h 2001/10/29 16:29:07 1.112 +++ parser3/src/include/pa_string.h 2001/11/16 14:25:02 1.118 @@ -2,9 +2,9 @@ Parser: string class decl. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexander Petrosyan (http://paf.design.ru) - $Id: pa_string.h,v 1.112 2001/10/29 16:29:07 paf Exp $ + $Id: pa_string.h,v 1.118 2001/11/16 14:25:02 paf Exp $ */ #ifndef PA_STRING_H @@ -16,15 +16,6 @@ class Table; -/** - $MAIN:html-typo table elements must enlarge string not more that that. - - that's a tradeoff - otherwise we'd have to scan string twice: - - first for buffer length - - second for replacements themselves -*/ -#define UNTAINT_TIMES_BIGGER 10 - #ifndef NO_STRING_ORIGIN # define STRING_APPEND_PARAMS \ const char *src, size_t size, \ @@ -78,6 +69,7 @@ class Dictionary; - whether they are tainted or not, and the language which should be used to detaint them */ +#include "pa_pragma_pack_begin.h" class String : public Pooled { public: @@ -109,26 +101,25 @@ public: UL_JS, ///< JavaScript code UL_XML, ///< ^dom:set xml UL_HTML, ///< HTML code (for editing) - UL_USER_HTML ///< HTML code with USER chars + UL_OPTIMIZED_HTML ///< optimized HTML code, adjucent whitespaces joined }; public: String(Pool& apool, const char *src=0, size_t src_size=0, bool tainted=false); String(const String& src); - size_t size() const { return fsize; } - /// makes store_to produce origin:text\n output - void set_origins_mode(bool aorigins_mode) const { forigins_mode=aorigins_mode; } + size_t size() const; /// convert to C string. if 'lang' known, forcing 'lang' to it char *cstr(Untaint_lang lang=UL_AS_IS, SQL_Connection *connection=0, const char *charset=0) const { - char *result=(char *)malloc(cstr_bufsize(lang)); + char *result=(char *)malloc(cstr_bufsize(lang, connection, charset)); char *eol=store_to(result, lang, connection, charset); *eol=0; return result; } + char *cstr_debug_origins() const; /// puts pieces to buf void serialize(size_t prolog_size, void *& buf, size_t& buf_size) const; /// appends pieces from buf to self @@ -173,7 +164,6 @@ public: return cmp(partial, src_ptr, 0)!=0; } - /** appends other String. @@ -244,14 +234,14 @@ private: /// several String fragments struct Chunk { - uint count; ///< the number of rows in chunk + ushort count; ///< the number of rows in chunk /// string fragment or a link to next chunk union union Row { /// fragment struct { const char *ptr; ///< pointer to the start - size_t size; ///< length - Untaint_lang lang; ///< untaint flag, later untaint language + ushort size; ///< length + unsigned char/*Untaint_lang*/ lang; ///< untaint flag, later untaint language #ifndef NO_STRING_ORIGIN Origin origin; ///< origin #endif @@ -274,12 +264,6 @@ private: /// last chunk Chunk *last_chunk; - /// string size - size_t fsize; - - /// origins_mode changes behaviour of store_to[cstr()] - mutable bool forigins_mode; - private: bool chunk_is_full() { @@ -288,7 +272,9 @@ private: uint used_rows() const; void expand(); - size_t cstr_bufsize(Untaint_lang lang) const; + size_t cstr_bufsize(Untaint_lang lang, + SQL_Connection *connection, + const char *charset) const; /// convert to C string, store to 'dest' which must be big enough for proper untaint char *store_to(char *dest, Untaint_lang lang=UL_UNSPECIFIED, SQL_Connection *connection=0, @@ -305,5 +291,6 @@ private: //disabled String& operator = (const String&) { return *this; } }; +#include "pa_pragma_pack_end.h" #endif