diff options
| author | Juan Linietsky | 2015-05-04 13:24:02 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2015-05-04 13:24:02 -0300 |
| commit | fbbe7dcdfbd09fc6ef5614dea2183481a27e4f4e (patch) | |
| tree | 4e783f0e4347a2f612e6b85398c83a492d7b090f /core/ustring.cpp | |
| parent | 7f5b744b92256e42aa3c700ee88d8318732935c6 (diff) | |
| parent | 6f8bd899311d459b9e391b4acf72ccfa5cc1d806 (diff) | |
| download | godot-fbbe7dcdfbd09fc6ef5614dea2183481a27e4f4e.tar.gz godot-fbbe7dcdfbd09fc6ef5614dea2183481a27e4f4e.tar.zst godot-fbbe7dcdfbd09fc6ef5614dea2183481a27e4f4e.zip | |
Merge remote-tracking branch 'origin/master'
Conflicts:
drivers/windows/dir_access_windows.cpp
Diffstat (limited to 'core/ustring.cpp')
| -rw-r--r-- | core/ustring.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 09d3d95b6..ffd22c1f8 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -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()) |
