mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 10:27:34 +00:00
Added formatted printing
This commit is contained in:
@@ -3,12 +3,25 @@
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <sta/debug/assert.hpp>
|
||||
#include <sta/lang.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void Printable::printf(const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
char str[2*strlen(fmt)];
|
||||
int n = vsnprintf(str, 2*strlen(fmt), fmt, args);
|
||||
STA_ASSERT(n > 0);
|
||||
|
||||
println(str);
|
||||
}
|
||||
|
||||
void Printable::print(char c)
|
||||
{
|
||||
print(&c, 1);
|
||||
@@ -182,4 +195,4 @@ namespace sta
|
||||
print(buffer, digits);
|
||||
}
|
||||
|
||||
} // namespace sta
|
||||
} // namespace sta
|
||||
|
Reference in New Issue
Block a user