1 // Copyright Leandro Lucarella 2008 - 2010.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file COPYING or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef POSIXX_LINUX_TIPC_PRINT_HPP_
8 #define POSIXX_LINUX_TIPC_PRINT_HPP_
10 #include "../tipc.hpp" // posixx::linux::tipc::sockaddr
11 #include <ostream> // std::ostream
14 std::ostream& operator << (std::ostream& os,
15 const posixx::linux::tipc::addr& a) throw()
17 return os << a.zone() << "." << a.cluster() << "." << a.node();
21 std::ostream& operator << (std::ostream& os,
22 const posixx::linux::tipc::portid& p) throw()
24 return os << "portid(" << p.ref << ", " << p.node
25 << " [" << p.node_addr() << "])";
29 std::ostream& operator << (std::ostream& os,
30 const posixx::linux::tipc::name& n) throw()
32 return os << "name(" << n.type << ", " << n.instance << ")";
36 std::ostream& operator << (std::ostream& os,
37 const posixx::linux::tipc::nameseq& ns) throw()
39 return os << "nameseq(" << ns.type << ", " << ns.lower << ", "
44 std::ostream& operator << (std::ostream& os,
45 const posixx::linux::tipc::subscr& s) throw()
47 using namespace posixx::linux::tipc;
49 bool has_filter = false;
51 os << "subscr(" << s.name_seq() << ", " << s.timeout << ", ";
54 if (s.filter & SUB_PORTS) {
58 if (s.filter & SUB_SERVICE) {
66 if (s.filter & SUB_CANCEL) {
77 os << ", '" << std::string(s.usr_handle, sizeof(s.usr_handle)) << "')";
84 std::ostream& operator << (std::ostream& os,
85 const posixx::linux::tipc::subscr_event& e) throw()
87 using namespace posixx::linux::tipc;
88 os << "subscr_event(" << e.event << "[";
89 if (e.event == PUBLISHED)
91 else if (e.event == WITHDRAWN)
93 else if (e.event == TIMEOUT)
95 return os << "], " << e.found_lower << ", " << e.found_upper << ", "
96 << e.port_id() << ", " << e.subscription() << ")";
100 std::ostream& operator << (std::ostream& os,
101 const posixx::linux::tipc::sockaddr& sa) throw()
103 using namespace posixx::linux::tipc;
104 os << "sockaddr(" << sa.family << ", " << unsigned(sa.scope) << ", ";
107 else if (sa.type() == NAME)
108 os << sa.port_name() << ", " << sa.name_domain();
109 else if (sa.type() == NAMESEQ)
112 os << "[UNKNOW addrtype=" << sa.addrtype << "]";
116 #endif // POSIXX_LINUX_TIPC_PRINT_HPP_