diff --git a/include/address.h b/include/address.h index 2117995..c2e9f21 100644 --- a/include/address.h +++ b/include/address.h @@ -236,6 +236,30 @@ public: // the opposite of operator== return !operator==(that); } + + /** + * Friend function to allow writing the address to a stream + * @param stream + * @param address + * @return std::ostream + */ + friend std::ostream &operator<<(std::ostream &stream, const Address &address) + { + // start with the protocol and login + stream << "amqp://" << address._login; + + // do we need a special portnumber? + if (address._port != 5672) stream << ":" << address._port; + + // append default vhost + stream << "/"; + + // do we have a special vhost? + if (address._vhost != "/") stream << address._vhost; + + // done + return stream; + } }; /** diff --git a/include/login.h b/include/login.h index f68f1aa..d4599d9 100644 --- a/include/login.h +++ b/include/login.h @@ -120,6 +120,18 @@ public: return !operator==(that); } + /** + * Friend function to allow writing the login to a stream + * @param stream + * @param login + * @return std::ostream + */ + friend std::ostream &operator<<(std::ostream &stream, const Login &login) + { + // write username and password + return stream << login._user << "@" << login._password; + } + }; /**