removed
[ghsmtp.git] / DNS-iostream.hpp
blobd9536249e1f1ccfb88925b9b010c7eb93e599dd4
1 #ifndef DNS_IOSTREAM_DOT_HPP
2 #define DNS_IOSTREAM_DOT_HPP
4 #include "DNS-rrs.hpp"
6 #include <iostream>
8 inline std::ostream& operator<<(std::ostream& os, DNS::RR_A const& rr_a)
10 return os << "A " << rr_a.c_str();
13 inline std::ostream& operator<<(std::ostream& os, DNS::RR_CNAME const& rr_c)
15 return os << "CNAME " << rr_c.str();
18 inline std::ostream& operator<<(std::ostream& os, DNS::RR_PTR const& rr_ptr)
20 return os << "PTR " << rr_ptr.str();
23 inline std::ostream& operator<<(std::ostream& os, DNS::RR_MX const& rr_mx)
25 return os << "MX " << rr_mx.preference() << ' ' << rr_mx.exchange();
28 inline std::ostream& operator<<(std::ostream& os, DNS::RR_TXT const& rr_txt)
30 return os << "TXT " << rr_txt.str();
33 inline std::ostream& operator<<(std::ostream& os, DNS::RR_AAAA const& rr_aaaa)
35 return os << "AAAA " << rr_aaaa.c_str();
38 inline std::ostream& operator<<(std::ostream& os, DNS::RR_TLSA const& rr_tlsa)
40 os << "TLSA " << rr_tlsa.cert_usage() << ' ' << rr_tlsa.selector() << ' '
41 << rr_tlsa.matching_type() << ' ';
43 for (auto const& ch : rr_tlsa.assoc_data()) {
44 auto const lo = ch & 0xF;
45 auto const hi = (ch >> 4) & 0xF;
47 using namespace std::literals::string_view_literals;
48 auto constexpr hex_digits{"0123456789abcdef"sv};
50 os << hex_digits[hi] << hex_digits[lo];
53 return os;
56 inline std::ostream& operator<<(std::ostream& os, DNS::RR_type const& type)
58 return os << DNS::RR_type_c_str(type);
61 #endif // DNS_IOSTREAM_DOT_HPP