C

SafeRenderer::QSafeString Class

class SafeRenderer::QSafeString

The QSafeString class contains functions for the string manipulation. More...

Header: #include <QSafeString>
Since: QtSafeRenderer 1.2

Public Functions

QSafeString(const SafeRenderer::qchar *const strArg)
QSafeString(const SafeRenderer::QSafeString &other)
QSafeString(SafeRenderer::QSafeString &&other)
void append(const SafeRenderer::QSafeString &other)
void append(const SafeRenderer::qchar *const strArg)
void append(const SafeRenderer::qchar *const strArg, const size_t lengthArg)
SafeRenderer::qchar at(const std::size_t pos) const
bool endsWith(const SafeRenderer::qchar chrArg) const
SafeRenderer::quint32 hash() const
bool isEmpty() const
size_t length() const
const SafeRenderer::qchar *rawCString() const
void reset()
void set(const SafeRenderer::qchar *const strArg)
void set(const SafeRenderer::qchar *const strArg, const size_t lengthArg)
SafeRenderer::QSafeString &operator=(SafeRenderer::QSafeString &&other) &
SafeRenderer::QSafeString &operator=(const SafeRenderer::QSafeString &other) &
SafeRenderer::QSafeString &operator=(const SafeRenderer::qchar *const strArg) &

Static Public Members

SafeRenderer::QSafeString fromNumber(const T number)

Detailed Description

The QSafeString class contains functions for the string manipulation.

Member Function Documentation

QSafeString::QSafeString(const SafeRenderer::qchar *const strArg)

Constructs QSafeString from the null terminated strArg. strArg is copied to QSafeString.

QSafeString::QSafeString(const SafeRenderer::QSafeString &other)

Constructs QSafeString from another QSafeString other. Data from other is copied to QSafeString.

[noexcept] QSafeString::QSafeString(SafeRenderer::QSafeString &&other)

Constructs QSafeString from another QSafeString other. Data from other is moved to this new instance.

void QSafeString::append(const SafeRenderer::QSafeString &other)

Appends the string other onto the end of this string. If the string does not fit to Constraints::MAX_LEN_OF_TEXT, an exception will be thrown:

void QSafeString::append(const SafeRenderer::qchar *const strArg)

Appends the string strArg onto the end of this string. In case of strArg does not fit to Constraints::MAX_LEN_OF_TEXT, an exception will be thrown:

void QSafeString::append(const SafeRenderer::qchar *const strArg, const size_t lengthArg)

Appends lengthArg amount of characters from the string strArg onto the end of this string. In case of strArg does not fit to Constraints::MAX_LEN_OF_TEXT, an exception will be thrown:

SafeRenderer::qchar QSafeString::at(const std::size_t pos) const

Fetch a letter in the given position pos.

In case of error, following exceptions may be thrown:

ExceptionIdDescription
SafeRenderer::QSafeStringExceptionSafeRenderer::QSafeStringException::StringException::IndexOutOfBoundsThe requested position is not inside a valid range.

Returns the character at given index pos.

bool QSafeString::endsWith(const SafeRenderer::qchar chrArg) const

Returns true if the string ends with chrArg. Otherwise returns false.

[static] template <typename T, std::enable_if_t<std::is_integral<T>::value && !std::is_same_v<qchar, T>, bool> = true> SafeRenderer::QSafeString QSafeString::fromNumber(const T number)

Converts the given number to QSafeString.

Note: qchar (char) usage is specifically disabled as a type for fromNumber conversion, as some platforms consider simple chars as unsigned ones and that gives invalid results for our unit tests and makes the functionality not consistent between platforms. For 1 byte signed conversions use qint8 instead.

Returns converted QSafeString

SafeRenderer::quint32 QSafeString::hash() const

Calculates hash value from the string data.

bool QSafeString::isEmpty() const

Returns true if the string is empty, false otherwise.

size_t QSafeString::length() const

Returns the length of the contained string.

const SafeRenderer::qchar *QSafeString::rawCString() const

Returns pointer to the string array.

void QSafeString::reset()

Resets the QSafeString to an empty string with length 0.

void QSafeString::set(const SafeRenderer::qchar *const strArg)

Overload for void QSafeString::set(const qchar * const strArg, const size_t lengthArg)

The length of the string strArg will be calculated with safe_strlen instead of caller providing it.

void QSafeString::set(const SafeRenderer::qchar *const strArg, const size_t lengthArg)

Set the string to be strArg with length lengthArg. This function will copy the contents of strArg to be stored in this QSafeString.

In case of error, following exceptions may be thrown:

[noexcept] SafeRenderer::QSafeString &QSafeString::operator=(SafeRenderer::QSafeString &&other) &

Copies contents of another temporary QSafeString instance other to this one.

SafeRenderer::QSafeString &QSafeString::operator=(const SafeRenderer::QSafeString &other) &

Copies contents of another QSafeString instance other to this one.

SafeRenderer::QSafeString &QSafeString::operator=(const SafeRenderer::qchar *const strArg) &

Copies contents of given null-terminated string strArg to this QSafeString instance.

Available under certain Qt licenses.
Find out more.