diff --git a/src/pvxs/util.h b/src/pvxs/util.h index 964703c..4c58019 100644 --- a/src/pvxs/util.h +++ b/src/pvxs/util.h @@ -104,57 +104,6 @@ public: #endif // !defined(__rtems__) && !defined(vxWorks) -//! representation of a network address -struct PVXS_API SockAddr { - union store_t { - sockaddr sa; - sockaddr_in in; -#ifdef AF_INET6 - sockaddr_in6 in6; -#endif - }; -private: - store_t store; -public: - - explicit SockAddr(int af = AF_UNSPEC); - explicit SockAddr(int af, const char *address, unsigned short port=0); - explicit SockAddr(const sockaddr *addr, ev_socklen_t len); - inline explicit SockAddr(int af, const std::string& address) :SockAddr(af, address.c_str()) {} - - size_t size() const; - - inline unsigned short family() const { return store.sa.sa_family; } - unsigned short port() const; - void setPort(unsigned short port); - - void setAddress(const char *, unsigned short port=0); - - bool isAny() const; - bool isLO() const; - - store_t* operator->() { return &store; } - const store_t* operator->() const { return &store; } - - std::string tostring() const; - - static SockAddr any(int af, unsigned port=0); - static SockAddr loopback(int af, unsigned port=0); - - inline bool operator<(const SockAddr& o) const { - return evutil_sockaddr_cmp(&store.sa, &o.store.sa, true)<0; - } - inline bool operator==(const SockAddr& o) const { - return evutil_sockaddr_cmp(&store.sa, &o.store.sa, true)==0; - } - inline bool operator!=(const SockAddr& o) const { - return !(*this==o); - } -}; - -PVXS_API -std::ostream& operator<<(std::ostream& strm, const SockAddr& addr); - } // namespace pvxs #endif // PVXS_UTIL_H diff --git a/src/util.cpp b/src/util.cpp index 228f69f..ed350f6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -378,7 +378,7 @@ std::ostream& operator<<(std::ostream& strm, const SockAddr& addr) return strm; } -} +} // namespace pvxs namespace pvxs {namespace impl { namespace idetail { diff --git a/src/utilpvt.h b/src/utilpvt.h index 02d5960..6f15327 100644 --- a/src/utilpvt.h +++ b/src/utilpvt.h @@ -181,6 +181,58 @@ using aligned_union = std::aligned_union; } // namespace impl using namespace impl; + +//! representation of a network address +struct PVXS_API SockAddr { + union store_t { + sockaddr sa; + sockaddr_in in; +#ifdef AF_INET6 + sockaddr_in6 in6; +#endif + }; +private: + store_t store; +public: + + explicit SockAddr(int af = AF_UNSPEC); + explicit SockAddr(int af, const char *address, unsigned short port=0); + explicit SockAddr(const sockaddr *addr, ev_socklen_t len); + inline explicit SockAddr(int af, const std::string& address) :SockAddr(af, address.c_str()) {} + + size_t size() const; + + inline unsigned short family() const { return store.sa.sa_family; } + unsigned short port() const; + void setPort(unsigned short port); + + void setAddress(const char *, unsigned short port=0); + + bool isAny() const; + bool isLO() const; + + store_t* operator->() { return &store; } + const store_t* operator->() const { return &store; } + + std::string tostring() const; + + static SockAddr any(int af, unsigned port=0); + static SockAddr loopback(int af, unsigned port=0); + + inline bool operator<(const SockAddr& o) const { + return evutil_sockaddr_cmp(&store.sa, &o.store.sa, true)<0; + } + inline bool operator==(const SockAddr& o) const { + return evutil_sockaddr_cmp(&store.sa, &o.store.sa, true)==0; + } + inline bool operator!=(const SockAddr& o) const { + return !(*this==o); + } +}; + +PVXS_API +std::ostream& operator<<(std::ostream& strm, const SockAddr& addr); + } // namespace pvxs #endif // UTILPVT_H