4#include "../Strings/StringFormat.h"
5#include "StringsExport.h"
9struct StringBuilderFor;
30 template <
typename T>
static StringBuilderFor<T> create(T& stringOrBuffer)
noexcept {
return {stringOrBuffer, StringBuilder::Clear}; }
36 template <
typename T,
typename... Types>
37 [[nodiscard]]
static bool format(T& buffer,
StringView fmt, Types&&... args) {
return StringBuilder::create(buffer).append(fmt, forward<Types>(args)...); }
41 template <
typename... Types>
87 StringBuilder(IGrowableBuffer& ibuffer, StringEncoding encoding, Flags flags)
noexcept;
88 void initWithEncoding(IGrowableBuffer& bufferT, StringEncoding stringEncoding, Flags flags)
noexcept;
90 IGrowableBuffer* buffer =
nullptr;
91 StringEncoding encoding;
99 GrowableBuffer<T> growableBuffer;
103 initWithEncoding(growableBuffer, GrowableBuffer<T>::getEncodingFor(stringOrBuffer), flags);
113 growableBuffer.finalize();
114 finalizedView = {{buffer->data(), buffer->size()},
true, encoding};
125 return finalizedView;
#define SC_ASSERT_RELEASE(e)
Assert expression e to be true.
Definition Assert.h:48
Parse and compose filesystem paths for windows and posix.
Definition Path.h:17
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:98
StringView view() noexcept
Returns the resulting StringView after finalize.
Definition StringBuilder.h:122
StringView finalize() noexcept
Finalizes the StringBuilder, returning the resulting StringView.
Definition StringBuilder.h:109
Builds String out of a sequence of StringView or formatting through StringFormat.
Definition StringBuilder.h:27
Flags
Definition StringBuilder.h:80
@ Clear
Destination buffer will be cleared before pushing to it.
Definition StringBuilder.h:81
bool append(StringView str)
Appends StringView to destination buffer.
AppendHexCase
Option for StringBuilder::appendHex.
Definition StringBuilder.h:65
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:30
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:33
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:37
bool append(StringView fmt, Types &&... args)
Formats the given StringView against args, appending to destination contents.
Definition StringBuilder.h:42
Non-owning view over a range of characters with UTF Encoding.
Definition StringView.h:47