diff options
author | Alan Conway <aconway@apache.org> | 2008-11-20 18:29:20 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-11-20 18:29:20 +0000 |
commit | 24f410931d76bc37dd575436a7b11a87b6aef0c9 (patch) | |
tree | 49ee770cf521f3a0bba881cee7219082ee89b2c2 /cpp/src/qpid/Address.cpp | |
parent | 5b93ee887ca64e26fb2440bab4c9785ea3de2e79 (diff) | |
download | qpid-python-24f410931d76bc37dd575436a7b11a87b6aef0c9.tar.gz |
Replaced boost.spirit-based URL parser with simple recursive descent parser.
boost.spirit has some known thread-safety issues and appears to be causing
qpid clients to crash in several scenarios.
The new parser is trivially thread safe and relatively easy to extend.
It's a simple recursive descent parser, sufficient for simple grammars
like those used in URL formats. It's not intended to be a
full-featured parser framework like spirit.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@719317 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/Address.cpp')
-rw-r--r-- | cpp/src/qpid/Address.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/cpp/src/qpid/Address.cpp b/cpp/src/qpid/Address.cpp index e278c0295c..ac8c7f30b1 100644 --- a/cpp/src/qpid/Address.cpp +++ b/cpp/src/qpid/Address.cpp @@ -18,17 +18,41 @@ #include "Address.h" +#include <ostream> + +using namespace std; + namespace qpid { -std::ostream& operator<<(std::ostream& os, const Address& addr) { - const TcpAddress *t = addr.get<TcpAddress>(); - if (t) - os << *t; - return os; +TcpAddress::TcpAddress(const std::string& h, uint16_t p): host(h), port(p) {} + +struct AddressOstreamVisitor : public boost::static_visitor<ostream&> { + ostream& out; + AddressOstreamVisitor(ostream& o) : out(o) {} + template <class T> ostream& operator()(const T& data) { return out << data; } +}; + +ostream& operator<<(ostream& os, const Address& addr) { + AddressOstreamVisitor visitor(os); + return boost::apply_visitor(visitor, addr.value); +} + +bool operator==(const TcpAddress& x, const TcpAddress& y) { + return y.host==x.host && y.port == x.port; } -std::ostream& operator<<(std::ostream& os, const TcpAddress& a) { +ostream& operator<<(ostream& os, const TcpAddress& a) { return os << "tcp:" << a.host << ":" << a.port; } +ExampleAddress::ExampleAddress(const char c) : data(c) {} + +bool operator==(const ExampleAddress& x, const ExampleAddress& y) { + return x.data == y.data; +} + +ostream& operator<<(ostream& os, const ExampleAddress& ex) { + return os << "example:" << ex.data; +} + } // namespace qpid |