summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 14:29:06 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit07bc4e2f96f8f47991339654ff4ab16acc19d44f (patch)
tree43cdc7cfe8239c23065616a931de3769d2db1e86 /core/ustring.cpp
parent0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (diff)
downloadredot-engine-07bc4e2f96f8f47991339654ff4ab16acc19d44f.tar.gz
Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 249a61f3f9..a1a2280066 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -247,6 +247,7 @@ String String::operator+(CharType p_chr) const {
res+=p_chr;
return res;
}
+
*/
String &String::operator+=(const String &p_str) {
if (empty()) {
@@ -607,6 +608,7 @@ String String::get_with_code_lines() const {
}
return ret;
}
+
int String::get_slice_count(String p_splitter) const {
if (empty())
return 0;
@@ -959,6 +961,7 @@ String String::chr(CharType p_char) {
CharType c[2] = { p_char, 0 };
return String(c);
}
+
String String::num(double p_num, int p_decimals) {
#ifndef NO_USE_STDLIB
@@ -1522,6 +1525,7 @@ String::String(CharType p_char) {
shared=nullptr;
copy_from(p_char);
}
+
*/
String::String(const char *p_str) {
@@ -2073,6 +2077,7 @@ String operator+(const char *p_chr, const String &p_str) {
tmp += p_str;
return tmp;
}
+
String operator+(CharType p_chr, const String &p_str) {
return (String::chr(p_chr) + p_str);
}
@@ -2217,6 +2222,7 @@ String String::insert(int p_at_pos, const String &p_string) const {
return pre + p_string + post;
}
+
String String::substr(int p_from, int p_chars) const {
if (p_chars == -1)
p_chars = length() - p_from;
@@ -2467,6 +2473,7 @@ int String::rfind(const String &p_str, int p_from) const {
return -1;
}
+
int String::rfindn(const String &p_str, int p_from) const {
// establish a limit
int limit = length() - p_str.length();
@@ -2540,6 +2547,7 @@ bool String::begins_with(const String &p_string) const {
// only if i == l the p_string matches the beginning
return i == l;
}
+
bool String::begins_with(const char *p_string) const {
int l = length();
if (l == 0 || !p_string)
@@ -2846,6 +2854,7 @@ String String::replace_first(const String &p_key, const String &p_with) const {
return *this;
}
+
String String::replacen(const String &p_key, const String &p_with) const {
String new_string;
int search_from = 0;
@@ -3110,6 +3119,7 @@ String String::humanize_size(uint64_t p_size) {
return String::num(p_size / divisor).pad_decimals(digits) + " " + prefixes[prefix_idx];
}
+
bool String::is_abs_path() const {
if (length() > 1)
return (operator[](0) == '/' || operator[](0) == '\\' || find(":/") != -1 || find(":\\") != -1);
@@ -3742,6 +3752,7 @@ String String::percent_encode() const {
return encoded;
}
+
String String::percent_decode() const {
CharString pe;
@@ -3824,6 +3835,7 @@ String String::rpad(int min_length, const String &character) const {
return s;
}
+
// Left-pad with a character.
String String::lpad(int min_length, const String &character) const {
String s = *this;