aboutsummaryrefslogtreecommitdiff
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-04-07 20:22:09 -0300
committerJuan Linietsky2015-04-07 20:22:09 -0300
commite336306e9176bb3e9e459a63344ef54c1e57c9cd (patch)
tree020db36d856f01442056763596fb84b4035fccb3 /core/ustring.cpp
parent219fce737c05405db06cb268520d6abf0386db38 (diff)
parent21eb3b2a83fd59f6d667688c95b4a198b3b6f689 (diff)
downloadgodot-e336306e9176bb3e9e459a63344ef54c1e57c9cd.tar.gz
godot-e336306e9176bb3e9e459a63344ef54c1e57c9cd.tar.zst
godot-e336306e9176bb3e9e459a63344ef54c1e57c9cd.zip
Merge pull request #1554 from NateWardawg/inspectorupdate
Camel casing being capitalized only happens in the inspector now.
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 09d3d95b6..edb5da2bd 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -498,6 +498,27 @@ String String::capitalize() const {
return cap;
}
+
+String String::camelcase_to_underscore() const {
+ const CharType * cstr = c_str();
+ String newString;
+ const char A = 'A', Z = 'Z';
+ int startIndex = 0;
+
+ for ( int i = 1; i < this->size()-1; i++ ) {
+ bool isCapital = cstr[i] >= A && cstr[i] <= Z;
+
+ if ( isCapital ) {
+ newString += "_" + this->substr(startIndex, i-startIndex);
+ startIndex = i;
+ }
+ }
+
+ newString += "_" + this->substr(startIndex, this->size()-startIndex);
+
+ return newString;
+}
+
int String::get_slice_count(String p_splitter) const{
if (empty())