From 87071200872c2450c947047350132aee493033c1 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Thu, 2 Jan 2025 15:11:51 -0600 Subject: Get basic CSV parser operating. --- include/fud_format.hpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'include/fud_format.hpp') diff --git a/include/fud_format.hpp b/include/fud_format.hpp index 2102dc9..9be3dd9 100644 --- a/include/fud_format.hpp +++ b/include/fud_format.hpp @@ -32,8 +32,10 @@ #include #include +#include #include #include +#include namespace fud { @@ -716,21 +718,24 @@ FudStatus fillSignedBuffer(IntCharArray& buffer, T value, uint8_t& bufferLength, { static_assert(sizeof(T) <= sizeof(uint64_t)); static_assert(std::is_signed_v); + uint64_t unsignedValue{}; if (value < 0) { value++; - value = -value; - value++; + unsignedValue = static_cast(-value); + unsignedValue++; + } else { + unsignedValue = static_cast(value); } if constexpr (std::is_same_v) { - return fillUnsignedBuffer(buffer, static_cast(value), bufferLength, radix, uppercase); + return fillUnsignedBuffer(buffer, static_cast(unsignedValue), bufferLength, radix, uppercase); } else if constexpr (std::is_same_v) { - return fillUnsignedBuffer(buffer, static_cast(value), bufferLength, radix, uppercase); + return fillUnsignedBuffer(buffer, static_cast(unsignedValue), bufferLength, radix, uppercase); } else if constexpr (std::is_same_v) { - return fillUnsignedBuffer(buffer, static_cast(value), bufferLength, radix, uppercase); + return fillUnsignedBuffer(buffer, static_cast(unsignedValue), bufferLength, radix, uppercase); } else if constexpr (std::is_same_v) { - return fillUnsignedBuffer(buffer, static_cast(value), bufferLength, radix, uppercase); + return fillUnsignedBuffer(buffer, static_cast(unsignedValue), bufferLength, radix, uppercase); } else if constexpr (std::is_same_v) { - return fillUnsignedBuffer(buffer, static_cast(value), bufferLength, radix, uppercase); + return fillUnsignedBuffer(buffer, static_cast(unsignedValue), bufferLength, radix, uppercase); } } @@ -1441,6 +1446,8 @@ FormatResult format(Sink& sink, FormatCharMode formatMode, const FormatSpec& for return result; } + // printf("From format(sink, mode, spec, stringview arg): Arg contents are %p %zu?\n\n", arg.c_str(), arg.length()); + // printf("From format(sink, mode, spec, stringview arg): What?\n%s\n", std::format("{}", std::string_view{arg.c_str(), arg.length()}).c_str()); auto drainViewResult = sink.drain(arg); result.bytesDrained += drainViewResult.bytesDrained; result.status = drainViewResult.status; -- cgit v1.2.3