4#include "../Strings/StringFormat.h"
32 GrowableBuffer<T>& bufferT = bufferStorage.reinterpret_as<GrowableBuffer<T>>();
33 placementNew(bufferT, buffer);
34 initWithEncoding(bufferT, encoding, flags);
43 GrowableBuffer<T>& bufferT = bufferStorage.reinterpret_as<GrowableBuffer<T>>();
44 placementNew(bufferT,
string);
45 initWithEncoding(bufferT,
string.getEncoding(), flags);
48 StringBuilder(IGrowableBuffer& bufferT, StringEncoding encoding, Flags flags);
71 template <
typename T,
typename... Types>
72 [[nodiscard]]
static bool format(T& buffer,
StringView fmt, Types&&... args);
79 [[nodiscard]]
static bool format(T& buffer,
StringView text);
95 template <
typename... Types>
96 [[nodiscard]]
bool append(
StringView fmt, Types&&... args);
129 void initWithEncoding(IGrowableBuffer& bufferT, StringEncoding stringEncoding,
Flags flags);
132 IGrowableBuffer* buffer =
nullptr;
133 bool destroyBuffer =
true;
137 StringEncoding encoding;
151 const bool res = sb.
append(fmt);
156template <
typename T,
typename... Types>
165template <
typename... Types>
constexpr T && forward(typename TypeTraits::RemoveReference< T >::type &value)
Forwards an lvalue or an rvalue as an rvalue reference.
Definition Compiler.h:260
#define SC_TRY(expression)
Checks the value of the given expression and if failed, returns this value to caller.
Definition Result.h:48
A buffer of bytes with given alignment.
Definition AlignedStorage.h:29
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
Builds String out of a sequence of StringView or formatting through StringFormat.
Definition StringBuilder.h:18
StringBuilder(T &buffer, StringEncoding encoding, Flags flags=DoNotClear)
Create a StringBuilder that will push to given Buffer, with specific encoding.
Definition StringBuilder.h:30
Flags
Clearing flags used when initializing destination buffer.
Definition StringBuilder.h:21
@ Clear
Destination buffer will be cleared before pushing to it.
Definition StringBuilder.h:22
bool append(StringView str)
Appends StringView to destination buffer.
AppendHexCase
Option for StringBuilder::appendHex.
Definition StringBuilder.h:115
bool appendHex(Span< const uint8_t > data, AppendHexCase casing)
Appends given binary data escaping it as hexadecimal ASCII characters.
StringView view()
Obtains view after finalize has been previously called.
bool appendReplaceAll(StringView source, StringView occurrencesOf, StringView with)
Appends source to destination buffer, replacing occurrencesOf StringView with StringView with
StringBuilder(T &string, Flags flags=DoNotClear)
Create a StringBuilder that will push to given Buffer, with specific encoding.
Definition StringBuilder.h:41
static bool format(T &buffer, StringView fmt, Types &&... args)
Uses StringFormat to format the given StringView against args, replacing destination contents.
Definition StringBuilder.h:157
bool append(StringView fmt, Types &&... args)
Uses StringFormat to format the given StringView against args, appending to destination contents.
Definition StringBuilder.h:166
StringView finalize()
Finalizes building the string and returns a StringView with the contents.
constexpr StringEncoding getEncoding() const
Get encoding of this StringView.
Definition StringSpan.h:98
Non-owning view over a range of characters with UTF Encoding.
Definition StringView.h:46