From eebeadbe479c45ea87f5814559e42f8da3749ab7 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 27 Apr 2024 18:53:54 +0200 Subject: [PATCH] Added more helper methods to StringBuilder. --- core/string/string_builder.cpp | 7 +++++++ core/string/string_builder.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/core/string/string_builder.cpp b/core/string/string_builder.cpp index 709f6bd0d..2c3dea772 100644 --- a/core/string/string_builder.cpp +++ b/core/string/string_builder.cpp @@ -57,6 +57,13 @@ StringBuilder &StringBuilder::append(const char *p_cstring) { return *this; } +void StringBuilder::clear() { + string_length = 0; + strings.clear(); + c_strings.clear(); + appended_strings.clear(); +} + String StringBuilder::as_string() const { if (string_length == 0) { return ""; diff --git a/core/string/string_builder.h b/core/string/string_builder.h index defdac261..446d392ba 100644 --- a/core/string/string_builder.h +++ b/core/string/string_builder.h @@ -50,6 +50,12 @@ public: StringBuilder &append(const String &p_string); StringBuilder &append(const char *p_cstring); + void clear(); + + _FORCE_INLINE_ uint32_t length() { + return string_length; + } + _FORCE_INLINE_ StringBuilder &operator+(const String &p_string) { return append(p_string); }