summaryrefslogtreecommitdiff
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorNathan Warden <nathanwardenlee@icloud.com>2015-03-23 00:08:07 -0500
committerNathan Warden <nathanwardenlee@icloud.com>2015-03-23 00:08:07 -0500
commit21eb3b2a83fd59f6d667688c95b4a198b3b6f689 (patch)
tree017ed29e978a4d37701f5098d01cb0ec997255ab /core/ustring.cpp
parenta12c364489df586bf3cbb38f613c0615f88eaff1 (diff)
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 09d3d95b68..edb5da2bd2 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())