mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
AK: Add StringBuilder::appendff using the new format.
StringBuilder::appendf was already used, thus this name. If we some day replace all usages of printf, we could rename this method.
This commit is contained in:
parent
4fcdc19b14
commit
e5497a326a
|
@ -100,4 +100,7 @@ String format(StringView fmtstr, const Parameters&... parameters)
|
||||||
return Detail::Format::format(fmtstr, formatters);
|
return Detail::Format::format(fmtstr, formatters);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
template<typename... Parameters>
|
||||||
|
void StringBuilder::appendff(StringView fmtstr, const Parameters&... parameters) { AK::format(*this, fmtstr, parameters...); }
|
||||||
|
|
||||||
|
} // namespace AK
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
|
#include <AK/StringView.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
@ -37,7 +38,7 @@ public:
|
||||||
using OutputType = String;
|
using OutputType = String;
|
||||||
|
|
||||||
explicit StringBuilder(size_t initial_capacity = 16);
|
explicit StringBuilder(size_t initial_capacity = 16);
|
||||||
~StringBuilder() {}
|
~StringBuilder() { }
|
||||||
|
|
||||||
void append(const StringView&);
|
void append(const StringView&);
|
||||||
void append(const Utf32View&);
|
void append(const Utf32View&);
|
||||||
|
@ -47,6 +48,10 @@ public:
|
||||||
void appendf(const char*, ...);
|
void appendf(const char*, ...);
|
||||||
void appendvf(const char*, va_list);
|
void appendvf(const char*, va_list);
|
||||||
|
|
||||||
|
// Implemented in <AK/Format.h> to break circular dependency.
|
||||||
|
template<typename... Parameters>
|
||||||
|
void appendff(StringView fmtstr, const Parameters&...);
|
||||||
|
|
||||||
String build() const;
|
String build() const;
|
||||||
String to_string() const;
|
String to_string() const;
|
||||||
ByteBuffer to_byte_buffer() const;
|
ByteBuffer to_byte_buffer() const;
|
||||||
|
|
|
@ -46,7 +46,7 @@ String UserOrKernelBuffer::copy_into_string(size_t size) const
|
||||||
return data_copy;
|
return data_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String({ m_buffer, size });
|
return String(ReadonlyBytes { m_buffer, size });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserOrKernelBuffer::write(const void* src, size_t offset, size_t len)
|
bool UserOrKernelBuffer::write(const void* src, size_t offset, size_t len)
|
||||||
|
|
Loading…
Reference in a new issue