|
|
| version 1.225, 2019/12/05 11:36:15 | version 1.232, 2024/03/14 03:17:01 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: string class decl. | Parser: string class decl. |
| Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| #ifndef PA_STRING_H | #ifndef PA_STRING_H |
| Line 47 class SQL_Connection; | Line 47 class SQL_Connection; |
| class Dictionary; | class Dictionary; |
| class Request_charsets; | class Request_charsets; |
| class String; | class String; |
| typedef Array<const String*> ArrayString; | |
| class VRegex; | class VRegex; |
| #ifdef NDEBUG | |
| typedef Array<const String*> ArrayString; | |
| #else | |
| class ArrayString : public Array<const String*> { | |
| public: | |
| inline ArrayString(size_t initial=0) : Array(initial){ | |
| } | |
| inline Array& operator+=(element_type src) { | |
| assert(src != NULL); | |
| return Array::operator+=(src); | |
| } | |
| inline element_type get(size_t index) const { | |
| element_type result=Array::get(index); | |
| assert(result != NULL); | |
| return result; | |
| } | |
| }; | |
| #endif | |
| // generally useful | // generally useful |
| int pa_atoi(const char* str, const String* problem_source=0); | double pa_atod(const char* str, const String* problem_source); |
| double pa_atod(const char* str, const String* problem_source=0); | int pa_atoi(const char* str, int base=10, const String* problem_source=0); |
| unsigned int pa_atoui(const char *str, int base, const String* problem_source=0); | unsigned int pa_atoui(const char *str, int base=10, const String* problem_source=0); |
| unsigned long long int pa_atoul(const char *str, int base, const String* problem_source=0); | uint64_t pa_atoul(const char *str, int base=10, const String* problem_source=0); |
| /// this is result of pos functions which mean that substr were not found | /// this is result of pos functions which mean that substr were not found |
| #define STRING_NOT_FOUND ((size_t)-1) | #define STRING_NOT_FOUND ((size_t)-1) |
| Line 683 public: | Line 702 public: |
| const String& replace(const Dictionary& dict) const; | const String& replace(const Dictionary& dict) const; |
| const String& trim(Trim_kind kind=TRIM_BOTH, const char* chars=0, Charset* source_charset=0) const; | const String& trim(Trim_kind kind=TRIM_BOTH, const char* chars=0, Charset* source_charset=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(), 0, this); } |
| bool as_bool() const { return as_int()!=0; } | bool as_bool() const { return as_int()!=0; } |
| const String& escape(Charset& source_charset) const; | const String& escape(Charset& source_charset) const; |