]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Move Namespace::Foo printing operators to Namespace (#1218)
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 14 Jan 2023 18:29:18 +0000 (18:29 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 16 Jan 2023 16:41:10 +0000 (16:41 +0000)
... where C++ Argument-Dependent Lookup (ADL) can find them.

These specific printing operators did not encounter build problems yet,
but they were misplaced. See commit XXX for rationale and details.

Also removed unimplemented Mgr::ActionParams printing operator.

Also removed excessive "Namespace::" prefixes inside Namespace in
several printing operators declarations that were already properly
placed in their argument's namespaces (e.g., Ipc::ReadWriteLock).

No functionality changes expected.

31 files changed:
src/DiskIO/IpcIo/IpcIoFile.cc
src/DiskIO/IpcIo/IpcIoFile.h
src/acl/Acl.h
src/acl/Options.cc
src/acl/Options.h
src/anyp/ProtocolVersion.h
src/anyp/Uri.h
src/anyp/UriScheme.h
src/clients/HttpTunnelerAnswer.h
src/comm/Connection.cc
src/comm/Connection.h
src/dns/LookupDetails.h
src/helper/Reply.cc
src/helper/Reply.h
src/helper/ReservationId.h
src/http/RegisteredHeaders.cc
src/http/RegisteredHeaders.h
src/ip/NfMarkConfig.cc
src/ip/NfMarkConfig.h
src/ipc/ReadWriteLock.h
src/ipcache.h
src/mgr/ActionParams.h
src/mgr/ActionProfile.h
src/mgr/Command.cc
src/mgr/Command.h
src/security/EncryptorAnswer.h
src/security/ErrorDetail.h
src/security/Handshake.h
src/tests/stub_libcomm.cc
src/tests/stub_libhttp.cc
src/tests/stub_libmgr.cc

index 04e85c42d0a265e04f4aa89e56402fc0b4ea45bc..2b93befd03fb0dcf7181c5b87d0819b86f558260 100644 (file)
@@ -74,16 +74,16 @@ operator <<(std::ostream &os, const SipcIo &sio)
 /* IpcIo::Command */
 
 std::ostream &
-operator <<(std::ostream &os, const IpcIo::Command command)
+IpcIo::operator <<(std::ostream &os, const Command command)
 {
     switch (command) {
-    case IpcIo::cmdNone:
+    case cmdNone:
         return os << '-';
-    case IpcIo::cmdOpen:
+    case cmdOpen:
         return os << 'o';
-    case IpcIo::cmdRead:
+    case cmdRead:
         return os << 'r';
-    case IpcIo::cmdWrite:
+    case cmdWrite:
         return os << 'w';
     }
     // unreachable code
index 56a2f15252069c734b6ebc17bd6aae796dd2e2e9..83d9e02d569841938105d3b84d9d8a7849b1659e 100644 (file)
@@ -32,9 +32,10 @@ namespace IpcIo
 /// what kind of I/O the disker needs to do or have done
 typedef enum { cmdNone, cmdOpen, cmdRead, cmdWrite } Command;
 
+std::ostream &operator <<(std::ostream &, Command);
+
 } // namespace IpcIo
 
-std::ostream &operator <<(std::ostream &, IpcIo::Command);
 
 /// converts DiskIO requests to IPC queue messages
 class IpcIoMsg
index 5c9e76836db7371949e660d344537ab3781a24a6..44a053abbc884a6109585259ea99036b92e76050 100644 (file)
@@ -167,10 +167,8 @@ public:
     bool implicit = false;
 };
 
-} // namespace Acl
-
 inline std::ostream &
-operator <<(std::ostream &o, const Acl::Answer a)
+operator <<(std::ostream &o, const Answer a)
 {
     switch (a) {
     case ACCESS_DENIED:
@@ -189,6 +187,8 @@ operator <<(std::ostream &o, const Acl::Answer a)
     return o;
 }
 
+} // namespace Acl
+
 /// \ingroup ACLAPI
 class acl_proxy_auth_match_cache
 {
index 0650e0da0e8fdcde8814c5cfe63044f59507f671..17a7a820748ed1a34f6d2a309b5f51d3d3390a22 100644 (file)
@@ -245,14 +245,14 @@ Acl::CaseSensitivityOption()
 }
 
 std::ostream &
-operator <<(std::ostream &os, const Acl::Option &option)
+Acl::operator <<(std::ostream &os, const Option &option)
 {
     option.print(os);
     return os;
 }
 
 std::ostream &
-operator <<(std::ostream &os, const Acl::Options &options)
+Acl::operator <<(std::ostream &os, const Options &options)
 {
     for (const auto option: options)
         os << *option;
index 86cdef633d0937bb8bb690b4b494d283bd1dcc88..9746a0b42e9508782652c7fdea4ae73ffabc1987 100644 (file)
@@ -225,10 +225,10 @@ const Options &NoOptions(); ///< \returns an empty Options container
 /// A disabled (+i) and default states are "case sensitive".
 const BooleanOption &CaseSensitivityOption();
 
-} // namespace Acl
+std::ostream &operator <<(std::ostream &, const Option &);
+std::ostream &operator <<(std::ostream &, const Options &);
 
-std::ostream &operator <<(std::ostream &os, const Acl::Option &option);
-std::ostream &operator <<(std::ostream &os, const Acl::Options &options);
+} // namespace Acl
 
 #endif /* SQUID_ACL_OPTIONS_H */
 
index 9fd04a58c7b93382e0fcbee83c32563ec66e79d5..0d85b12e9225d31069f4a6c570b2bdfe0aeb9d7b 100644 (file)
@@ -92,7 +92,7 @@ public:
 };
 
 inline std::ostream &
-operator << (std::ostream &os, const AnyP::ProtocolVersion &v)
+operator << (std::ostream &os, const ProtocolVersion &v)
 {
     return (os << AnyP::ProtocolType_str[v.protocol] << '/' << v.major << '.' << v.minor);
 }
index df83b8bc6463193c72ffc06abdd094fc23f7423f..004439a43d08c34b8e2edeb2ed04cd5a1f9922ff 100644 (file)
@@ -186,18 +186,16 @@ private:
     mutable SBuf absolute_;          ///< RFC 7230 section 5.3.2 absolute-URI
 };
 
-} // namespace AnyP
-
 inline std::ostream &
-operator <<(std::ostream &os, const AnyP::Uri &url)
+operator <<(std::ostream &os, const Uri &url)
 {
     // none means explicit empty string for scheme.
-    if (url.getScheme() != AnyP::PROTO_NONE)
+    if (url.getScheme() != PROTO_NONE)
         os << url.getScheme().image();
     os << ":";
 
     // no authority section on URN
-    if (url.getScheme() != AnyP::PROTO_URN)
+    if (url.getScheme() != PROTO_URN)
         os << "//" << url.authority();
 
     // path is what it is - including absent
@@ -205,6 +203,8 @@ operator <<(std::ostream &os, const AnyP::Uri &url)
     return os;
 }
 
+} // namespace AnyP
+
 /* Deprecated functions for Legacy code handling URLs */
 
 class HttpRequest;
index ef82ede57d116cd05d16c45ffc8f82f1283c23f7..bf4948f5c289678c8ebcc08c384f6f6dae7619e9 100644 (file)
@@ -69,14 +69,14 @@ private:
     SBuf image_;
 };
 
-} // namespace AnyP
-
 inline std::ostream &
-operator << (std::ostream &os, AnyP::UriScheme const &scheme)
+operator <<(std::ostream &os, const UriScheme &scheme)
 {
     os << scheme.image();
     return os;
 }
 
+} // namespace AnyP
+
 #endif /* SQUID_ANYP_URISCHEME_H */
 
index b26bb32aa0d932ddecbd24de3d2db16bda88734a..38553b3a6f7ebf9455a6d050076ef8e5e0651eaf 100644 (file)
@@ -47,7 +47,7 @@ public:
     Comm::ConnectionPointer conn;
 };
 
-std::ostream &operator <<(std::ostream &, const Http::TunnelerAnswer &);
+std::ostream &operator <<(std::ostream &, const TunnelerAnswer &);
 
 } // namespace Http
 
index 08d36f33c82fe805ee5320e99c7adf5cfda11a6b..d964f48583da543bbfd2cafe9aed9623acd05af8 100644 (file)
@@ -192,7 +192,7 @@ Comm::Connection::detailCodeContext(std::ostream &os) const
 }
 
 std::ostream &
-operator << (std::ostream &os, const Comm::Connection &conn)
+Comm::operator << (std::ostream &os, const Connection &conn)
 {
     os << conn.id;
     if (!conn.local.isNoAddr() || conn.local.port())
index 8a7589895fde96308cc02d86484c3094e4215f3f..b5835b547c086b89dfbd6dd4d67cfd9549ed8591 100644 (file)
@@ -193,17 +193,17 @@ private:
     Security::NegotiationHistory *tlsHistory;
 };
 
-}; // namespace Comm
-
-std::ostream &operator << (std::ostream &os, const Comm::Connection &conn);
+std::ostream &operator <<(std::ostream &, const Connection &);
 
 inline std::ostream &
-operator << (std::ostream &os, const Comm::ConnectionPointer &conn)
+operator <<(std::ostream &os, const ConnectionPointer &conn)
 {
     if (conn != nullptr)
         os << *conn;
     return os;
 }
 
+} // namespace Comm
+
 #endif
 
index 47f1f062f4ca40c8e16f32b8c55c1824d0fe539e..fb7647129928a0d5f99f583b292666fab4f753d9 100644 (file)
@@ -30,13 +30,13 @@ public:
     int wait; ///< msecs spent waiting for the lookup (if any) or -1 (if none)
 };
 
-} // namespace Dns
-
 inline std::ostream &
-operator <<(std::ostream &os, const Dns::LookupDetails &dns)
+operator <<(std::ostream &os, const LookupDetails &dns)
 {
     return dns.print(os);
 }
 
+} // namespace Dns
+
 #endif /* SQUID_DNS_LOOKUPDETAILS_H */
 
index d21d5a14d069b24ce892c9cc88932481f59e6b93..aef0f7413d5cb048645534ed5965009343f7b7e6 100644 (file)
@@ -249,26 +249,26 @@ Helper::Reply::emptyBuf() const
 }
 
 std::ostream &
-operator <<(std::ostream &os, const Helper::Reply &r)
+Helper::operator <<(std::ostream &os, const Reply &r)
 {
     os << "{result=";
     switch (r.result) {
-    case Helper::Okay:
+    case Okay:
         os << "OK";
         break;
-    case Helper::Error:
+    case Error:
         os << "ERR";
         break;
-    case Helper::BrokenHelper:
+    case BrokenHelper:
         os << "BH";
         break;
-    case Helper::TT:
+    case TT:
         os << "TT";
         break;
-    case Helper::TimedOut:
+    case TimedOut:
         os << "Timeout";
         break;
-    case Helper::Unknown:
+    case Unknown:
         os << "Unknown";
         break;
     }
index 3c75a51604b29a204e4346a41ea10f61e840c791..f8e29dab42aa6f019a1c493cd4b3ee9c478683cc 100644 (file)
@@ -75,9 +75,10 @@ private:
     MemBuf other_;
 };
 
+std::ostream &operator <<(std::ostream &, const Reply &);
+
 } // namespace Helper
 
-std::ostream &operator <<(std::ostream &os, const Helper::Reply &r);
 
 #endif /* _SQUID_SRC_HELPER_REPLY_H */
 
index 4eadf5bd73df837590ea4721d9527695c2c09552..b79124f7131549c0ace39c4350bac959c34f0639 100644 (file)
@@ -36,14 +36,14 @@ private:
     uint64_t id = 0; ///< uniquely identifies this reservation
 };
 
-}; // namespace Helper
-
 inline std::ostream &
-operator <<(std::ostream &os, const Helper::ReservationId &id)
+operator <<(std::ostream &os, const ReservationId &id)
 {
     return id.print(os);
 }
 
+}; // namespace Helper
+
 namespace std {
 /// default hash functor to support std::unordered_map<HelperReservationId, *>
 template <>
index 94b0afc050b8d248a12b70e2ea5fb724c1c0108b..5717fabe060a947cd7ab668b0c671cd0645a63f8 100644 (file)
@@ -62,10 +62,10 @@ const HeaderLookupTable_t HeaderLookupTable;
 }; /* namespace Http */
 
 std::ostream&
-operator<< (std::ostream &s, Http::HdrType id)
+Http::operator<< (std::ostream &s, const HdrType id)
 {
-    if (Http::any_HdrType_enum_value(id))
-        s << Http::HeaderLookupTable.lookup(id).name << '[' << static_cast<int>(id) << ']';
+    if (any_HdrType_enum_value(id))
+        s << HeaderLookupTable.lookup(id).name << '[' << static_cast<int>(id) << ']';
     else
         s << "Invalid-Header[" << static_cast<int>(id) << ']';
     return s;
index e6cbeafd3e5555005c083819dbe4944b890d43b0..9bc9bd42eeb128abdd0b728cd06e3a64c02e78fc 100644 (file)
@@ -222,11 +222,10 @@ any_registered_header (const Http::HdrType id)
     return (id >= Http::HdrType::ACCEPT && id < Http::HdrType::OTHER);
 }
 
+std::ostream &operator <<(std::ostream &, HdrType);
+
 }; /* namespace Http */
 
-/* ostream output for Http::HdrType */
-std::ostream &
-operator<< (std::ostream&, Http::HdrType);
 
 #endif /* SQUID_HTTP_REGISTEREDHEADERS_H */
 
index d87b2dd0d4e1424f64d26d8e2046347a40478580..4c1d84d4173f46ad55f9c82789e46cd1f9a8b405 100644 (file)
@@ -49,7 +49,7 @@ Ip::NfMarkConfig::applyToMark(nfmark_t m) const
 }
 
 std::ostream &
-operator <<(std::ostream &os, const Ip::NfMarkConfig c)
+Ip::operator <<(std::ostream &os, const NfMarkConfig c)
 {
     os << asHex(c.mark);
 
index bbd5b7a1308eef63600b461118e731b4f730c5d7..a21717b586d07c019af343c29730cf6b66644fe1 100644 (file)
@@ -42,9 +42,10 @@ public:
     nfmark_t mask = 0xffffffff;
 };
 
+std::ostream &operator <<(std::ostream &, NfMarkConfig);
+
 } // namespace Ip
 
-std::ostream &operator <<(std::ostream &os, const Ip::NfMarkConfig connmark);
 
 #endif // SQUID_NFMARKCONFIG_H
 
index 01c57eba181618b66ff9cd33668592a1f204ff23..90c67adf1208128b5f6d4b76c4df6ad05ae5bb30 100644 (file)
@@ -59,7 +59,7 @@ private:
 };
 
 /// dumps approximate lock state (for debugging)
-std::ostream &operator <<(std::ostream &os, const Ipc::ReadWriteLock &);
+std::ostream &operator <<(std::ostream &, const ReadWriteLock &);
 
 /// approximate stats of a set of ReadWriteLocks
 class ReadWriteLockStats
index b581891776995834f5c7347aecd172ff6cba944a..7eb0e97a9bbaaac5b9baa3e6a867393f982811b1 100644 (file)
@@ -212,6 +212,13 @@ public:
 /// initiate an (often) asynchronous DNS lookup; the `receiver` gets the results
 void nbgethostbyname(const char *name, const CbcPointer<IpReceiver> &receiver);
 
+inline std::ostream &
+operator <<(std::ostream &os, const CachedIps &ips)
+{
+    ips.reportCurrent(os);
+    return os;
+}
+
 } // namespace Dns
 
 typedef Dns::CachedIps ipcache_addrs; ///< deprecated alias
@@ -229,13 +236,6 @@ void ipcacheMarkGoodAddr(const char *name, const Ip::Address &);
 void ipcache_restart(void);
 int ipcacheAddEntryFromHosts(const char *name, const char *ipaddr);
 
-inline std::ostream &
-operator <<(std::ostream &os, const Dns::CachedIps &ips)
-{
-    ips.reportCurrent(os);
-    return os;
-}
-
 /* inlined implementations */
 
 inline Dns::IpsSelector<Dns::GoodIpsIterator>
index fad4194c41ee4c0f4d0e623a2509a88417373b33..4cd289f31e88a0d877466c9a87db6609f1396171 100644 (file)
@@ -44,7 +44,5 @@ public:
 
 } // namespace Mgr
 
-std::ostream &operator <<(std::ostream &os, const Mgr::ActionParams &params);
-
 #endif /* SQUID_MGR_ACTION_PARAMS_H */
 
index 895cc09033188a2c693c71351a0dce35a2666279..263c7298d323ef10b298c230786b21965f129857 100644 (file)
@@ -38,13 +38,13 @@ public:
     ActionCreatorPointer creator; ///< creates Action objects with this profile
 };
 
-} // namespace Mgr
-
 inline std::ostream &
-operator <<(std::ostream &os, const Mgr::ActionProfile &profile)
+operator <<(std::ostream &os, const ActionProfile &profile)
 {
     return os << profile.name;
 }
 
+} // namespace Mgr
+
 #endif /* SQUID_MGR_ACTION_PROFILE_H */
 
index 895feef5b59a372cd8d58931ce3dd9fe95865af0..f8ce1059523f24a98eb075965d6aed951f5b2d2e 100644 (file)
@@ -13,7 +13,7 @@
 #include "mgr/Command.h"
 
 std::ostream &
-operator <<(std::ostream &os, const Mgr::Command &cmd)
+Mgr::operator <<(std::ostream &os, const Command &cmd)
 {
     if (cmd.profile != nullptr)
         return os << *cmd.profile;
index 52395e6daa6283c10ef51d8c2d12f334e0ac6502..58f662ce4534d30c24df4c5e05a9d4d0344d65c2 100644 (file)
@@ -28,9 +28,9 @@ public:
     ActionParams params; ///< user-supplied action arguments
 };
 
-} // namespace Mgr
+std::ostream &operator <<(std::ostream &, const Command &);
 
-std::ostream &operator <<(std::ostream &os, const Mgr::Command &cmd);
+} // namespace Mgr
 
 #endif /* SQUID_MGR_COMMAND_H */
 
index a0dd150bb0fe61423ecc42f668ee4145ddc001d7..d98962681decb71d1cbf9c6800b45459004ad57b 100644 (file)
@@ -33,7 +33,7 @@ public:
     bool tunneled;
 };
 
-std::ostream &operator <<(std::ostream &, const Security::EncryptorAnswer &);
+std::ostream &operator <<(std::ostream &, const EncryptorAnswer &);
 
 } // namespace Security
 
index 0b37d14e4a6a8617fefcdba1d9d56b7a2a2c08f3..cf120c8e868833c294d24c41a2089d960df5cf23 100644 (file)
@@ -126,17 +126,17 @@ ErrorCode ErrorCodeFromName(const char *name);
 /// \param prefixRawCode whether to prefix raw codes with "SSL_ERR="
 const char *ErrorNameFromCode(ErrorCode err, bool prefixRawCode = false);
 
-} // namespace Security
-
 /// Dump the given Security::ErrorDetail via a possibly nil pointer (for
 /// debugging). Unfortunately, without this, compilers pick generic RefCount<T>
 /// operator "<<" overload (with T=Security::ErrorDetail) instead of the
 /// overload provided by the parent ErrorDetail class (that we call here).
 inline std::ostream &
-operator <<(std::ostream &os, const Security::ErrorDetail::Pointer &p)
+operator <<(std::ostream &os, const ErrorDetail::Pointer &p)
 {
     return operator <<(os, ::ErrorDetail::Pointer(p));
 }
 
+} // namespace Security
+
 #endif
 
index 9ead634c6170e28a0b25fb88fc934673a5f59074..75f4971da88fd43efbcf9b3e286ff95f9cf10c9d 100644 (file)
@@ -50,8 +50,8 @@ public:
     Ciphers ciphers;
 };
 
-inline
-std::ostream &operator <<(std::ostream &os, Security::TlsDetails const &details)
+inline std::ostream &
+operator <<(std::ostream &os, const TlsDetails &details)
 {
     return details.print(os);
 }
index 29b294fc64e9298c34e91804db5698ac5f78d7ce..e936a17fe8838fbb8d2352a8b3f332a1c8b8805a 100644 (file)
@@ -85,5 +85,5 @@ void Comm::Write(const Comm::ConnectionPointer &, MemBuf *, AsyncCall::Pointer &
 void Comm::WriteCancel(const Comm::ConnectionPointer &, const char *) STUB
 /*PF*/ void Comm::HandleWrite(int, void*) STUB
 
-std::ostream &operator << (std::ostream &os, const Comm::Connection &) STUB_RETVAL(os << "[Connection object]")
+std::ostream &Comm::operator <<(std::ostream &os, const Connection &) STUB_RETVAL(os << "[Connection object]")
 
index 0419ffe31880f1361dfec5f4cdbded981c629e9d..56e01c98af0d34b82aa00a2a3b8e0c41ae357063 100644 (file)
@@ -67,7 +67,7 @@ HeaderLookupTable_t::HeaderLookupTable_t() {STUB_NOP}
 const HeaderTableRecord& HeaderLookupTable_t::lookup(const char *, const std::size_t) const STUB_RETVAL(BadHdr)
 const HeaderLookupTable_t HeaderLookupTable;
 }
-std::ostream &operator<< (std::ostream&os, Http::HdrType) STUB_RETVAL(os)
+std::ostream &Http::operator <<(std::ostream &os, HdrType) STUB_RETVAL(os)
 
 #include "http/RequestMethod.h"
 HttpRequestMethod::HttpRequestMethod(const SBuf &) {STUB}
index 16d100c51e93ccf427488fe2a5d1b88d75f74111..9fd1d752a815fc90ba0682023d2f9f30174085ec 100644 (file)
@@ -19,7 +19,7 @@
 
 // NP: used by Action.h instantiations
 #include "mgr/Command.h"
-std::ostream &operator <<(std::ostream &os, const Mgr::Command &) STUB_RETVAL(os)
+std::ostream &Mgr::operator <<(std::ostream &os, const Command &) STUB_RETVAL(os)
 
 #include "mgr/Action.h"
 Mgr::Action::Action(const CommandPointer &) STUB
@@ -40,7 +40,6 @@ static Mgr::Action::Pointer dummyAction;
 Mgr::ActionParams::ActionParams() STUB_NOP
 Mgr::ActionParams::ActionParams(const Ipc::TypedMsgHdr &) STUB_NOP
 void Mgr::ActionParams::pack(Ipc::TypedMsgHdr &) const STUB
-std::ostream &operator <<(std::ostream &os, const Mgr::ActionParams &) STUB_RETVAL(os)
 
 #include "mgr/ActionWriter.h"
 //Mgr::ActionWriter::ActionWriter(const Action::Pointer &, int) STUB