added operator<< to write a amqp address to a stream

This commit is contained in:
Emiel Bruijntjes 2017-06-21 09:44:52 +02:00
parent acd6698db3
commit 27ac6aeea5
2 changed files with 36 additions and 0 deletions

View File

@ -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;
}
};
/**

View File

@ -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;
}
};
/**