Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 85725 invoked from network); 15 Aug 2007 14:25:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Aug 2007 14:25:04 -0000 Received: (qmail 63261 invoked by uid 500); 15 Aug 2007 14:25:02 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 63244 invoked by uid 500); 15 Aug 2007 14:25:02 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 63232 invoked by uid 99); 15 Aug 2007 14:25:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2007 07:25:02 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2007 14:25:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CC9C01A981A; Wed, 15 Aug 2007 07:24:43 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r566185 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net: URI.cpp URISyntaxException.h Date: Wed, 15 Aug 2007 14:24:43 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070815142443.CC9C01A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Wed Aug 15 07:24:42 2007 New Revision: 566185 URL: http://svn.apache.org/viewvc?view=rev&rev=566185 Log: http://issues.apache.org/activemq/browse/AMQCPP-103 Adding start of URI class Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URI.cpp activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URISyntaxException.h Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URI.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URI.cpp?view=diff&rev=566185&r1=566184&r2=566185 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URI.cpp (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URI.cpp Wed Aug 15 07:24:42 2007 @@ -84,9 +84,8 @@ if( scheme != "" && path.length() > 0 && path.at(0) != '/') { throw URISyntaxException( - __FILE__, __LINE__, - "URI::URI - Path string: %s starts with invalid char '/'", - path.c_str() ); + __FILE__, __LINE__, path, + "URI::URI - Path string: %s starts with invalid char '/'" ); } std::string uri = ""; @@ -164,9 +163,8 @@ if( scheme != "" && path.length() > 0 && path.at(0) != '/' ) { throw URISyntaxException( - __FILE__, __LINE__, - "URI::URI - Path String %s must start with a '/'", - path.c_str() ); + __FILE__, __LINE__, path, + "URI::URI - Path String %s must start with a '/'" ); } std::string uri = ""; @@ -207,10 +205,35 @@ if( result != APR_SUCCESS ) { throw URISyntaxException( - __FILE__, __LINE__, - "URI::praseURI - URI String %s invalid.", - uri.c_str() ); + __FILE__, __LINE__, uri, + "URI::praseURI - URI String %s invalid." ); } + + std::cout << "\n"; + std::cout << "Original URI String: " << uri << std::endl; + std::cout << "\n"; + std::cout << "Scheme: " + << ( this->uri.scheme ? this->uri.scheme : "" ) << std::endl; + std::cout << "Host: " + << ( this->uri.hostinfo ? this->uri.hostinfo : "" ) << std::endl; + std::cout << "User: " + << ( this->uri.user ? this->uri.user : "" ) << std::endl; + std::cout << "Passwrod: " + << ( this->uri.password ? this->uri.password : "" ) << std::endl; + std::cout << "Host Name: " + << ( this->uri.hostname ? this->uri.hostname : "" ) << std::endl; + std::cout << "Port Str: " + << ( this->uri.port_str ? this->uri.port_str : "" ) << std::endl; + std::cout << "Path: " + << ( this->uri.path ? this->uri.path : "" ) << std::endl; + std::cout << "Query: " + << ( this->uri.query ? this->uri.query : "" ) << std::endl; + std::cout << "Fragment: " + << ( this->uri.fragment ? this->uri.fragment : "" ) << std::endl; + std::cout << "Port: " << this->uri.port << std::endl; + std::cout << "Is Initialized: " << this->uri.is_initialized << std::endl; + std::cout << "DNS Looked Up: " << this->uri.dns_looked_up << std::endl; + std::cout << "DNS Resolved: " << this->uri.dns_resolved << std::endl; } //////////////////////////////////////////////////////////////////////////////// Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URISyntaxException.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URISyntaxException.h?view=diff&rev=566185&r1=566184&r2=566185 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URISyntaxException.h (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/net/URISyntaxException.h Wed Aug 15 07:24:42 2007 @@ -25,48 +25,92 @@ namespace net{ class DECAF_API URISyntaxException : public lang::Exception { + private: + + std::string reason; + std::string input; + int index; + public: /** * Default Constructor */ - URISyntaxException() throw() {} + URISyntaxException() throw() { + this->reason = ""; + this->input = ""; + this->index = -1; + } /** * Conversion Constructor from some other Exception * @param An exception that should become this type of Exception */ - URISyntaxException( const Exception& ex ) throw() - : Exception() - { + URISyntaxException( const Exception& ex ) throw() : Exception() { + *(Exception*)this = ex; + this->reason = ""; + this->input = ""; + this->index = -1; } /** * Copy Constructor */ - URISyntaxException( const URISyntaxException& ex ) throw() - : Exception() - { + URISyntaxException( const URISyntaxException& ex ) throw() : Exception() { + *(Exception*)this = ex; + this->reason = ex.getReason(); + this->input = ex.getInput(); + this->index = ex.getIndex(); } /** * Constructor - Initializes the file name and line number where - * this message occured. Sets the message to report, using an - * optional list of arguments to parse into the message + * this message occured. Sets the input string that caused the error + * and the reason for the error. * @param file name where exception occurs * @param line number where the exception occurred. - * @param message to report + * @param input uri string + * @param reason string for the failure. * @param list of primitives that are formatted into the message */ URISyntaxException( const char* file, const int lineNumber, - const char* msg, ... ) throw () - : Exception() - { - va_list vargs ; - va_start( vargs, msg ); - buildMessage( msg, vargs ); + const std::string& input, + const std::string& reason ) throw () : Exception() { + + this->reason = reason; + this->input = input; + this->index = -1; + + const char * message = "Input: %s, Reason it failed: %s"; + this->setMessage( message, input.c_str(), reason.c_str() ); + + // Set the first mark for this exception. + setMark( file, lineNumber ); + } + + /** + * Constructor - Initializes the file name and line number where + * this message occured. Sets the input string that caused the error + * and the reason for the error. + * @param file name where exception occurs + * @param line number where the exception occurred. + * @param input uri string + * @param reason string for the failure. + * @param index in the uri string where the error occured. + */ + URISyntaxException( const char* file, const int lineNumber, + const std::string& input, + const std::string& reason, + int index ) throw () : Exception() { + + this->reason = reason; + this->input = input; + this->index = index; + + const char * message = "Input: %s, Index %d resulted in this error: %s"; + this->setMessage( message, input.c_str(), index, reason.c_str() ); // Set the first mark for this exception. setMark( file, lineNumber ); @@ -85,6 +129,27 @@ * Destructor */ virtual ~URISyntaxException() throw() {} + + /** + * @returns the Input string that cause this exception or "" + */ + std::string getInput() const { + return input; + } + + /** + * @returns the Reason given for this failure, or "" + */ + std::string getReason() const { + return reason; + } + + /** + * @returns the index in the input string where the error occured or -1 + */ + int getIndex() const { + return index; + } };