--- parser3/src/include/pa_string.h 2024/03/14 03:17:01 1.232 +++ parser3/src/include/pa_string.h 2025/05/26 00:52:15 1.237 @@ -1,14 +1,14 @@ /** @file Parser: string class decl. - Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ #ifndef PA_STRING_H #define PA_STRING_H -#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.232 2024/03/14 03:17:01 moko Exp $" +#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.237 2025/05/26 00:52:15 moko Exp $" // includes #include "pa_types.h" @@ -378,8 +378,8 @@ public: void dump() const; Body(): body(CORD_EMPTY) INIT_HASH_CODE(0) INIT_LENGTH(0) {} - Body(const char *abody): body(AS_CORD(abody)) INIT_HASH_CODE(0) INIT_LENGTH(0) {} - Body(CORD abody, uint ahash_code): body(abody) INIT_HASH_CODE(ahash_code) INIT_LENGTH(0) {} + explicit Body(const char *abody): body(AS_CORD(abody)) INIT_HASH_CODE(0) INIT_LENGTH(0) {} + explicit Body(CORD abody, uint ahash_code): body(abody) INIT_HASH_CODE(ahash_code) INIT_LENGTH(0) {} explicit Body(C ac): body(AS_CORD(ac.str)) INIT_HASH_CODE(0) INIT_LENGTH(ac.length) {} explicit Body(CORD abody): body(abody) INIT_HASH_CODE(0) INIT_LENGTH(0) { #ifdef CORD_CAT_OPTIMIZATION @@ -400,8 +400,7 @@ public: #endif } - - static Body Format(int value); + static Body uitoa(size_t aindex); void clear() { ZERO_LENGTH ZERO_HASH_CODE body=CORD_EMPTY; } @@ -652,17 +651,14 @@ public: 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 - 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); - } + /// return position of substr in string, -1 means "not found" [const char* version] + size_t pos(const char* substr, size_t this_offset=0) const { return body.pos(substr, this_offset); } + size_t pos(const Body substr, size_t this_offset=0) const { return body.pos(substr, this_offset); } + size_t pos(const String& substr, size_t this_offset=0) const { return body.pos(substr.body, this_offset); } + size_t pos(char c, size_t this_offset=0) const { return body.pos(c, this_offset); } + /// ignore lang if it's L_UNSPECIFIED, otherwise look for substring that lies in ONE fragment in THAT lang + 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 strrpbrk(const char* chars, size_t left=0) const {