diff --git a/include/bx/readerwriter.h b/include/bx/readerwriter.h index df32c69..8610dfe 100644 --- a/include/bx/readerwriter.h +++ b/include/bx/readerwriter.h @@ -266,7 +266,10 @@ namespace bx int32_t write(WriterI* _writer, const StringView& _format, va_list _argList, Error* _err); /// - int32_t write(WriterI* _writer, Error* _err, const StringView& _format, ...); + int32_t write(WriterI* _writer, Error* _err, const StringView* _format, ...); + + /// + int32_t write(WriterI* _writer, Error* _err, const char* _format, ...); /// Write repeat the same value. int32_t writeRep(WriterI* _writer, uint8_t _byte, int32_t _size, Error* _err = NULL); diff --git a/src/string.cpp b/src/string.cpp index 0d768e2..6ca50af 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -1106,10 +1106,19 @@ namespace bx return size; } - int32_t write(WriterI* _writer, Error* _err, const StringView& _format, ...) + int32_t write(WriterI* _writer, Error* _err, const StringView* _format, ...) { va_list argList; - va_start(argList, &_format); + va_start(argList, _format); + int32_t total = write(_writer, *_format, argList, _err); + va_end(argList); + return total; + } + + int32_t write(WriterI* _writer, Error* _err, const char* _format, ...) + { + va_list argList; + va_start(argList, _format); int32_t total = write(_writer, _format, argList, _err); va_end(argList); return total; diff --git a/tests/vsnprintf_test.cpp b/tests/vsnprintf_test.cpp index 0fa3a39..4d6480c 100644 --- a/tests/vsnprintf_test.cpp +++ b/tests/vsnprintf_test.cpp @@ -188,5 +188,5 @@ TEST_CASE("vsnprintf write") REQUIRE(len == 4); bx::StringView str(tmp, len); - REQUIRE(0 == bx::strCmp(str, "1389")); + REQUIRE(0 == bx::strCmp(str, "1389") ); }