summaryrefslogtreecommitdiff
path: root/lib/streamSupport.h
blob: 0723faf1af8d3933bbe0dd87902f78ea035a4aa2 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef MYGRATE_STREAM_SUPPORT_H
#define MYGRATE_STREAM_SUPPORT_H

#include <array>
#include <cstddef>
#include <iomanip>
#include <mysql.h>
#include <ostream>
#include <span>
#include <vector>

#include "mysql_types.h"
#include <mariadb_rpl.h>

namespace std {
	std::ostream & operator<<(std::ostream & strm, const std::byte byt);

	std::ostream & operator<<(std::ostream & s, const MARIADB_STRING & str);

	std::ostream & operator<<(std::ostream & s, const tm & tm);

	std::ostream & operator<<(std::ostream & s, const timespec & ts);

	std::ostream & operator<<(std::ostream & s, const MyGrate::MySQL::Date & d);

	std::ostream & operator<<(std::ostream & s, const MyGrate::MySQL::Time & t);

	std::ostream & operator<<(std::ostream & s, const MyGrate::MySQL::DateTime & dt);

	std::ostream & operator<<(std::ostream & s, const MyGrate::BitSet & bs);

	template<std::forward_iterator Iter>
	inline std::ostream &
	operator<<(std::ostream & strm, const std::pair<Iter, Iter> range)
	{
		strm << '[';
		for (auto i {range.first}; i != range.second; i++) {
			if (i != range.first) {
				strm << ',';
			}
			strm << *i;
		}
		return strm << ']';
	}

	template<typename T>
	std::ostream &
	operator<<(std::ostream & strm, const std::span<const T> spn)
	{
		return strm << std::make_pair(spn.begin(), spn.end());
	}

	template<typename T>
	std::ostream &
	operator<<(std::ostream & strm, const std::vector<T> & v)
	{
		return strm << std::span<const T>(v.data(), v.size());
	}

	template<typename T, std::size_t L>
	std::ostream &
	operator<<(std::ostream & strm, const std::array<T, L> & a)
	{
		return strm << std::span<const T>(a.begin(), a.end());
	}
}

#endif