2023-08-05 13:42:26 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2023-08-05 13:42:26 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-12-16 11:19:34 -03:00
|
|
|
#include <AK/ByteString.h>
|
2023-08-05 13:42:26 -03:00
|
|
|
#include <AK/Error.h>
|
2026-05-26 14:07:49 -03:00
|
|
|
#include <AK/Format.h>
|
2025-02-22 05:51:15 -03:00
|
|
|
#include <AK/Optional.h>
|
2023-08-05 13:42:26 -03:00
|
|
|
#include <AK/String.h>
|
2023-12-04 11:55:47 -03:00
|
|
|
#include <AK/StringView.h>
|
2025-07-28 17:51:01 -03:00
|
|
|
#include <AK/Utf16String.h>
|
2026-05-26 14:07:49 -03:00
|
|
|
#include <AK/Utf16View.h>
|
2024-03-18 00:22:27 -03:00
|
|
|
#include <LibURL/URL.h>
|
2024-11-09 14:50:33 -03:00
|
|
|
|
2025-05-01 12:38:31 -03:00
|
|
|
#include <QByteArray>
|
2023-08-05 13:42:26 -03:00
|
|
|
#include <QString>
|
2024-01-30 23:15:55 -03:00
|
|
|
#include <QUrl>
|
2023-08-05 13:42:26 -03:00
|
|
|
|
2023-12-16 11:19:34 -03:00
|
|
|
AK::ByteString ak_byte_string_from_qstring(QString const&);
|
2025-05-01 12:38:31 -03:00
|
|
|
AK::ByteString ak_byte_string_from_qbytearray(QByteArray const&);
|
|
|
|
|
|
2023-12-04 12:08:16 -03:00
|
|
|
String ak_string_from_qstring(QString const&);
|
2023-12-04 11:55:47 -03:00
|
|
|
QString qstring_from_ak_string(StringView);
|
2025-07-28 17:51:01 -03:00
|
|
|
|
|
|
|
|
Utf16String utf16_string_from_qstring(QString const&);
|
|
|
|
|
QString qstring_from_utf16_string(Utf16View const&);
|
|
|
|
|
|
2026-05-26 14:07:49 -03:00
|
|
|
QString vqformatted(StringView, AK::TypeErasedFormatParams&);
|
|
|
|
|
|
|
|
|
|
template<typename... Parameters>
|
|
|
|
|
QString qformatted(CheckedFormatString<Parameters...>&& format, Parameters const&... parameters)
|
|
|
|
|
{
|
|
|
|
|
AK::VariadicFormatParams<AK::AllowDebugOnlyFormatters::No, Parameters...> variadic_format_parameters { parameters... };
|
|
|
|
|
return vqformatted(format.view(), variadic_format_parameters);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-01 12:38:31 -03:00
|
|
|
QByteArray qbytearray_from_ak_string(StringView);
|
|
|
|
|
|
2025-02-22 05:51:15 -03:00
|
|
|
Optional<URL::URL> ak_url_from_qstring(QString const&);
|
2024-03-18 00:22:27 -03:00
|
|
|
URL::URL ak_url_from_qurl(QUrl const&);
|
2026-05-26 14:07:49 -03:00
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
struct Formatter<QString> : Formatter<Utf16View> {
|
|
|
|
|
ErrorOr<void> format(FormatBuilder& builder, QString const& value)
|
|
|
|
|
{
|
|
|
|
|
Utf16View view { reinterpret_cast<char16_t const*>(value.utf16()), static_cast<size_t>(value.size()) };
|
|
|
|
|
return Formatter<Utf16View>::format(builder, view);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|