1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

AK: Resolve format related circular dependencies properly.

With this commit, <AK/Format.h> has a more supportive role and isn't
used directly.

Essentially, there now is a public 'vformat' function ('v' for vector)
which takes already type erased parameters. The name is choosen to
indicate that this function behaves similar to C-style functions taking
a va_list equivalent.

The interface for frontend users are now 'String::formatted' and
'StringBuilder::appendff'.
This commit is contained in:
asynts 2020-09-23 13:21:18 +02:00 committed by Andreas Kling
parent 3224fb7d55
commit b7a4c4482f
8 changed files with 105 additions and 100 deletions

View file

@ -27,6 +27,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Format.h>
#include <AK/Forward.h>
#include <AK/StringView.h>
#include <stdarg.h>
@ -48,9 +49,12 @@ public:
void appendf(const char*, ...);
void appendvf(const char*, va_list);
// Implemented in <AK/Format.h> to break circular dependency.
template<typename... Parameters>
void appendff(StringView fmtstr, const Parameters&...);
void appendff(StringView fmtstr, const Parameters&... parameters)
{
const auto type_erased_parameters = make_type_erased_parameters(parameters...);
vformat(*this, fmtstr, type_erased_parameters);
}
String build() const;
String to_string() const;