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/07/06 23:25:32 UTC
svn commit: r674350 - in /activemq/activemq-cpp/trunk/src/main: Makefile.am
decaf/internal/net/URIHelper.cpp decaf/internal/net/URIHelper.h
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 <decaf/lang/Integer.h>
+#include <decaf/lang/Character.h>
+
+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 <string>
+
+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_ */