diff options
author | Gordon Sim <gsim@apache.org> | 2011-08-10 17:01:55 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2011-08-10 17:01:55 +0000 |
commit | d687ac9e72fb9875c232750cdc21246e1d9c982f (patch) | |
tree | 839ab35c2358b638f1980604aa1aa6ce398b6e37 /cpp/src | |
parent | 238a7f000808121c53186625220240c4e709e4fa (diff) | |
download | qpid-python-d687ac9e72fb9875c232750cdc21246e1d9c982f.tar.gz |
NO-JIRA: Remove redundant code (qpid::Url now does everything required)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1156262 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cpp/src/Makefile.am | 4 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp | 13 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SimpleUrlParser.cpp | 79 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SimpleUrlParser.h | 42 |
5 files changed, 5 insertions, 135 deletions
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index b0ea19709b..49f94322d8 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -923,8 +923,6 @@ set (qpidmessaging_SOURCES qpid/client/amqp0_10/SessionImpl.cpp qpid/client/amqp0_10/SenderImpl.h qpid/client/amqp0_10/SenderImpl.cpp - qpid/client/amqp0_10/SimpleUrlParser.h - qpid/client/amqp0_10/SimpleUrlParser.cpp ) add_msvc_version (qpidmessaging library dll) diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 4e13e9ad9c..4f9d7ab28a 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -789,9 +789,7 @@ libqpidmessaging_la_SOURCES = \ qpid/client/amqp0_10/SessionImpl.h \ qpid/client/amqp0_10/SessionImpl.cpp \ qpid/client/amqp0_10/SenderImpl.h \ - qpid/client/amqp0_10/SenderImpl.cpp \ - qpid/client/amqp0_10/SimpleUrlParser.h \ - qpid/client/amqp0_10/SimpleUrlParser.cpp + qpid/client/amqp0_10/SenderImpl.cpp QPIDMESSAGING_VERSION_INFO = 2:0:0 libqpidmessaging_la_LDFLAGS = -version-info $(QPIDMESSAGING_VERSION_INFO) diff --git a/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp b/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp index 3492938156..491d05a5dc 100644 --- a/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp @@ -20,7 +20,6 @@ */ #include "ConnectionImpl.h" #include "SessionImpl.h" -#include "SimpleUrlParser.h" #include "qpid/messaging/exceptions.h" #include "qpid/messaging/Session.h" #include "qpid/messaging/PrivateImplRef.h" @@ -273,14 +272,10 @@ bool ConnectionImpl::tryConnect() for (std::vector<std::string>::const_iterator i = urls.begin(); i != urls.end(); ++i) { try { QPID_LOG(info, "Trying to connect to " << *i << "..."); - //TODO: when url support is more complete can avoid this test here - if (i->find("amqp:") == 0) { - Url url(*i); - connection.open(url, settings); - } else { - SimpleUrlParser::parse(*i, settings); - connection.open(settings); - } + Url url(*i); + if (url.getUser().size()) settings.username = url.getUser(); + if (url.getPass().size()) settings.password = url.getPass(); + connection.open(url, settings); QPID_LOG(info, "Connected to " << *i); mergeUrls(connection.getInitialBrokers(), l); return resetSessions(l); diff --git a/cpp/src/qpid/client/amqp0_10/SimpleUrlParser.cpp b/cpp/src/qpid/client/amqp0_10/SimpleUrlParser.cpp deleted file mode 100644 index 327c2274a6..0000000000 --- a/cpp/src/qpid/client/amqp0_10/SimpleUrlParser.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "SimpleUrlParser.h" -#include "qpid/client/ConnectionSettings.h" -#include "qpid/Exception.h" -#include <boost/lexical_cast.hpp> - -namespace qpid { -namespace client { -namespace amqp0_10 { - -bool split(const std::string& in, char delim, std::pair<std::string, std::string>& result) -{ - std::string::size_type i = in.find(delim); - if (i != std::string::npos) { - result.first = in.substr(0, i); - if (i+1 < in.size()) { - result.second = in.substr(i+1); - } - return true; - } else { - return false; - } -} - -void parseUsernameAndPassword(const std::string& in, qpid::client::ConnectionSettings& result) -{ - std::pair<std::string, std::string> parts; - if (!split(in, '/', parts)) { - result.username = in; - } else { - result.username = parts.first; - result.password = parts.second; - } -} - -void parseHostAndPort(const std::string& in, qpid::client::ConnectionSettings& result) -{ - std::pair<std::string, std::string> parts; - if (!split(in, ':', parts)) { - result.host = in; - } else { - result.host = parts.first; - if (parts.second.size()) { - result.port = boost::lexical_cast<uint16_t>(parts.second); - } - } -} - -void SimpleUrlParser::parse(const std::string& url, qpid::client::ConnectionSettings& result) -{ - std::pair<std::string, std::string> parts; - if (!split(url, '@', parts)) { - parseHostAndPort(url, result); - } else { - parseUsernameAndPassword(parts.first, result); - parseHostAndPort(parts.second, result); - } -} - -}}} // namespace qpid::client::amqp0_10 diff --git a/cpp/src/qpid/client/amqp0_10/SimpleUrlParser.h b/cpp/src/qpid/client/amqp0_10/SimpleUrlParser.h deleted file mode 100644 index 24f90ca9d6..0000000000 --- a/cpp/src/qpid/client/amqp0_10/SimpleUrlParser.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef QPID_CLIENT_AMQP0_10_SIMPLEURLPARSER_H -#define QPID_CLIENT_AMQP0_10_SIMPLEURLPARSER_H - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include <string> - -namespace qpid { -namespace client { - -struct ConnectionSettings; - -namespace amqp0_10 { - -/** - * Parses a simple url of the form user/password@hostname:port - */ -struct SimpleUrlParser -{ - static void parse(const std::string& url, qpid::client::ConnectionSettings& result); -}; -}}} // namespace qpid::client::amqp0_10 - -#endif /*!QPID_CLIENT_AMQP0_10_SIMPLEURLPARSER_H*/ |