summaryrefslogtreecommitdiffstats
path: root/src/core/String.cpp
diff options
context:
space:
mode:
authorThomas Herzog <thomas.herzog@mail.com>2018-03-07 16:15:49 +0100
committerGitHub <noreply@github.com>2018-03-07 16:15:49 +0100
commitba1fbfa4d1c44670f729579dfe5612bf8475ed54 (patch)
treef3f742e19f7a9f9878383d85f7b16ac661de92e9 /src/core/String.cpp
parent779568c67c18ab190ba1950c517c279b7d12bf7a (diff)
parente74b8f593ecd412ee410f538ac88aa8b91d24b33 (diff)
downloadredot-cpp-ba1fbfa4d1c44670f729579dfe5612bf8475ed54.tar.gz
Merge pull request #109 from danielytics/easier-printing-and-formatting
adds variadic printing function, makes String.format custom placehold…
Diffstat (limited to 'src/core/String.cpp')
-rw-r--r--src/core/String.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/String.cpp b/src/core/String.cpp
index 3d822b1..737c040 100644
--- a/src/core/String.cpp
+++ b/src/core/String.cpp
@@ -267,13 +267,22 @@ int String::findn(String what, int from) const {
return godot::api->godot_string_findn(&_godot_string, what._godot_string);
}
-String String::format(Variant values, String placeholder) const {
+String String::format(Variant values) const {
String new_string;
new_string._godot_string = godot::api->godot_string_format(&_godot_string, (godot_variant *)&values);
return new_string;
}
+String String::format(Variant values, String placeholder) const {
+ String new_string;
+ godot_char_string contents = godot::api->godot_string_utf8(&placeholder._godot_string);
+ new_string._godot_string = godot::api->godot_string_format_with_custom_placeholder(&_godot_string, (godot_variant *)&values, godot::api->godot_char_string_get_data(&contents));
+ godot::api->godot_char_string_destroy(&contents);
+
+ return new_string;
+}
+
String String::get_base_dir() const {
String new_string;
new_string._godot_string = godot::api->godot_string_get_base_dir(&_godot_string);