--- parser3/src/include/pa_string.h 2002/04/19 08:28:35 1.136 +++ parser3/src/include/pa_string.h 2002/08/08 08:43:38 1.142 @@ -3,13 +3,13 @@ Copyright (c) 2001, 2002 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: 2002/08/08 08:43:38 $"; + #include "pa_pool.h" #include "pa_types.h" @@ -106,6 +106,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; } @@ -153,6 +154,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 +178,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()?*head.chunk.rows[0].item.ptr:0; + } /// extracts [start, finish) piece of string String& mid(size_t start, size_t finish) const; @@ -222,6 +230,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;