You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/12/20 19:01:41 UTC
svn commit: r728327 - in /activemq/activemq-cpp/trunk/src/main/decaf:
internal/net/URIEncoderDecoder.cpp internal/net/URIHelper.cpp net/URI.cpp
Author: tabish
Date: Sat Dec 20 10:01:41 2008
New Revision: 728327
URL: http://svn.apache.org/viewvc?rev=728327&view=rev
Log:
Partially working URI class, updates for bugs found in testing.
Modified:
activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIEncoderDecoder.cpp
activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp
activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp
Modified: activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIEncoderDecoder.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIEncoderDecoder.cpp?rev=728327&r1=728326&r2=728327&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIEncoderDecoder.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIEncoderDecoder.cpp Sat Dec 20 10:01:41 2008
@@ -111,10 +111,10 @@
char ch = *iter;
if( Character::isLetterOrDigit( ch ) ||
- legal.find( ch ) > std::string::npos ||
+ legal.find( ch ) != std::string::npos ||
( (unsigned char)ch > 127 &&
- !Character::isWhitespace(ch) &&
- !Character::isISOControl(ch) ) ) {
+ ( !Character::isWhitespace(ch) &&
+ !Character::isISOControl(ch) ) ) ) {
buf += ch;
} else {
Modified: activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp?rev=728327&r1=728326&r2=728327&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp Sat Dec 20 10:01:41 2008
@@ -90,7 +90,7 @@
result.setAbsolute( true );
result.setScheme( temp.substr( 0, index ) );
- if( result.getScheme().length() == 0 ) {
+ if( result.getScheme() == "" ) {
throw URISyntaxException(
__FILE__, __LINE__,
uri, "Scheme not specified.", index );
@@ -99,18 +99,19 @@
validateScheme( uri, result.getScheme(), 0 );
result.setSchemeSpecificPart( temp.substr( index + 1, std::string::npos ) );
- if( result.getSchemeSpecificPart().length() == 0 ) {
+ if( result.getSchemeSpecificPart() == "" ) {
throw URISyntaxException(
__FILE__, __LINE__,
uri, "Scheme specific part is invalid..", index + 1 );
}
+
} else {
result.setAbsolute( false );
result.setSchemeSpecificPart( temp );
}
if( result.getScheme() == "" ||
- ( result.getSchemeSpecificPart().length() > 0 &&
+ ( !result.getSchemeSpecificPart().empty() &&
result.getSchemeSpecificPart().at( 0 ) == '/' ) ) {
result.setOpaque( false );
@@ -135,20 +136,16 @@
} else {
result.setAuthority( temp.substr( 2, std::string::npos ) );
- if( result.getAuthority().length() == 0 &&
+ if( result.getAuthority() == "" &&
result.getQuery() == "" && result.getFragment() == "" ) {
throw URISyntaxException(
__FILE__, __LINE__,
uri, "Scheme specific part is invalid..", uri.length() );
}
-
- result.setPath( "" );
- // nothing left, so path is empty (not null, path should
- // never be null)
}
- if( result.getAuthority().length() != 0 ) {
+ if( result.getAuthority() != "" ) {
validateAuthority( uri, result.getAuthority(), index1 + 3 );
}
@@ -175,7 +172,7 @@
URIType authority = parseAuthority( forceServer, result.getAuthority() );
// Authority was valid, so we capture the results
- if( result.isValid() ) {
+ if( authority.isValid() ) {
result.setUserInfo( authority.getUserInfo() );
result.setHost( authority.getHost() );
result.setPort( authority.getPort() );
@@ -303,10 +300,10 @@
hostindex = index + 1;
}
- index = temp.find_last_of( ':' );
+ index = temp.rfind( ':' );
std::size_t endindex = temp.find( ']' );
- if( index != std::string::npos && endindex < index ) {
+ if( index != std::string::npos && ( endindex < index || endindex == std::string::npos ) ){
// determine port and host
tempHost = temp.substr( 0, index );
@@ -325,6 +322,7 @@
return result;
}
+
} catch( NumberFormatException& e ) {
if( forceServer ) {
Modified: activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp?rev=728327&r1=728326&r2=728327&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/net/URI.cpp Sat Dec 20 10:01:41 2008
@@ -86,11 +86,10 @@
if( scheme == "" && userInfo == "" && host == "" &&
path == "" && query == "" && fragment == "" ) {
- this->uri.setPath( "" );
return;
}
- if( scheme != "" && path.length() > 0 && path.at(0) != '/') {
+ if( scheme != "" && !path.empty() && path.at(0) != '/') {
throw URISyntaxException(
__FILE__, __LINE__, path,
@@ -705,7 +704,7 @@
URI newURI = *this;
- if( newURI.uri.isServerAuthority() ) {
+ if( !newURI.uri.isServerAuthority() ) {
newURI.uri = URIHelper().parseAuthority( true, this->uri.getAuthority() );
}