Run clang-format over C++ files

This commit is contained in:
Olivier Goffart 2022-08-16 18:06:22 +02:00 committed by Olivier Goffart
parent 1884497308
commit ca6dfc0cb5
12 changed files with 141 additions and 107 deletions

View file

@ -53,7 +53,10 @@ struct SharedString
}
/// Destroys this SharedString and frees the memory if this is the last instance
/// referencing it.
~SharedString() { cbindgen_private::slint_shared_string_drop(this); }
~SharedString()
{
cbindgen_private::slint_shared_string_drop(this);
}
/// Assigns \a other to this string and returns a reference to this string.
SharedString &operator=(const SharedString &other)
{
@ -72,7 +75,10 @@ struct SharedString
/// Assigns null-terminated string pointer \a s to this string and returns a reference
/// to this string. The underlying string data is copied. It is assumed that the string
/// is UTF-8 encoded.
SharedString &operator=(const char *s) { return *this = std::string_view(s); }
SharedString &operator=(const char *s)
{
return *this = std::string_view(s);
}
/// Move-assigns \a other to this SharedString instance.
SharedString &operator=(SharedString &&other)
@ -83,20 +89,35 @@ struct SharedString
/// Provides a view to the string data. The returned view is only valid as long as at
/// least this SharedString exists.
operator std::string_view() const { return cbindgen_private::slint_shared_string_bytes(this); }
operator std::string_view() const
{
return cbindgen_private::slint_shared_string_bytes(this);
}
/// Provides a raw pointer to the string data. The returned pointer is only valid as long as at
/// least this SharedString exists.
auto data() const -> const char * { return cbindgen_private::slint_shared_string_bytes(this); }
auto data() const -> const char *
{
return cbindgen_private::slint_shared_string_bytes(this);
}
/// Returns a pointer to the first character. It is only safe to dereference the pointer if the
/// string contains at least one character.
const char *begin() const { return data(); }
const char *begin() const
{
return data();
}
/// Returns a point past the last character of the string. It is not safe to dereference the
/// pointer, but it is suitable for comparison.
const char *end() const { return &*std::string_view(*this).end(); }
const char *end() const
{
return &*std::string_view(*this).end();
}
/// \return true if the string contains no characters; false otherwise.
bool empty() const { return std::string_view(*this).empty(); }
bool empty() const
{
return std::string_view(*this).empty();
}
/// \return true if the string starts with the specified prefix string; false otherwise
bool starts_with(std::string_view prefix) const
@ -123,7 +144,10 @@ struct SharedString
/// auto str = slint::SharedString::from_number(42); // creates "42"
/// auto str2 = slint::SharedString::from_number(100.5) // creates "100.5"
/// \endcode
static SharedString from_number(double n) { return SharedString(n); }
static SharedString from_number(double n)
{
return SharedString(n);
}
/// Returns true if \a a is equal to \a b; otherwise returns false.
friend bool operator==(const SharedString &a, const SharedString &b)
@ -185,7 +209,10 @@ struct SharedString
private:
/// Use SharedString::from_number
explicit SharedString(double n) { cbindgen_private::slint_shared_string_from_number(this, n); }
explicit SharedString(double n)
{
cbindgen_private::slint_shared_string_from_number(this, n);
}
void *inner; // opaque
};