activemq-cpp-3.4.0

src/main/decaf/internal/net/URIHelper.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_INTERNAL_NET_URIHELPER_H_
00019 #define _DECAF_INTERNAL_NET_URIHELPER_H_
00020 
00021 #include <string>
00022 #include <decaf/util/Config.h>
00023 #include <decaf/net/URISyntaxException.h>
00024 #include <decaf/internal/net/URIType.h>
00025 
00026 namespace decaf {
00027 namespace internal {
00028 namespace net {
00029 
00033     class DECAF_API URIHelper {
00034     private:
00035 
00036         const std::string unreserved;
00037         const std::string punct;
00038         const std::string reserved;
00039         const std::string someLegal;
00040         const std::string allLegal;
00041 
00042     public:
00043 
00055         URIHelper( const std::string& unreserved,
00056                    const std::string& punct,
00057                    const std::string& reserved,
00058                    const std::string& someLegal,
00059                    const std::string& allLegal );
00060 
00064         URIHelper();
00065 
00066         virtual ~URIHelper() {}
00067 
00075         URIType parseURI( const std::string& uri, bool forceServer );
00076 
00084         void validateScheme( const std::string& uri, const std::string& scheme, int index );
00085 
00093         void validateSsp( const std::string& uri, const std::string& ssp,
00094                           std::size_t index );
00095 
00103         void validateAuthority( const std::string& uri, const std::string& authority,
00104                                 std::size_t index );
00105 
00113         void validatePath( const std::string& uri, const std::string& path,
00114                            std::size_t index );
00115 
00123         void validateQuery( const std::string& uri, const std::string& query,
00124                             std::size_t index );
00125 
00133         void validateFragment( const std::string& uri, const std::string& fragment,
00134                                std::size_t index );
00135 
00153         URIType parseAuthority( bool forceServer, const std::string& authority );
00154 
00163         void validateUserinfo( const std::string& uri, const std::string& userinfo, std::size_t index );
00164 
00173         bool isValidHost( bool forceServer, const std::string& host );
00174 
00181         bool isValidDomainName( const std::string& host );
00182 
00190         bool isValidIPv4Address( const std::string& host );
00191 
00197         bool isValidIP6Address( const std::string& ipAddress );
00198 
00205         bool isValidIP4Word( const std::string& word );
00206 
00213         bool isValidHexChar( char c );
00214 
00215     };
00216 
00217 }}}
00218 
00219 #endif /* _DECAF_INTERNAL_NET_URIHELPER_H_ */