mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added printf and vprintf.
This commit is contained in:
@@ -281,6 +281,12 @@ namespace bx
|
||||
/// enough space had been available.
|
||||
int32_t snprintf(char* _out, int32_t _max, const char* _format, ...);
|
||||
|
||||
///
|
||||
int32_t vprintf(const char* _format, va_list _argList);
|
||||
|
||||
///
|
||||
int32_t printf(const char* _format, ...);
|
||||
|
||||
/// Templatized snprintf.
|
||||
template <typename Ty>
|
||||
void stringPrintfVargs(Ty& _out, const char* _format, va_list _argList);
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "bx_p.h"
|
||||
#include <bx/allocator.h>
|
||||
#include <bx/file.h>
|
||||
#include <bx/hash.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/string.h>
|
||||
|
||||
namespace bx
|
||||
@@ -1153,10 +1153,10 @@ namespace bx
|
||||
SizerWriter sizer;
|
||||
va_list argListCopy;
|
||||
va_copy(argListCopy, _argList);
|
||||
int32_t size = write(&sizer, _format, argListCopy, &err);
|
||||
int32_t total = write(&sizer, _format, argListCopy, &err);
|
||||
va_end(argListCopy);
|
||||
|
||||
return size;
|
||||
return total;
|
||||
}
|
||||
|
||||
int32_t snprintf(char* _out, int32_t _max, const char* _format, ...)
|
||||
@@ -1165,6 +1165,28 @@ namespace bx
|
||||
va_start(argList, _format);
|
||||
int32_t total = vsnprintf(_out, _max, _format, argList);
|
||||
va_end(argList);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
int32_t vprintf(const char* _format, va_list _argList)
|
||||
{
|
||||
Error err;
|
||||
va_list argListCopy;
|
||||
va_copy(argListCopy, _argList);
|
||||
int32_t total = write(getStdOut(), _format, argListCopy, &err);
|
||||
va_end(argListCopy);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
int32_t printf(const char* _format, ...)
|
||||
{
|
||||
va_list argList;
|
||||
va_start(argList, _format);
|
||||
int32_t total = vprintf(_format, argList);
|
||||
va_end(argList);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user