--- parser3/src/include/pa_string.h 2002/04/19 08:28:35 1.136 +++ parser3/src/include/pa_string.h 2003/03/17 14:48:05 1.144.4.1 @@ -1,15 +1,15 @@ /** @file Parser: string class 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) - - $Id: pa_string.h,v 1.136 2002/04/19 08:28:35 paf Exp $ */ #ifndef PA_STRING_H #define PA_STRING_H +static const char* IDENT_STRING_H="$Date: 2003/03/17 14:48:05 $"; + #include "pa_pool.h" #include "pa_types.h" @@ -67,7 +67,6 @@ 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: @@ -106,6 +105,7 @@ public: public: + static String& OnPool(Pool& apool, const char *local_src=0, size_t src_size=0, bool tainted=false); String(Pool& apool, const char *src=0, size_t src_size=0, bool tainted=false); String(const String& src); bool is_empty() const { return append_here==head.chunk.rows; } @@ -115,7 +115,7 @@ public: SQL_Connection *connection=0, Charset *cstr_charset=0, const char *cstr_charset_name=0) const { - char *result=(char *)malloc(cstr_bufsize(lang, connection, cstr_charset)); + char *result=(char *)malloc_atomic(cstr_bufsize(lang, connection, cstr_charset)); char *eol=store_to(result, lang, connection, cstr_charset, cstr_charset_name); *eol=0; return result; @@ -153,6 +153,11 @@ public: */ int cmp(int& partial, const char* src_ptr, size_t src_size=0, size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const; + /// this starts with src + bool starts_with(const char* src_ptr, size_t src_size=0) const { + int p; cmp(p, src_ptr, src_size); + return p==0 || p==2; + } bool operator == (const char* src_ptr) const { size_t src_size=src_ptr?strlen(src_ptr):0; if(size() != src_size) @@ -172,8 +177,10 @@ public: /// simple hash code of string. used by Hash uint hash_code() const; - /// extracts first char of a string - char first_char() const; + /// extracts first char of a string, if any + char first_char() const { + return is_empty()?0:*head.chunk.rows[0].item.ptr; + } /// extracts [start, finish) piece of string String& mid(size_t start, size_t finish) const; @@ -222,6 +229,8 @@ public: double as_double() const; int as_int() const; + String& join_chains(Pool& pool, char** cstr) const; + #ifndef NO_STRING_ORIGIN /// origin of string. calculated by first row const Origin& origin() const; @@ -296,7 +305,6 @@ private: //disabled String& operator = (const String&) { return *this; } }; -#include "pa_pragma_pack_end.h" #define STRING_PREPARED_FOREACH_ROW(self, body) \ while(row!=(self).append_here) { \