summaryrefslogtreecommitdiff
path: root/lib/streamSupport.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-05-18 00:06:37 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-05-18 00:06:37 +0100
commitfcdca58617caf6a8c034a91588d6abb399be6b57 (patch)
treead77f8e954a2ed05cd26237a7c665f3adc82b9fe /lib/streamSupport.cpp
downloadmygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.tar.bz2
mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.tar.xz
mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.zip
Initial commit, still lots to do!
Diffstat (limited to 'lib/streamSupport.cpp')
-rw-r--r--lib/streamSupport.cpp53
1 files changed, 53 insertions, 0 deletions
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<uint8_t>(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());
+ }
+}