mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
AK+Format: Add outln(FILE*, ...) overload.
This commit also removes a few functions like raw_out and vwarn. If we want to write raw output, we can do this as follows: out("{}", "Hello, World!"); The vout stuff isn't really public API anyways, so no need for another vwarn.
This commit is contained in:
parent
a274a8e5a0
commit
0508fdbbcd
3 changed files with 49 additions and 44 deletions
|
@ -572,37 +572,18 @@ void Formatter<bool>::format(TypeErasedFormatParams& params, FormatBuilder& buil
|
|||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
void raw_out(StringView string)
|
||||
{
|
||||
const auto retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), stdout);
|
||||
ASSERT(retval == string.length());
|
||||
}
|
||||
void vout(StringView fmtstr, TypeErasedFormatParams params, bool newline)
|
||||
void vout(FILE* file, StringView fmtstr, TypeErasedFormatParams params, bool newline)
|
||||
{
|
||||
StringBuilder builder;
|
||||
vformat(builder, fmtstr, params);
|
||||
|
||||
if (newline && !builder.is_empty())
|
||||
if (newline)
|
||||
builder.append('\n');
|
||||
|
||||
raw_out(builder.to_string());
|
||||
}
|
||||
|
||||
void raw_warn(StringView string)
|
||||
{
|
||||
const auto retval = ::write(STDERR_FILENO, string.characters_without_null_termination(), string.length());
|
||||
const auto string = builder.string_view();
|
||||
const auto retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), file);
|
||||
ASSERT(static_cast<size_t>(retval) == string.length());
|
||||
}
|
||||
void vwarn(StringView fmtstr, TypeErasedFormatParams params, bool newline)
|
||||
{
|
||||
StringBuilder builder;
|
||||
vformat(builder, fmtstr, params);
|
||||
|
||||
if (newline && !builder.is_empty())
|
||||
builder.append('\n');
|
||||
|
||||
raw_warn(builder.to_string());
|
||||
}
|
||||
#endif
|
||||
|
||||
void vdbgln(StringView fmtstr, TypeErasedFormatParams params)
|
||||
|
@ -636,9 +617,9 @@ void vdbgln(StringView fmtstr, TypeErasedFormatParams params)
|
|||
vformat(builder, fmtstr, params);
|
||||
builder.append('\n');
|
||||
|
||||
const auto string = builder.build();
|
||||
const auto string = builder.string_view();
|
||||
|
||||
const auto retval = dbgputstr(string.characters(), string.length());
|
||||
const auto retval = dbgputstr(string.characters_without_null_termination(), string.length());
|
||||
ASSERT(retval == 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue