From 0cffdb7d1a7e0a51eeab5b1d9368706f10071106 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Tue, 14 Apr 2020 20:27:39 +0200 Subject: [PATCH] move reverse_string to string.hpp --- src/script/functions/basic.cpp | 8 -------- src/util/string.cpp | 9 +++++++++ src/util/string.hpp | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index 53d5ac1e..6c56d2dc 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -316,14 +316,6 @@ SCRIPT_FUNCTION(to_title) { SCRIPT_RETURN(capitalize(input.Lower())); } -String reverse_string(String const& input) { - // Note: std::reverse doesn't work because of unicode encoding stuff - String reversed; - for (auto it = input.rbegin(); it != input.rend(); ++it) { - reversed += *it; - } - return reversed; -} // reverse a string SCRIPT_FUNCTION(reverse) { SCRIPT_PARAM_C(String, input); diff --git a/src/util/string.cpp b/src/util/string.cpp index 3af273fc..b716453d 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -79,6 +79,15 @@ String replace_all(const String& heystack, const String& needle, const String& r return ret; } +String reverse_string(String const& input) { + // Note: std::reverse doesn't work because of unicode encoding stuff + String reversed; + for (auto it = input.rbegin(); it != input.rend(); ++it) { + reversed += *it; + } + return reversed; +} + // ----------------------------------------------------------------------------- : Words String last_word(const String& s) { diff --git a/src/util/string.hpp b/src/util/string.hpp index c1eaa1e5..771f87a3 100644 --- a/src/util/string.hpp +++ b/src/util/string.hpp @@ -132,6 +132,9 @@ String substr_replace(const String& input, size_t start, size_t end, const Strin /// Replace all occurences of one needle with replacement String replace_all(const String& heystack, const String& needle, const String& replacement); +/// Reverses a string, Note: std::reverse doesn't work with wxString +String reverse_string(String const& input); + // ----------------------------------------------------------------------------- : Words /// Returns the last word in a string