|
|
| version 1.166, 2005/11/22 15:09:10 | version 1.178, 2009/04/22 04:37:52 |
|---|---|
| Line 36 class Dictionary; | Line 36 class Dictionary; |
| class Request_charsets; | class Request_charsets; |
| class String; | class String; |
| typedef Array<const String*> ArrayString; | typedef Array<const String*> ArrayString; |
| class VRegex; | |
| // generally useful | // generally useful |
| Line 57 inline size_t get_length(T current) { | Line 58 inline size_t get_length(T current) { |
| - whether they are tainted or not, | - whether they are tainted or not, |
| and the lang which should be used to detaint them | and the lang which should be used to detaint them |
| */ | */ |
| class String: public PA_Object { | class String: public PA_Object { |
| public: | public: |
| Line 77 public: | Line 80 public: |
| enum Language { | enum Language { |
| L_UNSPECIFIED=0, ///< no real string has parts of this lange: it's just convinient to check when string's empty | 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 | // these two must go before others, there are checks for >L_AS_IS |
| L_CLEAN='0', ///< clean WARNING: read above warning before changing | L_CLEAN='0', ///< clean WARNING: read above warning before changing |
| L_AS_IS='A', ///< leave all characters intact WARNING: read above warning before changing | L_AS_IS='A', ///< leave all characters intact WARNING: read above warning before changing |
| L_PASS_APPENDED='P', | L_PASS_APPENDED='P', |
| /**< | /**< |
| leave lang 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 |
| */ | */ |
| L_TAINTED='T', ///< tainted, untaint lang as assigned later | L_TAINTED='T', ///< tainted, untaint lang as assigned later |
| // untaint langs. assigned by ^untaint[lang]{...} | // untaint langs. assigned by ^untaint[lang]{...} |
| L_FILE_SPEC='F', ///< file specification | L_FILE_SPEC='F', ///< file specification |
| L_HTTP_HEADER='h', ///< text in HTTP response header | L_HTTP_HEADER='h', ///< text in HTTP response header |
| L_MAIL_HEADER='m', ///< text in mail header | L_MAIL_HEADER='m', ///< text in mail header |
| L_URI='U', ///< text in uri | L_URI='U', ///< text in uri |
| L_SQL='Q', ///< ^table:sql body | L_SQL='Q', ///< ^table:sql body |
| L_JS='J', ///< JavaScript code | L_JS='J', ///< JavaScript code |
| L_XML='X', ///< ^dom:set xml | L_XML='X', ///< ^dom:set xml |
| L_HTML='H', ///< HTML code | L_HTML='H', ///< HTML code |
| L_REGEX='R', ///< RegEx expression | L_REGEX='R', ///< RegEx expression |
| L_HTTP_COOKIE='C', ///< cookies encoded as %uXXXX for compartibility with js functions encode/decode | |
| L_FILE_POST='f', ///temporary escaping zero-char | |
| // READ WARNING ABOVE BEFORE ADDING ANYTHING | // READ WARNING ABOVE BEFORE ADDING ANYTHING |
| L_OPTIMIZE_BIT = 0x80 ///< flag, requiring cstr whitespace optimization | L_OPTIMIZE_BIT = 0x80 ///< flag, requiring cstr whitespace optimization |
| }; | }; |
| Line 106 public: | Line 111 public: |
| TRIM_END | TRIM_END |
| }; | }; |
| union Languages { | union Languages { |
| struct { | struct { |
| Line 180 public: | Line 186 public: |
| append(current, CORD_chars((char)alang, asize)); | append(current, CORD_chars((char)alang, asize)); |
| } | } |
| /// MUST be called exactly prior to modification of current [uses it's length] | |
| template<typename C> | template<typename C> |
| void append(C current, size_t appending_length, | void appendHelper(C current, Language alang, C asize_helper) { |
| const Languages src) { | assert(alang); |
| assert(appending_length); | |
| 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_helper.length())); | |
| } | |
| template<typename C> | |
| void appendHelper(C current, C length_helper, const Languages src) { | |
| if(!langs) | if(!langs) |
| langs=src.langs; // to uninitialized | langs=src.langs; // to uninitialized |
| else if(!src.opt.is_not_just_lang) | else if(!src.opt.is_not_just_lang) |
| append(current, src.opt.lang, appending_length); // simplifying when simple source | appendHelper(current, src.opt.lang, length_helper); // simplifying when simple source |
| else | else |
| append(current, src.make_langs(appending_length)); | append(current, src.make_langs(length_helper)); |
| } | } |
| /// MUST be called exactly prior to modification of current [uses it's length] | /// MUST be called exactly prior to modification of current [uses it's length] |
| template<typename C> | template<typename C> |
| void append(C current, | void append(C current, |
| Line 220 public: | Line 240 public: |
| if(opt.is_not_just_lang) | if(opt.is_not_just_lang) |
| return CORD_range_contains_chr_greater_then(langs, aoffset, alength, (unsigned)alang)==0; | return CORD_range_contains_chr_greater_then(langs, aoffset, alength, (unsigned)alang)==0; |
| else | else |
| return opt.lang<=alang; | return (unsigned)opt.lang<=(unsigned)alang; |
| } | } |
| /// @returns count of blocks | /// @returns count of blocks |
| Line 399 public: | Line 419 public: |
| bool is_empty() const { return body.is_empty(); } | bool is_empty() const { return body.is_empty(); } |
| size_t length() const { return body.length(); } | size_t length() const { return body.length(); } |
| size_t length(Charset& charset) const; | |
| /// convert to CORD. if 'lang' known, forcing 'lang' to it | /// convert to CORD. if 'lang' known, forcing 'lang' to it |
| Body cstr_to_string_body(Language lang=L_AS_IS, | Body cstr_to_string_body(Language lang=L_AS_IS, |
| Line 461 public: | Line 482 public: |
| /// extracts [start, finish) piece of string | /// extracts [start, finish) piece of string |
| String& mid(size_t substr_begin, size_t substr_end) const; | String& mid(size_t substr_begin, size_t substr_end) const; |
| String& mid(Charset& charset, size_t from, size_t to, size_t helper_length=0) const; | |
| /** | /** |
| ignore lang if it's L_UNSPECIFIED | ignore lang if it's L_UNSPECIFIED |
| Line 476 public: | Line 498 public: |
| size_t this_offset=0) const { | size_t this_offset=0) const { |
| return body.pos(c, this_offset); | return body.pos(c, this_offset); |
| } | } |
| size_t pos(Charset& charset, | |
| const String& substr, | |
| size_t this_offset=0, Language lang=L_UNSPECIFIED) const; | |
| void split(ArrayString& result, | void split(ArrayString& result, |
| size_t& pos_after, | size_t& pos_after, |
| Line 497 public: | Line 522 public: |
| prematch/match/postmatch/1/2/3/... | prematch/match/postmatch/1/2/3/... |
| @endverbatim | @endverbatim |
| */ | */ |
| Table* match(Charset& source_charset, | Table* match(VRegex* vregex, |
| const String& regexp, | |
| const String* options, | |
| Row_action row_action, void *info, | Row_action row_action, void *info, |
| bool& just_matched) const; | int& matches_count) const; |
| enum Change_case_kind { | enum Change_case_kind { |
| CC_UPPER, | CC_UPPER, |
| CC_LOWER | CC_LOWER |
| Line 512 public: | Line 535 public: |
| const String& trim(Trim_kind kind=TRIM_BOTH, const char* chars=0) const; | const String& trim(Trim_kind kind=TRIM_BOTH, const char* chars=0) const; |
| double as_double() const { return pa_atod(cstr(), this); } | double as_double() const { return pa_atod(cstr(), this); } |
| int as_int() const { return pa_atoi(cstr(), this); } | int as_int() const { return pa_atoi(cstr(), this); } |
| bool as_bool() const { return as_int()!=0; } | |
| const String& escape(Charset& source_charset) const; | |
| private: //disabled | private: //disabled |