summaryrefslogtreecommitdiff
path: root/core/ustring.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/ustring.h')
-rw-r--r--core/ustring.h35
1 files changed, 21 insertions, 14 deletions
diff --git a/core/ustring.h b/core/ustring.h
index a56c90544a..1bb4719b85 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -93,8 +93,8 @@ public:
bool operator!=(const CharType *p_str) const;
bool operator<(const CharType *p_str) const;
bool operator<(const char *p_str) const;
- bool operator<(String p_str) const;
- bool operator<=(String p_str) const;
+ bool operator<(const String &p_str) const;
+ bool operator<=(const String &p_str) const;
signed char casecmp_to(const String &p_str) const;
signed char nocasecmp_to(const String &p_str) const;
@@ -103,15 +103,19 @@ public:
const CharType *c_str() const;
/* standard size stuff */
- int length() const;
+ _FORCE_INLINE_ int length() const {
+ int s = size();
+ return s ? (s - 1) : 0; // length does not include zero
+ }
/* complex helpers */
String substr(int p_from, int p_chars) const;
- int find(String p_str, int p_from = 0) const; ///< return <0 if failed
- int find_last(String p_str) const; ///< return <0 if failed
- int findn(String p_str, int p_from = 0) const; ///< return <0 if failed, case insensitive
- int rfind(String p_str, int p_from = -1) const; ///< return <0 if failed
- int rfindn(String p_str, int p_from = -1) const; ///< return <0 if failed, case insensitive
+ int find(const String &p_str, int p_from = 0) const; ///< return <0 if failed
+ int find(const char *p_str, int p_from) const; ///< return <0 if failed
+ int find_last(const String &p_str) const; ///< return <0 if failed
+ int findn(const String &p_str, int p_from = 0) const; ///< return <0 if failed, case insensitive
+ int rfind(const String &p_str, int p_from = -1) const; ///< return <0 if failed
+ int rfindn(const String &p_str, int p_from = -1) const; ///< return <0 if failed, case insensitive
int findmk(const Vector<String> &p_keys, int p_from = 0, int *r_key = NULL) const; ///< return <0 if failed
bool match(const String &p_wildcard) const;
bool matchn(const String &p_wildcard) const;
@@ -125,10 +129,11 @@ public:
Vector<String> bigrams() const;
float similarity(const String &p_string) const;
String format(const Variant &values, String placeholder = "{_}") const;
- String replace_first(String p_key, String p_with) const;
- String replace(String p_key, String p_with) const;
- String replacen(String p_key, String p_with) const;
- String insert(int p_at_pos, String p_string) const;
+ String replace_first(const String &p_key, const String &p_with) const;
+ String replace(const String &p_key, const String &p_with) const;
+ String replace(const char *p_key, const char *p_with) const;
+ String replacen(const String &p_key, const String &p_with) const;
+ String insert(int p_at_pos, const String &p_string) const;
String pad_decimals(int p_digits) const;
String pad_zeros(int p_digits) const;
String lpad(int min_length, const String &character = " ") const;
@@ -162,7 +167,7 @@ public:
String get_slice(String p_splitter, int p_slice) const;
String get_slicec(CharType p_splitter, int p_slice) const;
- Vector<String> split(const String &p_splitter, bool p_allow_empty = true) const;
+ Vector<String> split(const String &p_splitter, bool p_allow_empty = true, int p_maxsplit = 0) const;
Vector<String> split_spaces() const;
Vector<float> split_floats(const String &p_splitter, bool p_allow_empty = true) const;
Vector<float> split_floats_mk(const Vector<String> &p_splitters, bool p_allow_empty = true) const;
@@ -204,7 +209,7 @@ public:
Vector<uint8_t> md5_buffer() const;
Vector<uint8_t> sha256_buffer() const;
- inline bool empty() const { return length() == 0; }
+ _FORCE_INLINE_ bool empty() const { return length() == 0; }
// path functions
bool is_abs_path() const;
@@ -242,6 +247,8 @@ public:
*/
/* String(CharType p_char);*/
inline String() {}
+ inline String(const String &p_str) :
+ Vector(p_str) {}
String(const char *p_str);
String(const CharType *p_str, int p_clip_to_len = -1);
String(const StrRange &p_range);