Blend2D
2D Vector Graphics Engine
Byte string [C++ API].
Blend2D always uses UTF-8 encoding in public APIs so all strings are assumed UTF-8 by default. However, BLString
doesn't guarantee any assumptions about the encoding of the data it holds. It can hold arbitrary byte sequence and act as a raw byte-string when this functionality is desired.
Creates an empty string.
Move constructor.
other
string is always reset by a move construction, so it becomes an empty string. Copy constructor, performs weak copy of the data held by the other
string.
Constructor that creates a string from the given string view
.
Constructor that creates a string from the given data specified by str
and size
. If size
is SIZE_MAX
the string is assumed to be null terminated.
This is a convenience function that doesn't provide error handling. If size exceeds small string capacity and dynamic allocation failed then a default empty string would be constructed.
Destroys the string.
Tests whether the string has a content.
empty()
. Move assignment.
other
string is reset by move construction, so it becomes an empty string. Copy assignment, performs weak copy of the data held by the other
string.
Returns a character at the given index
.
at(index)
. Clears the content of the string and releases its data.
After reset the string content matches a default constructed string.
Swaps the content of this string with the other
string.
Tests whether the string is empty (has no content).
Returns true
if the string's length is zero.
Returns a character at the given index
.
Returns the size of the string [in bytes].
Returns the capacity of the string [in bytes].
Returns a pointer to the data of the string.
Returns a pointer to the beginning of string data (iterator compatibility).
Returns a pointer to the end of string data (iterator compatibility).
The returned pointer points to the string null terminator.
Returns the content of the string as BLStringView
.
Clears the content of the string without releasing its dynamically allocated data, if possible.
Shrinks the capacity of the string to match the actual content.
Reserves at least n
bytes in the string for further manipulation (most probably appending).
Resizes the string to n
and fills the additional data by fill
pattern.
Makes the string mutable.
This operation checks whether the string is mutable and if not it makes a deep copy of its content so it can be modified. Please note that you can only modify the content that is defined by its length property. Even if the string had higher capacity before makeMutable()
it's not guaranteed that the possible new data would match that capacity.
If you want to make the string mutable for the purpose of appending or making other modifications please consider using modifyOp()
and insertOp()
instead.
Replaces the content of the string by c
character or multiple characters if n
is greater than one.
Move assignment, the same as operator=()
, but returns a BLResult
instead of this
.
Copy assignment, the same as operator=()
, but returns a BLResult
instead of this
.
Replaces the string by the content described by the given string view
.
Replaces the string by str
data of the given length n
.
n
equals to SIZE_MAX
. Copy assignment, but creates a deep copy of the other
string instead of weak copy.
Replaces the content of the string by a result of calling snprintf(fmt, args...)
.
Replaces the content of the string by a result of calling vsnprintf(fmt, ap)
.
Truncates the string length to n
.
It does nothing if the the string length is less than n
.
Returns whether this string and other
are equal (i.e. their contents match).
Returns whether this string and other string view
are equal.
Returns whether this string and the given string data str
of length n
are equal.
Compares this string with other
and returns either -1
, 0
, or 1
.
Compares this string with other string view
and returns either -1
, 0
, or 1
.
Compares this string with other string data and returns either -1
, 0
, or 1
.
Returns the first index at which a given character c
can be found in the string, or SIZE_MAX
if not present.
Returns the index at which a given character c
can be found in the string starting from fromIndex
, or SIZE_MAX
if not present.
Returns the last index at which a given character c
can be found in the string, or SIZE_MAX
if not present.
Returns the index at which a given character c
can be found in the string starting from fromIndex
and ending at 0
, or SIZE_MAX
if not present.