From commits-return-8832-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Sun Jul 06 21:26:05 2008 Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 34204 invoked from network); 6 Jul 2008 21:26:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jul 2008 21:26:05 -0000 Received: (qmail 58648 invoked by uid 500); 6 Jul 2008 21:26:05 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 58627 invoked by uid 500); 6 Jul 2008 21:26:05 -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 58618 invoked by uid 99); 6 Jul 2008 21:26:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jul 2008 14:26:05 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Jul 2008 21:25:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D4AD623889BB; Sun, 6 Jul 2008 14:25:32 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r674350 - in /activemq/activemq-cpp/trunk/src/main: Makefile.am decaf/internal/net/URIHelper.cpp decaf/internal/net/URIHelper.h Date: Sun, 06 Jul 2008 21:25:32 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080706212532.D4AD623889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Sun Jul 6 14:25:32 2008 New Revision: 674350 URL: http://svn.apache.org/viewvc?rev=674350&view=rev Log: Implementing the URIHelper class to aid the URI class in parsing URIs. Added: activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.h Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?rev=674350&r1=674349&r2=674350&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/Makefile.am (original) +++ activemq/activemq-cpp/trunk/src/main/Makefile.am Sun Jul 6 14:25:32 2008 @@ -94,6 +94,7 @@ decaf/internal/nio/IntArrayBuffer.cpp \ decaf/internal/nio/ShortArrayBuffer.cpp \ decaf/internal/net/URIEncoderDecoder.cpp \ + decaf/internal/net/URIHelper.cpp \ decaf/net/ServerSocket.cpp \ decaf/net/SocketOutputStream.cpp \ decaf/net/BufferedSocket.cpp \ @@ -427,6 +428,7 @@ decaf/internal/nio/IntArrayBuffer.h \ decaf/internal/nio/ShortArrayBuffer.h \ decaf/internal/net/URIEncoderDecoder.h \ + decaf/internal/net/URIHelper.h \ decaf/nio/Buffer.h \ decaf/nio/ByteBuffer.h \ decaf/nio/CharBuffer.h \ Added: 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=674350&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.cpp Sun Jul 6 14:25:32 2008 @@ -0,0 +1,59 @@ +/* + * 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 "URIHelper.h" + +#include +#include + +using namespace decaf; +using namespace decaf::lang; +using namespace decaf::internal; +using namespace decaf::internal::net; + +//////////////////////////////////////////////////////////////////////////////// +URIHelper::URIHelper() { +} + +//////////////////////////////////////////////////////////////////////////////// +bool URIHelper::isValidIP4Word( const std::string& word ) { + + if( word.length() < 1 || word.length() > 3 ) { + return false; + } + + for( std::size_t i = 0; i < word.length(); i++ ) { + + if( !Character::isDigit( word.at( i ) ) ) { + return false; + } + } + + if( Integer::parseInt( word ) > 255 ) { + return false; + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +bool URIHelper::isValidHexChar( char c ) { + + return (c >= '0' && c <= '9') || + (c >= 'A' && c <= 'F') || + (c >= 'a' && c <= 'f'); +} Added: activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.h?rev=674350&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.h (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/internal/net/URIHelper.h Sun Jul 6 14:25:32 2008 @@ -0,0 +1,56 @@ +/* + * 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. + */ + +#ifndef _DECAF_INTERNAL_NET_URIHELPER_H_ +#define _DECAF_INTERNAL_NET_URIHELPER_H_ + +#include + +namespace decaf { +namespace internal { +namespace net { + + /** + * Helper class used by the URI classes in encoding and decoding of URI's. + */ + class URIHelper { + public: + + URIHelper(); + virtual ~URIHelper() {} + + /** + * Check is the string passed contains a Valid IPv4 word, which is + * an integer in the range of 0 to 255. + * @param word - string value to check. + * @return true if the word is a valid IPv4 word. + */ + bool isValidIP4Word( const std::string& word ); + + /** + * Determines if the given char is a valid Hex char. Valid + * chars are A-F (upper or lower case) and 0-9. + * @param c - char to inspect + * @return true if c is a valid hex char. + */ + bool isValidHexChar( char c ); + + }; + +}}} + +#endif /* _DECAF_INTERNAL_NET_URIHELPER_H_ */