class new in Git master
#include <Corrade/Containers/String.h>
String String.
Contents
A lightweight non-templated alternative to std::
Usage
It's recommended to prefer using StringView in most cases, and only create a String instance if you need to extend lifetime of the data or mutate it. The String is implicitly convertible from C string literals, but the designated way to instantiate a string is using the operator""_
Containers::String a = "hello\0world!"; // a.size() == 5 Containers::String b = "hello\0world!"_s; // a.size() == 12
String instances are implicitly convertible from and to (mutable) StringView, all instances (including an empty string) are guaranteed to be null-terminated, which means a conversion to StringView will always have StringViewFlag::
As with StringView, the class is implicitly convertible to ArrayView. In addition it's also move-convertible to Array, transferring the ownership of the internal data array to it. Ownership transfer in the other direction is not provided because it's not possible to implicitly guarantee null termination of the input Array — use the explicit String(char*, std::
Small string optimization
The class stores data size, data pointer and a deleter pointer, which is 24 bytes on 64-bit platforms (and 12 bytes on 32-bit). To avoid allocations for small strings, small strings up to 22 bytes on 64-bit (23 including the null terminator) and up to 10 bytes on 32-bit (11 including the null terminator) are by default stored inside the class.
Such optimization is completely transparent to the user, the only difference is that deleter() and release() can't be called on SSO strings, as there is nothing to delete / release. Presence of SSO on an instance can be queried using isSmall(). In cases where SSO isn't desired (for example when storing pointers to string contents stored in a growable array), the string can be constructed using the AllocatedInit tag (for example with String(AllocatedInitT, const char*)), which bypasses this optimization and always allocates.
String initialization
In addition to creating a String from an existing string (literal) or wrapping an externally allocated memory as mentioned above, explicit initialization constructors are provided, similarly to the Array class:
- String(ValueInitT, std::
size_t) zero-initializes the string, meaning each of its characters is '\0'
. For heap-allocated strings this is equivalent tonew char[size + 1]{}
(the one extra character is for the null terminator). - String(DirectInitT, std::
size_t, char) fills the whole string with given character and zero-initializes the null terminator. For heap-allocated strings this is equivalent to new char[size + 1]{c, c, c, …, '\0'}
. - String(NoInitT, std::
size_t) keeps the contents uninitialized, except for the null terminator. Equivalent to new char[size + 1]
followed bystring[size] = '\0'
.
STL compatibility
Instances of String are implicitly convertible from and to std::#include <string>
, which significantly affects compile times. The following table lists allowed conversions:
Corrade type | ↭ | STL type |
---|---|---|
String | ⇆ | std:: |
Example:
std::string a = "Hello world!"; Containers::String b = a.substr(5);
Because std::
Public types
- using Deleter = void(*)(char*, std::size_t)
- Deleter type.
Public static functions
- static auto nullTerminatedView(StringView view) -> String
- Turn a view into a null-terminated string.
- static auto nullTerminatedGlobalView(StringView view) -> String
- Turn a view into a null-terminated global string.
Constructors, destructors, conversion operators
- String() noexcept
- Default constructor.
- String(StringView view)
- Construct from a string view.
-
String(Containers::
ArrayView<const char> view) - String(MutableStringView view)
-
String(Containers::
ArrayView<char> view) - String(const char* data)
- Construct from a null-terminated C string.
-
String(const char* data,
std::
size_t size) - Construct from a sized C string.
- String(AllocatedInitT, StringView view) explicit
- Construct from a string view, bypassing SSO.
-
String(AllocatedInitT,
Containers::
ArrayView<const char> view) explicit - String(AllocatedInitT, MutableStringView view) explicit
-
String(AllocatedInitT,
Containers::
ArrayView<char> view) explicit - String(AllocatedInitT, const char* data) explicit
- Construct from a null-terminated C string, bypassing SSO.
-
String(AllocatedInitT,
const char* data,
std::
size_t size) explicit - Construct from a sized C string.
-
String(char* data,
std::
size_t size, Deleter deleter) explicit noexcept - Take ownership of an external data array.
-
String(const char* data,
std::
size_t size, Deleter deleter) explicit noexcept - Take ownership of an immutable external data array.
-
String(std::
nullptr_t, std:: size_t size, Deleter deleter) deleted explicit - Taking ownership of a null pointer is not allowed.
-
String(ValueInitT,
std::
size_t size) explicit - Create a zero-initialized string of given size.
-
String(DirectInitT,
std::
size_t size, char c) explicit - Create a string initialized to a particular character.
-
String(NoInitT,
std::
size_t size) explicit - Create an uninitialized string.
-
template<class T, class = decltype(Implementation::StringConverter<typename std::String(T&& other) noexcept
decay<T && >::type>::from(std:: declval<T && >()))> - Construct a view on an external type / from an external representation.
- ~String()
- Destructor.
- String(const String& other)
- Copy constructor.
- String(String&& other) noexcept
- Move constructor.
- operator ArrayView<const char>() const noexcept
- Convert to a const ArrayView.
- operator ArrayView<const void>() const noexcept
- operator ArrayView<char>() noexcept
- Convert to an ArrayView.
- operator ArrayView<void>() noexcept
-
template<class T, class = decltype(Implementation::StringConverter<T>::to(std::operator T() const
declval<String>()))> - Convert the view to external representation.
Public functions
- auto operator=(const String& other) -> String&
- Copy assignment.
- auto operator=(String&& other) -> String& noexcept
- Move assignment.
- auto isSmall() const -> bool
- Whether the string is stored using small string optimization.
- auto data() -> char*
- String data.
- auto data() const -> const char*
- auto deleter() const -> Deleter
- String deleter.
- auto isEmpty() const -> bool
- Whether the string is empty.
-
auto size() const -> std::
size_t - String size.
- auto begin() -> char*
- Pointer to the first byte.
- auto begin() const -> const char*
- auto cbegin() const -> const char*
- auto end() -> char*
- Pointer to (one item after) the last byte.
- auto end() const -> const char*
- auto cend() const -> const char*
- auto front() -> char&
- First byte.
- auto front() const -> char
- auto back() -> char&
- Last byte.
- auto back() const -> char
-
auto operator[](std::
size_t i) -> char& - Element access.
-
auto operator[](std::
size_t i) const -> char - auto slice(char* begin, char* end) -> MutableStringView
- String slice.
- auto slice(const char* begin, const char* end) const -> StringView
-
auto slice(std::
size_t begin, std:: size_t end) -> MutableStringView -
auto slice(std::
size_t begin, std:: size_t end) const -> StringView - auto prefix(char* end) -> MutableStringView
- String prefix.
- auto prefix(const char* end) const -> StringView
-
auto prefix(std::
size_t end) -> MutableStringView -
auto prefix(std::
size_t end) const -> StringView - auto suffix(char* begin) -> MutableStringView
- String suffix.
- auto suffix(const char* begin) const -> StringView
-
auto suffix(std::
size_t begin) -> MutableStringView -
auto suffix(std::
size_t begin) const -> StringView -
auto except(std::
size_t count) -> MutableStringView - String suffix.
-
auto except(std::
size_t count) const -> StringView - auto split(char delimiter) & -> Array<MutableStringView>
- Split on given character.
- auto split(char delimiter) const & -> Array<StringView>
- auto splitWithoutEmptyParts(char delimiter) & -> Array<MutableStringView>
- Split on given character, removing empty parts.
- auto splitWithoutEmptyParts(char delimiter) const & -> Array<StringView>
- auto splitWithoutEmptyParts(StringView delimiters) & -> Array<MutableStringView>
- Split on any character from given set, removing empty parts.
- auto splitWithoutEmptyParts(StringView delimiters) const & -> Array<StringView>
- auto splitWithoutEmptyParts() & -> Array<MutableStringView>
- Split on whitespace, removing empty parts.
- auto splitWithoutEmptyParts() const & -> Array<StringView>
- auto partition(char separator) & -> Array3<MutableStringView>
- Partition.
- auto partition(char separator) const & -> Array3<StringView>
- auto join(ArrayView<const StringView> strings) const -> String
- Join strings with this view as the delimiter.
-
auto join(std::
initializer_list<StringView> strings) const -> String - auto joinWithoutEmptyParts(ArrayView<const StringView> strings) const -> String
- Join strings with this view as the delimiter, skipping empty parts.
-
auto joinWithoutEmptyParts(std::
initializer_list<StringView> strings) const -> String - auto hasPrefix(StringView prefix) const -> bool
- Whether the string begins with given prefix.
- auto hasSuffix(StringView suffix) const -> bool
- Whether the string ends with given suffix.
- auto exceptPrefix(StringView prefix) & -> MutableStringView
- View with given prefix stripped.
- auto exceptPrefix(StringView prefix) const & -> StringView
- auto stripPrefix(StringView prefix) & -> MutableStringView deprecated in Git master
- View with given prefix stripped.
- auto stripPrefix(StringView prefix) const & -> StringView deprecated in Git master
- View with given prefix stripped.
- auto exceptSuffix(StringView suffix) & -> MutableStringView
- View with given suffix stripped.
- auto exceptSuffix(StringView suffix) const & -> StringView
- auto stripSuffix(StringView suffix) & -> MutableStringView deprecated in Git master
- View with given suffix stripped.
- auto stripSuffix(StringView suffix) const & -> StringView deprecated in Git master
- View with given suffix stripped.
- auto trimmed(StringView characters) & -> MutableStringView
- View with given characters trimmed from prefix and suffix.
- auto trimmed(StringView characters) const & -> StringView
- auto trimmed() & -> MutableStringView
- View with whitespace trimmed from prefix and suffix.
- auto trimmed() const & -> StringView
- auto trimmedPrefix(StringView characters) & -> MutableStringView
- View with given characters trimmed from prefix.
- auto trimmedPrefix(StringView characters) const & -> StringView
- auto trimmedPrefix() & -> MutableStringView
- View with whitespace trimmed from prefix.
- auto trimmedPrefix() const & -> StringView
- auto trimmedSuffix(StringView characters) & -> MutableStringView
- View with given characters trimmed from suffix.
- auto trimmedSuffix(StringView characters) const & -> StringView
- auto trimmedSuffix() & -> MutableStringView
- View with whitespace trimmed from suffix.
- auto trimmedSuffix() const & -> StringView
- auto find(StringView substring) & -> MutableStringView
- Find a substring.
- auto find(StringView substring) const & -> StringView
- auto contains(StringView substring) const -> bool
- Whether the view contains a substring.
- auto release() -> char*
- Release data storage.
Function documentation
static String Corrade:: Containers:: String:: nullTerminatedView(StringView view)
Turn a view into a null-terminated string.
If the view is StringViewFlag::
This function is primarily meant for efficiently passing StringView instances to APIs that expect null-terminated const char*
. Mutating the result in any way is undefined behavior.
static String Corrade:: Containers:: String:: nullTerminatedGlobalView(StringView view)
Turn a view into a null-terminated global string.
If the view is both StringViewFlag::
This function is primarily meant for efficiently storing StringView instances, ensuring the memory stays in scope and then passing them to APIs that expect null-terminated const char*
. Mutating the result in any way is undefined behavior.
Corrade:: Containers:: String:: String(StringView view)
Construct from a string view.
Creates a null-terminated owning copy of view
. Contrary to the behavior of std::view
is allowed to be nullptr
, but only if it's size is zero. Depending on the size, it's either stored allocated or in a SSO.
Corrade:: Containers:: String:: String(Containers:: ArrayView<const char> view)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: String(MutableStringView view)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: String(Containers:: ArrayView<char> view)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: String(const char* data)
Construct from a null-terminated C string.
Creates a null-terminated owning copy of data
. Contrary to the behavior of std::data
is allowed to be nullptr
— in that case an empty string is constructed. Depending on the size, it's either stored allocated or in a SSO.
Corrade:: Containers:: String:: String(const char* data,
std:: size_t size)
Construct from a sized C string.
Creates a null-terminated owning copy of data
. Contrary to the behavior of std::data
is allowed to be nullptr
, but only if size
is zero. Depending on the size, it's either stored allocated or in a SSO.
Corrade:: Containers:: String:: String(AllocatedInitT,
StringView view) explicit
Construct from a string view, bypassing SSO.
Compared to String(StringView) the data is always allocated.
Corrade:: Containers:: String:: String(AllocatedInitT,
Containers:: ArrayView<const char> view) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: String(AllocatedInitT,
MutableStringView view) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: String(AllocatedInitT,
Containers:: ArrayView<char> view) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: String(AllocatedInitT,
const char* data) explicit
Construct from a null-terminated C string, bypassing SSO.
Compared to String(const char*) the data is always allocated.
Corrade:: Containers:: String:: String(AllocatedInitT,
const char* data,
std:: size_t size) explicit
Construct from a sized C string.
Compared to String(const char*, std::
Corrade:: Containers:: String:: String(char* data,
std:: size_t size,
Deleter deleter) explicit noexcept
Take ownership of an external data array.
Parameters | |
---|---|
data | String |
size | Size of the string, excluding the null terminator |
deleter | Deleter. Use nullptr for the standard delete[] . |
Since the String class provides a guarantee of null-terminated strings, the data
array is expected to be null-terminated (which implies data
can't be nullptr
), but the null terminator not being included in size
. For consistency and interoperability with Array this in turn means the size passed to deleter
is one byte less than the actual memory size, and if the deleter does sized deallocation, it has to account for that.
Corrade:: Containers:: String:: String(const char* data,
std:: size_t size,
Deleter deleter) explicit noexcept
Take ownership of an immutable external data array.
Casts away the const
and delegates to String(char*, std::
Corrade:: Containers:: String:: String(std:: nullptr_t,
std:: size_t size,
Deleter deleter) explicit deleted
Taking ownership of a null pointer is not allowed.
Since the String class provides a guarantee of null-terminated strings, data
can't be nullptr
.
Corrade:: Containers:: String:: String(ValueInitT,
std:: size_t size) explicit
Create a zero-initialized string of given size.
Parameters | |
---|---|
size | Size excluding the null terminator |
A DefaultInitT overload isn't provided to prevent accidents — its behavior would be the same to String(NoInitT, std::
Corrade:: Containers:: String:: String(DirectInitT,
std:: size_t size,
char c) explicit
Create a string initialized to a particular character.
Parameters | |
---|---|
size | Size excluding the null terminator |
c | Character value |
Corrade:: Containers:: String:: String(NoInitT,
std:: size_t size) explicit
Create an uninitialized string.
Parameters | |
---|---|
size | Size excluding the null terminator |
While the string contents are left untouched, the null terminator does get initialized to '\0'
. Useful if you're going to overwrite the contents anyway.
template<class T, class = decltype(Implementation::StringConverter<typename std:: decay<T && >::type>::from(std:: declval<T && >()))>
Corrade:: Containers:: String:: String(T&& other) noexcept
Construct a view on an external type / from an external representation.
Corrade:: Containers:: String:: operator ArrayView<const char>() const noexcept
Convert to a const ArrayView.
The resulting view has the same size as this string size() — the null terminator is not counted into it.
Corrade:: Containers:: String:: operator ArrayView<const void>() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Corrade:: Containers:: String:: operator ArrayView<char>() noexcept
Convert to an ArrayView.
The resulting view has the same size as this string size() — the null terminator is not counted into it.
Corrade:: Containers:: String:: operator ArrayView<void>() noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T, class = decltype(Implementation::StringConverter<T>::to(std:: declval<String>()))>
Corrade:: Containers:: String:: operator T() const
Convert the view to external representation.
bool Corrade:: Containers:: String:: isSmall() const
Whether the string is stored using small string optimization.
It's not allowed to call deleter() or release() on a SSO instance. See Small string optimization for more information.
char* Corrade:: Containers:: String:: data()
String data.
The pointer is always guaranteed to be non-null and the data to be null-terminated, however note that the actual string might contain null bytes earlier than at the end.
const char* Corrade:: Containers:: String:: data() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Deleter Corrade:: Containers:: String:: deleter() const
String deleter.
If set to nullptr
, the contents are deleted using standard operator delete[]
. Can be called only if the string is not stored using SSO — see Small string optimization for more information.
char* Corrade:: Containers:: String:: begin()
Pointer to the first byte.
const char* Corrade:: Containers:: String:: begin() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const char* Corrade:: Containers:: String:: cbegin() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
char* Corrade:: Containers:: String:: end()
Pointer to (one item after) the last byte.
const char* Corrade:: Containers:: String:: end() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const char* Corrade:: Containers:: String:: cend() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
char Corrade:: Containers:: String:: front() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
char Corrade:: Containers:: String:: back() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
char Corrade:: Containers:: String:: operator[](std:: size_t i) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: slice(char* begin,
char* end)
String slice.
Equivalent to BasicStringView::end
points to (one item after) the end of the original (null-terminated) string, the result has StringViewFlag::
StringView Corrade:: Containers:: String:: slice(const char* begin,
const char* end) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: slice(std:: size_t begin,
std:: size_t end)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
StringView Corrade:: Containers:: String:: slice(std:: size_t begin,
std:: size_t end) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: prefix(char* end)
String prefix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: prefix(const char* end) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: prefix(std:: size_t end)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
StringView Corrade:: Containers:: String:: prefix(std:: size_t end) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: suffix(char* begin)
String suffix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: suffix(const char* begin) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: suffix(std:: size_t begin)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
StringView Corrade:: Containers:: String:: suffix(std:: size_t begin) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: except(std:: size_t count)
String suffix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: except(std:: size_t count) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array<MutableStringView> Corrade:: Containers:: String:: split(char delimiter) &
Split on given character.
Equivalent to BasicStringView::
Array<StringView> Corrade:: Containers:: String:: split(char delimiter) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array<MutableStringView> Corrade:: Containers:: String:: splitWithoutEmptyParts(char delimiter) &
Split on given character, removing empty parts.
Equivalent to BasicStringView::
Array<StringView> Corrade:: Containers:: String:: splitWithoutEmptyParts(char delimiter) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array<MutableStringView> Corrade:: Containers:: String:: splitWithoutEmptyParts(StringView delimiters) &
Split on any character from given set, removing empty parts.
Equivalent to BasicStringView::
Array<StringView> Corrade:: Containers:: String:: splitWithoutEmptyParts(StringView delimiters) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array<MutableStringView> Corrade:: Containers:: String:: splitWithoutEmptyParts() &
Split on whitespace, removing empty parts.
Equivalent to BasicStringView::
Array<StringView> Corrade:: Containers:: String:: splitWithoutEmptyParts() const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array3<MutableStringView> Corrade:: Containers:: String:: partition(char separator) &
Partition.
Equivalent to BasicStringView::
Array3<StringView> Corrade:: Containers:: String:: partition(char separator) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
String Corrade:: Containers:: String:: join(ArrayView<const StringView> strings) const
Join strings with this view as the delimiter.
Equivalent to BasicStringView::
String Corrade:: Containers:: String:: join(std:: initializer_list<StringView> strings) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
String Corrade:: Containers:: String:: joinWithoutEmptyParts(ArrayView<const StringView> strings) const
Join strings with this view as the delimiter, skipping empty parts.
Equivalent to BasicStringView::
String Corrade:: Containers:: String:: joinWithoutEmptyParts(std:: initializer_list<StringView> strings) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Corrade:: Containers:: String:: hasPrefix(StringView prefix) const
Whether the string begins with given prefix.
Equivalent to BasicStringView::
bool Corrade:: Containers:: String:: hasSuffix(StringView suffix) const
Whether the string ends with given suffix.
Equivalent to BasicStringView::
MutableStringView Corrade:: Containers:: String:: exceptPrefix(StringView prefix) &
View with given prefix stripped.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: exceptPrefix(StringView prefix) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: stripPrefix(StringView prefix) &
View with given prefix stripped.
StringView Corrade:: Containers:: String:: stripPrefix(StringView prefix) const &
View with given prefix stripped.
MutableStringView Corrade:: Containers:: String:: exceptSuffix(StringView suffix) &
View with given suffix stripped.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: exceptSuffix(StringView suffix) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: stripSuffix(StringView suffix) &
View with given suffix stripped.
StringView Corrade:: Containers:: String:: stripSuffix(StringView suffix) const &
View with given suffix stripped.
MutableStringView Corrade:: Containers:: String:: trimmed(StringView characters) &
View with given characters trimmed from prefix and suffix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: trimmed(StringView characters) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: trimmed() &
View with whitespace trimmed from prefix and suffix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: trimmed() const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: trimmedPrefix(StringView characters) &
View with given characters trimmed from prefix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: trimmedPrefix(StringView characters) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: trimmedPrefix() &
View with whitespace trimmed from prefix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: trimmedPrefix() const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: trimmedSuffix(StringView characters) &
View with given characters trimmed from suffix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: trimmedSuffix(StringView characters) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: trimmedSuffix() &
View with whitespace trimmed from suffix.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: trimmedSuffix() const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
MutableStringView Corrade:: Containers:: String:: find(StringView substring) &
Find a substring.
Equivalent to BasicStringView::
StringView Corrade:: Containers:: String:: find(StringView substring) const &
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Corrade:: Containers:: String:: contains(StringView substring) const
Whether the view contains a substring.
Equivalent to BasicStringView::
char* Corrade:: Containers:: String:: release()
Release data storage.
Returns the data pointer and resets data pointer, size and deleter to be equivalent to a default-constructed instance. Can be called only if the string is not stored using SSO — see Small string optimization for more information. Deleting the returned array is user responsibility — note the string might have a custom deleter() and so delete[]
might not be always appropriate.