4#include "../Strings/StringFormat.h"
8struct StringBuilderFor;
29 template <
typename T>
static StringBuilderFor<T> create(T& stringOrBuffer)
noexcept {
return {stringOrBuffer, StringBuilder::Clear}; }
35 template <
typename T,
typename... Types>
36 [[nodiscard]]
static bool format(T& buffer,
StringView fmt, Types&&... args) {
return StringBuilder::create(buffer).append(fmt, forward<Types>(args)...); }
40 template <
typename... Types>
86 StringBuilder(IGrowableBuffer& ibuffer, StringEncoding encoding, Flags flags)
noexcept;
87 void initWithEncoding(IGrowableBuffer& bufferT, StringEncoding stringEncoding, Flags flags)
noexcept;
89 IGrowableBuffer* buffer =
nullptr;
90 StringEncoding encoding;
98 GrowableBuffer<T> growableBuffer;
102 initWithEncoding(growableBuffer, GrowableBuffer<T>::getEncodingFor(stringOrBuffer), flags);
112 growableBuffer.finalize();
113 finalizedView = {{buffer->data(), buffer->size()},
true, encoding};
124 return finalizedView;
#define SC_ASSERT_RELEASE(e)
Assert expression e to be true.
Definition Assert.h:42
Parse and compose filesystem paths for windows and posix.
Definition Path.h:16
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
StringBuilder tied to a specific type, created through StringBuilder::create or StringBuilder::create...
Definition StringBuilder.h:97
StringView view() noexcept
Returns the resulting StringView after finalize.
Definition StringBuilder.h:121
StringView finalize() noexcept
Finalizes the StringBuilder, returning the resulting StringView.
Definition StringBuilder.h:108
Builds String out of a sequence of StringView or formatting through StringFormat.
Definition StringBuilder.h:26
Flags
Definition StringBuilder.h:79
@ Clear
Destination buffer will be cleared before pushing to it.
Definition StringBuilder.h:80
bool append(StringView str)
Appends StringView to destination buffer.
AppendHexCase
Option for StringBuilder::appendHex.
Definition StringBuilder.h:64
bool appendHex(Span< const uint8_t > data, AppendHexCase casing)
Appends given binary data escaping it as hexadecimal ASCII characters.
static StringBuilderFor< T > create(T &stringOrBuffer) noexcept
Creates a StringBuilder for the given string or buffer, replacing its current contents.
Definition StringBuilder.h:29
bool appendReplaceAll(StringView source, StringView occurrencesOf, StringView with)
Appends source to destination buffer, replacing occurrencesOf StringView with StringView with
static StringBuilderFor< T > createForAppendingTo(T &stringOrBuffer) noexcept
Creates a StringBuilder for the given string or buffer, appending to its current contents.
Definition StringBuilder.h:32
static bool format(T &buffer, StringView fmt, Types &&... args)
Helper to format a StringView against args, replacing destination contents, in a single function call...
Definition StringBuilder.h:36
bool append(StringView fmt, Types &&... args)
Formats the given StringView against args, appending to destination contents.
Definition StringBuilder.h:41
Non-owning view over a range of characters with UTF Encoding.
Definition StringView.h:46