From 964f7ec93c2b01aa2c3d171f01210df742dd0724 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 13 Jul 2021 20:18:09 +0100 Subject: Wider type support for PQ bindings timespec not supported... honestly not sure what it should bind! --- lib/output/pq/pqBindings.h | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'lib/output/pq/pqBindings.h') diff --git a/lib/output/pq/pqBindings.h b/lib/output/pq/pqBindings.h index 5df1a34..13d0f69 100644 --- a/lib/output/pq/pqBindings.h +++ b/lib/output/pq/pqBindings.h @@ -1,9 +1,11 @@ #ifndef MYGRATE_OUTPUT_PQ_PQBINDINGS #define MYGRATE_OUTPUT_PQ_PQBINDINGS +#include #include #include #include +#include #include #include @@ -15,6 +17,7 @@ namespace MyGrate::Output::Pq { bufs.reserve(vs.size()); values.reserve(vs.size()); lengths.reserve(vs.size()); + formats.reserve(vs.size()); for (const auto & v : vs) { v.visit(*this); } @@ -23,10 +26,7 @@ namespace MyGrate::Output::Pq { void operator()(const T & v) { - bufs.emplace_back(std::to_string(v)); - const auto & vw {bufs.back()}; - values.emplace_back(vw.data()); - lengths.emplace_back(vw.length()); + addBuf(std::to_string(v)); } template void @@ -34,10 +34,16 @@ namespace MyGrate::Output::Pq { { values.emplace_back(v.data()); lengths.emplace_back(v.size()); + formats.push_back(1); } template void - operator()(const T &) + operator()(const T & v) + { + addBuf(scprintf<"%?">(v)); + } + void + operator()(const timespec &) { throw std::logic_error("Not implemented"); } @@ -46,11 +52,23 @@ namespace MyGrate::Output::Pq { { values.emplace_back(nullptr); lengths.emplace_back(0); + formats.push_back(0); } std::vector bufs; std::vector values; std::vector lengths; + std::vector formats; + + private: + void + addBuf(std::string str) + { + const auto & vw = bufs.emplace_back(std::move(str)); + values.emplace_back(vw.data()); + lengths.emplace_back(vw.length()); + formats.push_back(0); + } }; } -- cgit v1.2.3