]> git.llucax.com Git - software/posixx.git/blob - src/linux/tipc/print.hpp
Update Makeit.mak
[software/posixx.git] / src / linux / tipc / print.hpp
1 #ifndef POSIXX_LINUX_TIPC_PRINT_HPP_
2 #define POSIXX_LINUX_TIPC_PRINT_HPP_
3
4 #include "../tipc.hpp" // posixx::linux::tipc::sockaddr
5 #include <ostream> // std::ostream
6
7 inline
8 std::ostream& operator << (std::ostream& os,
9                 const posixx::linux::tipc::addr& a) throw()
10 {
11         return os << a.zone() << "." << a.cluster() << "." << a.node();
12 }
13
14 inline
15 std::ostream& operator << (std::ostream& os,
16                 const posixx::linux::tipc::portid& p) throw()
17 {
18         return os << "portid(" << p.ref << ", " << p.node
19                         << " [" << p.node_addr() << "])";
20 }
21
22 inline
23 std::ostream& operator << (std::ostream& os,
24                 const posixx::linux::tipc::name& n) throw()
25 {
26         return os << "name(" << n.type << ", " << n.instance << ")";
27 }
28
29 inline
30 std::ostream& operator << (std::ostream& os,
31                 const posixx::linux::tipc::nameseq& ns) throw()
32 {
33         return os << "nameseq(" << ns.type << ", " << ns.lower << ", "
34                         << ns.upper << ")";
35 }
36
37 inline
38 std::ostream& operator << (std::ostream& os,
39                 const posixx::linux::tipc::subscr& s) throw()
40 {
41         using namespace posixx::linux::tipc;
42
43         bool has_filter = false;
44
45         os << "subscr(" << s.name_seq() << ", " << s.timeout << ", ";
46
47         os << s.filter;
48         if (s.filter & SUB_PORTS) {
49                 os << " [PORTS";
50                 has_filter = true;
51         }
52         if (s.filter & SUB_SERVICE) {
53                 if (has_filter)
54                         os << "|";
55                 else
56                         os << "[";
57                 os << "SERVICE";
58                 has_filter = true;
59         }
60         if (s.filter & SUB_CANCEL) {
61                 if (has_filter)
62                         os << "|";
63                 else
64                         os << "[";
65                 os << "CANCEL";
66                 has_filter = true;
67         }
68         if (has_filter)
69                 os << "]";
70
71         os << ", '" << std::string(s.usr_handle, sizeof(s.usr_handle)) << "')";
72
73         return os;
74
75 }
76
77 inline
78 std::ostream& operator << (std::ostream& os,
79                 const posixx::linux::tipc::subscr_event& e) throw()
80 {
81         using namespace posixx::linux::tipc;
82         os << "subscr_event(" << e.event << "[";
83         if (e.event == PUBLISHED)
84                 os << "PUBLISHED";
85         else if (e.event == WITHDRAWN)
86                 os << "WITHDRAWN";
87         else if (e.event == TIMEOUT)
88                 os << "TIMEOUT";
89         return os << "], " << e.found_lower << ", " << e.found_upper << ", "
90                         << e.port_id() << ", " << e.subscription() << ")";
91 }
92
93 inline
94 std::ostream& operator << (std::ostream& os,
95                 const posixx::linux::tipc::sockaddr& sa) throw()
96 {
97         using namespace posixx::linux::tipc;
98         os << "sockaddr(" << sa.family << ", " << unsigned(sa.scope) << ", ";
99         if (sa.type() == ID)
100                 os << sa.port_id();
101         else if (sa.type() == NAME)
102                 os << sa.port_name() << ", " << sa.name_domain();
103         else if (sa.type() == NAMESEQ)
104                 os << sa.name_seq();
105         else
106                 os << "[UNKNOW addrtype=" << sa.addrtype << "]";
107         return os << ")";
108 }
109
110 #endif // POSIXX_LINUX_TIPC_PRINT_HPP_