From c4cbebed1e8d08771b75dde15e45e12f086baddc Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 20 Nov 2008 22:33:28 +0000 Subject: Exorcise remains of boost.spirit parser. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@719410 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/Url.cpp | 69 +---------------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/Url.cpp b/qpid/cpp/src/qpid/Url.cpp index d0aa28ab0f..b7d6f76a94 100644 --- a/qpid/cpp/src/qpid/Url.cpp +++ b/qpid/cpp/src/qpid/Url.cpp @@ -22,22 +22,12 @@ #include "qpid/sys/SystemInfo.h" #include "qpid/sys/StrError.h" -#include // NB: must be before boost/spirit headers. -#define BOOST_SPIRIT_THREADSAFE - -#include -#include #include -#include -#include #include -#include -#include -#include +#include -using namespace boost::spirit; using namespace std; using boost::lexical_cast; @@ -192,63 +182,6 @@ class UrlParser { const string UrlParser::LOCALHOST("127.0.0.1"); -// Addition to boost::spirit parsers: accept any character from a -// string. Vastly more compile-time-efficient than long rules of the -// form: ch_p('x') | ch_p('y') |... -// -struct ch_in : public char_parser { - ch_in(const string& chars_) : chars(chars_) {} - bool test(char ch_) const { - return chars.find(ch_) != string::npos; - } - string chars; -}; - -inline ch_in ch_in_p(const string& chars) { - return ch_in(chars); -} - -/** Grammar for AMQP URLs. */ -struct UrlGrammar : public grammar -{ - Url& addr; - - UrlGrammar(Url& addr_) : addr(addr_) {} - - template - struct definition { - TcpAddress tcp; - - definition(const UrlGrammar& self) - { - first = eps_p[clear_a(self.addr)] >> amqp_url; - amqp_url = str_p("amqp:") >> prot_addr_list >> - !(str_p("/") >> !parameters); - prot_addr_list = prot_addr % ','; - prot_addr = tcp_prot_addr; // Extend for TLS etc. - - // TCP addresses - tcp_prot_addr = tcp_id >> tcp_addr[push_back_a(self.addr, tcp)]; - tcp_id = !str_p("tcp:"); - tcp_addr = !(host[assign_a(tcp.host)] >> !(':' >> port)); - - // See http://www.apps.ietf.org/rfc/rfc3986.html#sec-A - // for real host grammar. Shortcut: - port = uint_parser()[assign_a(tcp.port)]; - host = *( unreserved | pct_encoded ); - unreserved = alnum_p | ch_in_p("-._~"); - pct_encoded = "%" >> xdigit_p >> xdigit_p; - parameters = *anychar_p >> end_p; // Ignore, not used yet. - } - - const rule& start() const { return first; } - - rule first, amqp_url, prot_addr_list, prot_addr, - tcp_prot_addr, tcp_id, tcp_addr, host, port, - unreserved, pct_encoded, parameters; - }; -}; - void Url::parse(const char* url) { parseNoThrow(url); if (empty()) -- cgit v1.2.1