summaryrefslogtreecommitdiff
path: root/lib/streamSupport.cpp
blob: 541b191ff928eda3b36b179e172db08d291867de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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());
	}
}