From fcdca58617caf6a8c034a91588d6abb399be6b57 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 18 May 2021 00:06:37 +0100 Subject: Initial commit, still lots to do! --- lib/streamSupport.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/streamSupport.cpp (limited to 'lib/streamSupport.cpp') diff --git a/lib/streamSupport.cpp b/lib/streamSupport.cpp new file mode 100644 index 0000000..541b191 --- /dev/null +++ b/lib/streamSupport.cpp @@ -0,0 +1,53 @@ +#include "streamSupport.h" +#include "compileTimeFormatter.h" + +namespace std { + std::ostream & + operator<<(std::ostream & strm, const std::byte byt) + { + return AdHoc::scprintf<"%#02x">(strm, std::to_integer(byt)); + } + + std::ostream & + operator<<(std::ostream & s, const MARIADB_STRING & str) + { + return s.write(str.str, str.length); + } + + std::ostream & + operator<<(std::ostream & s, const tm & tm) + { + return AdHoc::scprintf<"%04d-%02d-%02d %02d:%02d:%02d">( + s, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + } + + std::ostream & + operator<<(std::ostream & s, const timespec & ts) + { + return AdHoc::scprintf<"%d.%09d">(s, ts.tv_sec, ts.tv_nsec); + } + + std::ostream & + operator<<(std::ostream & s, const MyGrate::MySQL::Date & d) + { + return AdHoc::scprintf<"%04d-%02d-%02d">(s, d.year, d.month, d.day); + } + + std::ostream & + operator<<(std::ostream & s, const MyGrate::MySQL::Time & t) + { + return AdHoc::scprintf<"%02d:%02d:%02d">(s, t.hour, t.minute, t.second); + } + + std::ostream & + operator<<(std::ostream & s, const MyGrate::MySQL::DateTime & dt) + { + return AdHoc::scprintf<"%? %?">(s, (const MyGrate::MySQL::Date)dt, (const MyGrate::MySQL::Time)dt); + } + + std::ostream & + operator<<(std::ostream & s, const MyGrate::BitSet & bs) + { + return s << std::make_pair(bs.begin(), bs.end()); + } +} -- cgit v1.2.3