Similar to String, but intended to more efficiently construct a String. Mutable type (String is largely immutable). More...
#include <StringBuilder.h>
Public Member Functions | |
template<IUNICODECanUnambiguouslyConvertFrom CHAR_T> | |
nonvirtual void | Append (span< const CHAR_T > s) |
template<typename APPEND_ARG_T > requires (requires (StringBuilder& s, APPEND_ARG_T&& a) { s.Append (forward<APPEND_ARG_T> (a)); }) | |
nonvirtual auto | operator+= (APPEND_ARG_T &&a) -> StringBuilder & |
template<typename APPEND_ARG_T > requires (Characters::Private_::IToString<APPEND_ARG_T> or requires (StringBuilder& s, APPEND_ARG_T&& a) { s.Append (forward<APPEND_ARG_T> (a)); }) | |
nonvirtual auto | operator<< (APPEND_ARG_T &&a) -> StringBuilder & |
nonvirtual size_t | size () const noexcept |
nonvirtual bool | empty () const noexcept |
nonvirtual Character | GetAt (size_t index) const noexcept |
nonvirtual void | SetAt (Character item, size_t index) noexcept |
nonvirtual const Character | operator[] (size_t i) const noexcept |
return (read-only) Character object | |
template<Common::IAnyOf< char, Character, String, span< const Character >, span< Character > > T> | |
nonvirtual void | InsertAt (T c, size_t at) |
nonvirtual void | ShrinkTo (size_t sz) noexcept |
template<Common::IAnyOf< String, wstring, u8string, u16string, u32string > RESULT_T> | |
nonvirtual RESULT_T | As () const |
nonvirtual String | str () const |
nonvirtual size_t | length () const noexcept |
number of characters, not bytes or code-points | |
nonvirtual span< BufferElementType > | data () |
template<IUNICODECanUnambiguouslyConvertFrom CHAR_T> requires (not is_const_v<CHAR_T>) | |
nonvirtual span< const CHAR_T > | GetData (Memory::StackBuffer< CHAR_T > *probablyIgnoredBuf) const |
access a span of data located inside the StringBuilder. Return internal pointer, or pointer internal to possiblyUsedBuffer | |
Similar to String, but intended to more efficiently construct a String. Mutable type (String is largely immutable).
Has operator String() co can be used by value most places you can use a String.
Definition at line 71 of file StringBuilder.h.
nonvirtual void Stroika::Foundation::Characters::StringBuilder< OPTIONS >::Append | ( | span< const CHAR_T > | s | ) |
Append the given argument characters to this buffer.
argument characters can be given by o span<unicode (or narrow ASCII) characters> o const T* - nul-terminated array of unicode (or narrow ASCII) characters o basic_string<unicode (or narrow ASCII) characters> o basic_string_view<unicode (or narrow ASCII) characters> o String o Character
This function appends as IF the argument was converted to a UNICODE string, and then appended.
nonvirtual auto Stroika::Foundation::Characters::StringBuilder< OPTIONS >::operator+= | ( | APPEND_ARG_T && | a | ) | -> StringBuilder & |
nonvirtual auto Stroika::Foundation::Characters::StringBuilder< OPTIONS >::operator<< | ( | APPEND_ARG_T && | a | ) | -> StringBuilder & |
|
noexcept |
returns number of characters (not bytes, not including any possible NUL-terminator)
Definition at line 206 of file StringBuilder.inl.
|
noexcept |
Returns true if this is an empty string (aka iff size () == 0);
Definition at line 217 of file StringBuilder.inl.
|
noexcept |
Definition at line 223 of file StringBuilder.inl.
|
noexcept |
Definition at line 238 of file StringBuilder.inl.
|
noexcept |
return (read-only) Character object
Definition at line 257 of file StringBuilder.inl.
nonvirtual void Stroika::Foundation::Characters::StringBuilder< OPTIONS >::InsertAt | ( | T | c, |
size_t | at | ||
) |
Mimic the String::InsertAt API, except modify in place.
|
noexcept |
Change the size of this object to sz = where sz must be <= size()
Definition at line 271 of file StringBuilder.inl.
nonvirtual RESULT_T Stroika::Foundation::Characters::StringBuilder< OPTIONS >::As | ( | ) | const |
String Stroika::Foundation::Characters::StringBuilder< OPTIONS >::str | ( | ) | const |
mimic wstringstream method
Definition at line 284 of file StringBuilder.inl.
|
noexcept |
number of characters, not bytes or code-points
Definition at line 348 of file StringBuilder.inl.
auto Stroika::Foundation::Characters::StringBuilder< OPTIONS >::data | ( | ) |
ONLY valid til the next non-const call to StringBuilder. See also GetData (to select a different charType).
Definition at line 353 of file StringBuilder.inl.
nonvirtual span< const CHAR_T > Stroika::Foundation::Characters::StringBuilder< OPTIONS >::GetData | ( | Memory::StackBuffer< CHAR_T > * | probablyIgnoredBuf | ) | const |
access a span of data located inside the StringBuilder. Return internal pointer, or pointer internal to possiblyUsedBuffer
The point of this queer API is too allow accessing the internal data by pointer, but allow StringBuilder to change its internal representation (not necessarily matching the kind of string being requested).
But this needs to be done in a way with data hiding (so we can change the internal representation of the StringBuilder class as needed) and with respect for the possibility that the string could be large (so break out of any small-string optimizations).
Passing in a reference to the 'StackBuffer' class is a compromise among all these considerations. The only cost is initializing a pointer, and checking that pointer on destruction, if no memory allocation is needed.