|
|
| version 1.80, 2001/04/11 08:36:16 | version 1.151, 2003/10/21 05:11:00 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: string class decl. | Parser: string class decl. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | |
| $Id$ | |
| */ | */ |
| #ifndef PA_STRING_H | #ifndef PA_STRING_H |
| #define PA_STRING_H | #define PA_STRING_H |
| #include "pa_config_includes.h" | static const char* IDENT_STRING_H="$Date$"; |
| #include <string.h> | // includes |
| #include <stddef.h> | |
| #include "pa_pool.h" | |
| #include "pa_types.h" | #include "pa_types.h" |
| #include "pa_array.h" | |
| class Table; | extern "C" { // cord's author forgot to do that |
| #define CORD_NO_IO | |
| #include "cord.h" | |
| }; | |
| /** | // cord extension |
| $MAIN:html-typo table elements must enlarge string not more that that | /* Returns true if x does contain */ |
| that's a tradeoff - otherwise we'd have to scan string twice: | /* char not_c at positions i..i+n. Value i,i+n must be < CORD_len(x). */ |
| - first for buffer length | int CORD_range_contains_chr_greater_then(CORD x, size_t i, size_t n, int c); |
| - second for replacements themselves | size_t CORD_block_count(CORD x); |
| */ | |
| #define UNTAINT_TIMES_BIGGER 10 | |
| #ifndef NO_STRING_ORIGIN | // forwards |
| # define STRING_APPEND_PARAMS \ | |
| const char *src, size_t size, \ | |
| String::Untaint_lang lang, \ | |
| const char *file, uint line | |
| /// appends piece to String @see String::real_append | |
| # define APPEND(src, size, lang, file, line) \ | |
| real_append(src, size, lang, file, line) | |
| #else | |
| # define STRING_APPEND_PARAMS \ | |
| const char *src, \ | |
| size_t size, \ | |
| String::Untaint_lang lang | |
| /// appends piece to String @see String::real_append | |
| # define APPEND(src, size, lang, file, line) \ | |
| real_append(src, size, lang) | |
| #endif | |
| /// appends clean piece to String @see String::real_append | |
| #define APPEND_CLEAN(src, size, file, line) \ | |
| APPEND(src, size, String::UL_CLEAN, file, line) | |
| /// appends tainted piece to String @see String::real_append | |
| #define APPEND_TAINTED(src, size, file, line) \ | |
| APPEND(src, size, String::UL_TAINTED, file, line) | |
| /// handy: appends const char* piece to String @see String::real_append | |
| #define APPEND_CONST(src) APPEND_CLEAN(src, 0, 0, 0) | |
| class Array; | class Charset; |
| class Table; | |
| class SQL_Connection; | class SQL_Connection; |
| class Dictionary; | |
| class Request_charsets; | |
| class String; | |
| typedef Array<const String*> ArrayString; | |
| /// this is result of pos functions which mean that substr were not found | |
| #define STRING_NOT_FOUND ((size_t)-1) | |
| template<typename T> | |
| inline size_t get_length(T current) { | |
| return current; | |
| } | |
| /** | /** |
| Pooled string. | String which knows the lang of all it's langs. |
| Internal structure: | |
| @verbatim | |
| String Chunk0 | |
| ====== ======== | |
| head--------------->[ptr, size, ...] | |
| append_here-------->[ptr, size, ...] | |
| . | |
| . | |
| [ptr, size, ...] | |
| link_row----------->[link to the next chunk] | |
| @endverbatim | |
| All pieces remember | All pieces remember |
| - the file and its line they are from [can be turned off by NO_STRING_ORIGIN] | |
| - whether they are tainted or not, | - whether they are tainted or not, |
| and the language which should be used to detaint them | and the lang which should be used to detaint them |
| */ | */ |
| class String : public Pooled { | class String: public PA_Object { |
| public: | public: |
| enum { | /** piece is tainted or not. the lang to use when detaint |
| CR_PREALLOCATED_COUNT=5, ///< default preallocated item count | remember to change String_Untaint_lang_name @ untaint.C along |
| CR_GROW_PERCENT=60 ///< each time the Array chunk_is_full() array expanded() | |
| }; | WARNING WARNING WARNING WARNING WARNING WARNING |
| pos function compares(<=) languages, that is used in searching | |
| for table column separator being L_CLEAN or L_AS_IS. | |
| they search for AS_IS, meaning AS_IS|CLEAN [doing <=L_AS_IS check]. | |
| letters assigned for debugging, but it's important for no language-letter | |
| come before L_AS_IS other then L_CLEAN | |
| WARNING WARNING WARNING WARNING WARNING WARNING | |
| */ | |
| enum Language { | |
| L_UNSPECIFIED=0, ///< no real string has parts of this lange: it's just convinient to check when string's empty | |
| // these two must go before others, there are checks for >L_AS_IS | |
| L_CLEAN='0', ///< clean WARNING: read above warning before changing | |
| L_AS_IS='A', ///< leave all characters intact WARNING: read above warning before changing | |
| /// piece is tainted or not. the language to use when detaint | L_PASS_APPENDED='P', |
| enum Untaint_lang { | |
| UL_UNSPECIFIED=0, ///< zero value handy for hash lookup @see untaint_lang_name2enum | |
| UL_CLEAN, ///< clean | |
| UL_TAINTED, ///< tainted, untaint language as assigned later | |
| // untaint languages. assigned by ^untaint[lang]{...} | |
| UL_PASS_APPENDED, | |
| /**< | /**< |
| leave language built into string being appended. | leave lang built into string being appended. |
| just a flag, that value not stored | just a flag, that value not stored |
| */ | */ |
| UL_AS_IS, ///< leave all characters intact | L_TAINTED='T', ///< tainted, untaint lang as assigned later |
| UL_FILE_NAME, ///< filename | // untaint langs. assigned by ^untaint[lang]{...} |
| UL_HTTP_HEADER, ///< text in HTTP response header | L_FILE_SPEC='F', ///< file specification |
| UL_MAIL_HEADER, ///< text in mail header | L_HTTP_HEADER='h', ///< text in HTTP response header |
| UL_URI, ///< text in uri | L_MAIL_HEADER='m', ///< text in mail header |
| UL_TABLE, ///< ^table:set body | L_URI='U', ///< text in uri |
| UL_SQL, ///< ^table:sql body | L_TABLE='L', ///< ^table:set body |
| UL_JS, ///< JavaScript code | L_SQL='Q', ///< ^table:sql body |
| UL_HTML, ///< HTML code (for editing) | L_JS='J', ///< JavaScript code |
| UL_HTML_TYPO ///< HTML code with TYPOgraphic replacements (for showing) | L_XML='X', ///< ^dom:set xml |
| L_HTML='H', ///< HTML code (for editing) | |
| // READ WARNING ABOVE BEFORE ADDING ANYTHING | |
| L_OPTIMIZE_BIT = 0x80 ///< flag, requiring cstr whitespace optimization | |
| }; | }; |
| public: | union Languages { |
| String(Pool& apool, const char *src=0, size_t src_size=0, bool tainted=false); | struct { |
| String(const String& src); | Language lang:8; |
| size_t size() const { return fsize; } | int is_not_just_lang:sizeof(CORD)*8-8; |
| /// convert to C string. if 'lang' known, forcing 'lang' to it | } opt; |
| char *cstr(Untaint_lang lang=UL_UNSPECIFIED, SQL_Connection *connection=0) const { | CORD langs; |
| char *result=(char *)malloc(size()*UNTAINT_TIMES_BIGGER+1); | |
| char *eol=store_to(result, lang, connection); | template<typename C> |
| *eol=0; | CORD make_langs(C current) const { |
| return result; | return opt.is_not_just_lang? |
| } | langs |
| /** append fragment | :CORD_chars((char)opt.lang, get_length(current)); |
| @see APPEND_CLEAN, APPEND_TAINTED, APPEND_CONST | } |
| */ | |
| String& real_append(STRING_APPEND_PARAMS); | CORD make_langs(size_t aoffset, size_t alength) const { |
| /// @return <0 ==0 or >0 depending on comparison result | return opt.is_not_just_lang? |
| int cmp (int& partial, const String& src, | CORD_substr(langs, aoffset, alength) |
| size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const; | :CORD_chars((char)opt.lang, alength); |
| bool operator < (const String& src) const { int p; return cmp(p, src)<0; } | } |
| bool operator > (const String& src) const { int p; return cmp(p, src)>0; } | |
| bool operator <= (const String& src) const { int p; return cmp(p, src)<=0; } | /// appending when 'langs' already contain something [simple cases hanled elsewhere] |
| bool operator >= (const String& src) const { int p; return cmp(p, src)>=0; } | template<typename C> |
| bool operator == (const String& src) const { | void append(C current, |
| if(size()!=src.size()) // can speed up in trivial case | const CORD to_nonempty_target_langs) { |
| return false; | assert(langs); |
| int p; return cmp(p, src)==0; | |
| } | if(opt.is_not_just_lang) |
| bool operator != (const String& src) const { int p; return cmp(p, src)!=0; } | langs=CORD_cat(langs, to_nonempty_target_langs); |
| else { // we were "just lang" | |
| /** | size_t current_size=get_length(current); |
| @param partial | assert(current_size); |
| returns partial match status. | langs=CORD_cat( |
| - -1: strings too different | CORD_chars((char)opt.lang, current_size), // first piece [making from just 'lang'] |
| - 0: full match | to_nonempty_target_langs); // new piece |
| - 1: means @c this starts @c src | } |
| - 2: means @src starts @this | } |
| */ | |
| int cmp(int& partial, const char* src_ptr, size_t src_size=0, | public: |
| size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const; | |
| bool operator == (const char* src_ptr) const { | const char* v() const; |
| size_t src_size=src_ptr?strlen(src_ptr):0; | |
| if(size() != src_size) | Languages(): langs(0) {} |
| return false; | Languages(Language alang) { |
| int partial; // unused | opt.lang=alang; |
| return cmp(partial, src_ptr, src_size)==0; | opt.is_not_just_lang=0; |
| } | } |
| bool operator != (const char* src_ptr) const { | |
| int partial; // unused | /// MUST be called exactly prior to modification of current [uses it's length] |
| return cmp(partial, src_ptr, 0)!=0; | template<typename C> |
| } | void append(C current, Language alang, size_t asize) { |
| assert(alang); | |
| assert(asize); | |
| if(!opt.is_not_just_lang) | |
| if(opt.lang) { | |
| if(opt.lang==alang) // same length? ignoring | |
| return; | |
| } else { | |
| opt.lang=alang; // to uninitialized | |
| return; | |
| } | |
| append(current, CORD_chars((char)alang, asize)); | |
| } | |
| /// MUST be called exactly prior to modification of current [uses it's length] | |
| template<typename C> | |
| void append(C current, size_t appending_length, | |
| const Languages src) { | |
| assert(appending_length); | |
| if(!langs) | |
| langs=src.langs; // to uninitialized | |
| else if(!src.opt.is_not_just_lang) | |
| append(current, src.opt.lang, appending_length); // simplifying when simple source | |
| else | |
| append(current, src.make_langs(appending_length)); | |
| } | |
| /// MUST be called exactly prior to modification of current [uses it's length] | |
| template<typename C> | |
| void append(C current, | |
| const Languages src, size_t aoffset, size_t alength) { | |
| assert(alength); | |
| if(!langs) // to uninitialized? | |
| if(src.opt.is_not_just_lang) | |
| langs=CORD_substr(src.langs, aoffset, alength); // to uninitialized complex | |
| else | |
| opt.lang=src.opt.lang; // to uninitialized simple | |
| else | |
| if(!opt.is_not_just_lang && !src.opt.is_not_just_lang && opt.lang==src.opt.lang) // both simple & of same language? | |
| return; // ignoring | |
| else | |
| append(current, src.make_langs(aoffset, alength)); | |
| } | |
| /// checks if we have lang<=alang all from aoffset to aoffset+alength | |
| bool check_lang(Language alang, size_t aoffset, size_t alength) const { | |
| if(alang==L_UNSPECIFIED) // ignore lang? | |
| return true; | |
| if(opt.is_not_just_lang) | |
| return CORD_range_contains_chr_greater_then(langs, aoffset, alength, (unsigned)alang)==0; | |
| else | |
| return opt.lang<=alang; | |
| } | |
| /// @returns count of blocks | |
| /// @todo currently there can be adjucent blocks of same language. someday merge them | |
| size_t count() const { | |
| return opt.is_not_just_lang? | |
| CORD_block_count(langs) | |
| : opt.lang? | |
| 1 | |
| : 0; | |
| }; | |
| template<typename C, typename I> | |
| void for_each(C current, | |
| int callback(char, size_t, I), I info) const { | |
| if(opt.is_not_just_lang) | |
| CORD_block_iter(langs, 0, (CORD_block_iter_fn)callback, info); | |
| else | |
| callback(opt.lang, get_length(current), info); | |
| } | |
| bool invariant(size_t current_length) { | |
| if(!langs) | |
| return current_length==0; | |
| if(opt.is_not_just_lang) | |
| return CORD_len(langs)==current_length; | |
| return true; // uncheckable, actually | |
| } | |
| }; | |
| class Body { | |
| /** | CORD body; |
| appends other String. | |
| marking all tainted pieces of it with @a lang. | public: |
| or marking ALL pieces of it with a @a lang when @a forced to. | |
| */ | |
| String& append(const String& src, Untaint_lang lang, bool forced=false); | |
| String& operator << (const String& src) { return append(src, UL_PASS_APPENDED); } | |
| String& operator << (const char *src) { return APPEND_CONST(src); } | |
| /// simple hash code of string. used by Hash | const char* v() const; |
| uint hash_code() const; | |
| /// extracts [start, finish) piece of string | Body(): body(CORD_EMPTY) {} |
| String& mid(size_t start, size_t finish) const; | Body(CORD abody): body(abody) { |
| assert(!body // no body | |
| || *body // ordinary string | |
| || body[1]==1 // CONCAT_HDR | |
| || body[1]==4 // FN_HDR | |
| || body[1]==6 // SUBSTR_HDR | |
| ); | |
| } | |
| /// WARNING: length is only HELPER length, str in ANY case should be zero-terminated | |
| Body(const char* str, size_t helper_length): body(CORD_EMPTY) { | |
| append_know_length(str, helper_length?helper_length:strlen(str)); | |
| } | |
| static Body Format(int value); | |
| void clear() { body=CORD_EMPTY; } | |
| bool operator! () const { return is_empty(); } | |
| uint hash_code() const; | |
| const char* cstr() const { return CORD_to_const_char_star(body); } | |
| char* cstrm() const { return CORD_to_char_star(body); } | |
| size_t length() const { return CORD_len(body); } | |
| bool is_empty() const { return body==CORD_EMPTY; } | |
| void append_know_length(const char *str, size_t known_length) { | |
| if(known_length) | |
| body=CORD_cat_char_star(body, str, known_length); | |
| } | |
| void append_strdup_know_length(const char* str, size_t known_length) { | |
| if(known_length) | |
| append_know_length(pa_strdup(str, known_length), known_length); | |
| } | |
| void append(char c) { body=CORD_cat_char(body, c); } | |
| Body& operator << (const Body src) { body=CORD_cat(body, src.body); return *this; } | |
| Body& operator << (const char* str) { append_know_length(str, strlen(str)); return *this; } | |
| // could not figure out why this operator is needed [should do this chain: string->simple->==] | |
| bool operator < (const Body src) const { return CORD_cmp(body, src.body)<0; } | |
| bool operator > (const Body src) const { return CORD_cmp(body, src.body)>0; } | |
| bool operator <= (const Body src) const { return CORD_cmp(body, src.body)<=0; } | |
| bool operator >= (const Body src) const { return CORD_cmp(body, src.body)>=0; } | |
| bool operator != (const Body src) const { return CORD_cmp(body, src.body)!=0; } | |
| bool operator == (const Body src) const { return CORD_cmp(body, src.body)==0; } | |
| int ncmp(size_t x_begin, const Body y, size_t y_begin, size_t size) const { | |
| return CORD_ncmp(body, x_begin, y.body, y_begin, size); | |
| } | |
| char fetch(size_t index) const { return CORD_fetch(body, index); } | |
| Body mid(size_t index, size_t length) const { return CORD_substr(body, index, length); } | |
| size_t pos(const char* substr, size_t offset=0) const { return CORD_str(body, offset, substr); } | |
| size_t pos(const Body substr, size_t offset=0) const { | |
| if(!substr.length()) | |
| return STRING_NOT_FOUND; // in this case CORD_str returns 0 [parser users got used to -1] | |
| // CORD_str checks for bad offset [CORD_chr does not] | |
| return CORD_str(body, offset, substr.body); | |
| } | |
| size_t pos(char c, | |
| size_t offset=0) const { | |
| if(offset>=length()) // CORD_chr does not check that [and ABORT's in that case] | |
| return STRING_NOT_FOUND; | |
| return CORD_chr(body, offset, c); | |
| } | |
| template<typename I> void for_each( | |
| int (*f1)(char c, I), | |
| int (*f2)(const char* s, I), | |
| I info) const { | |
| CORD_iter5(body, 0, (CORD_iter_fn)f1, (CORD_batched_iter_fn)f2, info); | |
| } | |
| void set_pos(CORD_pos& pos, size_t index) const { CORD_set_pos(pos, body, index); } | |
| /*Body normalize() const { | |
| return Body(CORD_balance(body)); | |
| }*/ | |
| }; | |
| /// @return position of substr in string, -1 means "not found" [String version] | struct C { |
| int pos(const String& substr, | const char *str; |
| size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const; | size_t length; |
| /// @return position of substr in string, -1 means "not found" [const char* version] | operator const char *() { return str; } |
| int pos(const char *substr, size_t substr_size, | C(const char *astr, size_t asize): str(astr), length(asize) {} |
| size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const; | }; |
| void split(Array& result, | |
| size_t *pos_after_ref, | |
| const char *delim, size_t delim_size, | |
| Untaint_lang lang, int limit=-1) const; | |
| void split(Array& result, | |
| size_t *pos_after_ref, | |
| const String& delim, | |
| Untaint_lang lang, int limit=-1) const; | |
| typedef void (*Row_action)(Table& table, Array *row, int start, int finish, | struct Cm { |
| void *info); | char *str; |
| bool match(const String *aorigin, | size_t length; |
| const String& regexp, | //operator char *() { return str; } |
| const String *options, | Cm(char *astr, size_t asize): str(astr), length(asize) {} |
| Table **table, | }; |
| Row_action row_action, void *info) const; | |
| #ifndef NO_STRING_ORIGIN | |
| /// origin of string. calculated by first row | |
| const Origin& origin() const; | |
| #endif | |
| private: | private: |
| struct Chunk { | Languages langs; ///< string characters lang |
| // the number of rows in chunk | Body body; ///< all characters of string |
| size_t count; | |
| union Row { | const char* v() const; |
| // fragment | |
| struct { | #define ASSERT_STRING_INVARIANT(string) \ |
| const char *ptr; // pointer to the start | assert((string).langs.invariant((string).body.length())) |
| size_t size; // length | |
| Untaint_lang lang; // untaint flag, later untaint language | public: |
| #ifndef NO_STRING_ORIGIN | |
| Origin origin; // origin | static const String Empty; |
| #endif | |
| } item; | explicit String(const char* cstr=0, size_t helper_length=0, bool tainted=false); |
| Chunk *link; // link to the next chunk in chain | explicit String(const C cstr, bool tainted=false); |
| } rows[CR_PREALLOCATED_COUNT]; | String(Body abody, Language alang): body(abody), langs(alang) { |
| // next rows are here | assert(!body.is_empty()); |
| Chunk *preallocated_link; | ASSERT_STRING_INVARIANT(*this); |
| } | |
| String(const String& src): body(src.body), langs(src.langs) { | |
| ASSERT_STRING_INVARIANT(*this); | |
| } | } |
| head; // the head chunk of the chunk chain | |
| // next append would write to this record | /// for convinient hash lookup |
| Chunk::Row *append_here; | operator const Body() const { return body; } |
| // the address of place where lies address | |
| // of the link to the next chunk to allocate | |
| Chunk::Row *link_row; | |
| private: | bool is_empty() const { return body.is_empty(); } |
| // last chunk | size_t length() const { return body.length(); } |
| Chunk *last_chunk; | |
| /// convert to CORD. if 'lang' known, forcing 'lang' to it | |
| Body cstr_to_string_body(Language lang=L_AS_IS, | |
| SQL_Connection* connection=0, | |
| const Request_charsets *charsets=0) const; | |
| /// convert to constant C string. if 'lang' known, forcing 'lang' to it | |
| const char* cstr(Language lang=L_AS_IS, | |
| SQL_Connection* connection=0, | |
| const Request_charsets *charsets=0) const { | |
| return cstr_to_string_body(lang, connection, charsets).cstr(); | |
| } | |
| /// convert to Modifiable C string. if 'lang' known, forcing 'lang' to it | |
| char *cstrm(Language lang=L_AS_IS, | |
| SQL_Connection* connection=0, | |
| const Request_charsets *charsets=0) const { | |
| return cstr_to_string_body(lang, connection, charsets).cstrm(); | |
| } | |
| /// puts pieces to buf | |
| Cm serialize(size_t prolog_size) const; | |
| /// appends pieces from buf to self | |
| bool deserialize(size_t prolog_size, void *buf, size_t buf_size); | |
| /// @see Body::append_know_length | |
| String& append_know_length(const char* str, size_t known_length, Language lang); | |
| /// @see Body::append_help_length | |
| String& append_help_length(const char* str, size_t helper_length, Language lang); | |
| String& append_strdup(const char* str, size_t helper_length, Language lang); | |
| bool operator == (const char* y) const { return body==Body(y); } | |
| bool operator != (const char* y) const { return body!=Body(y); } | |
| /// this starts with y | |
| bool starts_with(const char* y) const { | |
| return body.ncmp(0/*x_begin*/, Body(y), 0/*y_begin*/, strlen(y))==0; | |
| } | |
| /// x starts with this | |
| bool this_starts(const char* x) const { | |
| return Body(x).ncmp(0/*x_begin*/, body, 0/*y_begin*/, length())==0; | |
| } | |
| // string size | String& append_to(String& dest, Language lang, bool forced) const; |
| size_t fsize; | String& append(const String& src, Language lang, bool forced=false) { |
| return src.append_to(*this, lang, forced); | |
| } | |
| String& operator << (const String& src) { return append(src, L_PASS_APPENDED); } | |
| String& operator << (const char* src) { return append_help_length(src, 0, L_AS_IS); } | |
| String& operator << (const Body src); | |
| /// extracts first char of a string, if any | |
| char first_char() const { | |
| return is_empty()?0:body.fetch(0); | |
| } | |
| // used rows in all chunks | bool operator < (const String& src) const { return body<src.body; } |
| int fused_rows; | bool operator > (const String& src) const { return body>src.body; } |
| bool operator <= (const String& src) const { return body<=src.body; } | |
| bool operator >= (const String& src) const { return body>=src.body; } | |
| bool operator != (const String& src) const { return body!=src.body; } | |
| bool operator == (const String& src) const { return body==src.body; } | |
| private: | /// extracts [start, finish) piece of string |
| String& mid(size_t substr_begin, size_t substr_end) const; | |
| bool chunk_is_full() { | /** |
| return append_here == link_row; | ignore lang if it's L_UNSPECIFIED |
| but when specified: look for substring that lies in ONE fragment in THAT lang | |
| @return position of substr in string, -1 means "not found" [const char* version] | |
| */ | |
| size_t pos(const Body substr, | |
| size_t this_offset=0, Language lang=L_UNSPECIFIED) const; | |
| /// String version of @see pos(const char*, int, Language) | |
| size_t pos(const String& substr, | |
| size_t this_offset=0, Language lang=L_UNSPECIFIED) const; | |
| size_t pos(char c, | |
| size_t this_offset=0) const { | |
| return body.pos(c, this_offset); | |
| } | } |
| void expand(); | |
| /// convert to C string, store to 'dest' which must be big enough for proper untaint | void split(ArrayString& result, |
| char *store_to(char *dest, | size_t& pos_after, |
| Untaint_lang lang=UL_UNSPECIFIED, SQL_Connection *connection=0) const; | const char* delim, |
| Language lang=L_UNSPECIFIED, int limit=-1) const; | |
| void split(ArrayString& result, | |
| size_t& pos_after, | |
| const String& delim, | |
| Language lang=L_UNSPECIFIED, int limit=-1) const; | |
| typedef void (*Row_action)(Table& table, ArrayString* row, | |
| int prestart, int prefinish, | |
| int poststart, int postfinish, | |
| void *info); | |
| /** | |
| @return table of found items, if any. | |
| table format is defined and fixed[can be used by others]: | |
| @verbatim | |
| prematch/match/postmatch/1/2/3/... | |
| @endverbatim | |
| */ | |
| Table* match(Charset& source_charset, | |
| const String& regexp, | |
| const String* options, | |
| Row_action row_action, void *info, | |
| bool& just_matched) const; | |
| enum Change_case_kind { | |
| CC_UPPER, | |
| CC_LOWER | |
| }; | |
| String& change_case(Charset& source_charset, | |
| Change_case_kind kind) const; | |
| const String& replace(const Dictionary& dict) const; | |
| double as_double() const; | |
| int as_int() const; | |
| private: //disabled | private: //disabled |
| Line 263 private: //disabled | Line 486 private: //disabled |
| }; | }; |
| template<> | |
| inline size_t get_length<String::Body>(String::Body body) { | |
| return body.length(); | |
| } | |
| /// simple hash code of string. used by Hash | |
| inline uint hash_code(const String::Body self) { | |
| return self.hash_code(); | |
| } | |
| /// now that we've declared specialization we can use it | |
| inline String& String::operator << (const String::Body src) { | |
| langs.append(body, L_AS_IS, src.length()); | |
| body<<src; | |
| return *this; | |
| } | |
| #endif | #endif |