HybridString
A HybridString
is a cross between a String
and a StringView
. It references a range of memory
that is generally intended (but not required) to contain UTF-8-encoded text. The HybridString
may
or may not own the memory it points to, as determined by the isOwner
flag. If isOwner
is
non-zero, the memory block owned by the HybridString
will be freed from heap when the
HybridString
is destroyed. If isOwner
is zero, the HybridString
does not own the memory it
points to, and the caller must ensure that the memory remains valid for the lifetime of the
HybridString
.
Header File
#include <ply-runtime/container/String.h>
Also included from <ply-runtime/Base.h>
.
Data Members
-
The bytes. Should be treated as const if isOwner == 0.
-
Number of bytes and owner flag.
Member Functions
-
Constructs an empty
HybridString
. -
Constructs a
HybridString
that views the same memory block asview
.view
is expected to remain valid for the lifetime of theHybridString
. No new memory is allocated. -
Constructs a
HybridString
that takes ownership of the memory block owned bystr
.str
is reset to an empty string. -
Move constructor.
-
Copy constructor.
-
Construct a
HybridString
from a string literal. Compilers seem able to calculate its length at compile time (if optimization is enabled). void HybridString::operator=(HybridString&& other)
[code]-
Move assignment operator.
void HybridString::operator=(const HybridString& other)
[code]-
Copy assignment operator.
HybridString::operator StringView() const
[code]-
Conversion operator. Makes
HybridString
implicitly convertible toStringView
. -
Explicitly creates a
StringView
into theHybridString
. No new memory is allocated by this function.
Members Inherited From ply::StringMixin
template <typename T>
T StringMixin::to(const T& defaultValue = subst::createDefault<T>()) const
explicit StringMixin::operator bool() const
bool StringMixin::isEmpty() const
StringView StringMixin::subStr(u32 start) const
StringView StringMixin::subStr(u32 start, u32 numBytes) const
StringView StringMixin::left(u32 numBytes) const
StringView StringMixin::shortenedBy(u32 numBytes) const
StringView StringMixin::right(u32 numBytes) const
String StringMixin::operator+(StringView other) const
String StringMixin::operator*(u32 count) const
s32 StringMixin::findByte(char matchByte, u32 startPos = 0) const
template <typename MatchFuncOrChar>
s32 StringMixin::findByte(const MatchFuncOrChar& matchFuncOrByte, u32 startPos = 0) const
template <typename MatchFuncOrChar>
s32 StringMixin::rfindByte(const MatchFuncOrChar& matchFuncOrByte, u32 startPos) const
template <typename MatchFuncOrChar>
s32 StringMixin::rfindByte(const MatchFuncOrChar& matchFuncOrByte) const
bool StringMixin::startsWith(StringView arg) const
bool StringMixin::endsWith(StringView arg) const
StringView StringMixin::trim(bool* matchFunc(char) = isWhite, bool left = true, bool right = true) const
StringView StringMixin::ltrim(bool* matchFunc(char) = isWhite) const
StringView StringMixin::rtrim(bool* matchFunc(char) = isWhite) const
String StringMixin::join(ArrayView<const StringView> comps) const
auto StringMixin::splitByte(char sep) const
String StringMixin::upperAsc() const
String StringMixin::lowerAsc() const
String StringMixin::reversedBytes() const
String StringMixin::reversedUTF8() const
String StringMixin::filterBytes(char* filterFunc(char)) const
bool StringMixin::includesNullTerminator() const
HybridString StringMixin::withNullTerminator() const
StringView StringMixin::withoutNullTerminator() const