--- parser3/src/include/pa_string.h 2026/10/01 11:48:37 1.243 +++ parser3/src/include/pa_string.h 2026/11/01 14:41:57 1.245 @@ -8,7 +8,7 @@ #ifndef PA_STRING_H #define PA_STRING_H -#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.243 2026/10/01 11:48:37 moko Exp $" +#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.245 2026/11/01 14:41:57 moko Exp $" // includes #include "pa_types.h" @@ -92,7 +92,7 @@ class String: public PA_Object { public: /** piece is tainted or not. the lang to use when detaint - remember to change String_Untaint_lang_name @ untaint.C along + remember to change Name2lang_hash @ untaint.C along WARNING WARNING WARNING WARNING WARNING WARNING @@ -135,6 +135,11 @@ public: L_OPTIMIZE_BIT = 0x80 ///< flag, requiring cstr whitespace optimization }; + /// throws an exception for an unknown name + static Language name2lang(const String& name); + /// 0 if there is none + static const char* lang2name(Language lang); + enum Trim_kind { TRIM_BOTH, TRIM_START, @@ -490,6 +495,9 @@ public: return CORD_rchr(body, right, c); } + /// position of the last @a substr starting at or before @a offset, -1 means "not found" + size_t rpos(const Body substr, size_t offset) const; + size_t strrpbrk(const char* chars, size_t left, size_t right) const; size_t rskipchars(const char* chars, size_t left, size_t right) const; @@ -662,6 +670,7 @@ public: size_t pos(const Body substr, size_t this_offset, Language lang) const; size_t pos(const String& substr, size_t this_offset, Language lang) const; size_t pos(Charset& charset, const String& substr, size_t this_offset=0, Language lang=L_UNSPECIFIED) const; + size_t rpos(Charset& charset, const String& substr, size_t this_offset) const; /// true if the characters from offset to offset+length are of lang or a cleaner one bool check_lang(Language lang, size_t offset, size_t length) const { return langs.check_lang(lang, offset, length); }