activemq-cpp-3.3.0

src/main/decaf/net/URISyntaxException.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_NET_URISYNTAXEXCEPTION_H_
00019 #define _DECAF_NET_URISYNTAXEXCEPTION_H_
00020 
00021 #include <decaf/util/Config.h>
00022 #include <decaf/lang/Exception.h>
00023 
00024 namespace decaf{
00025 namespace net{
00026 
00027     class DECAF_API URISyntaxException : public lang::Exception {
00028     private:
00029 
00030         std::string reason;
00031         std::string input;
00032         int index;
00033 
00034     public:
00035 
00039         URISyntaxException() throw() : decaf::lang::Exception(), reason(), input(), index( -1 ) {
00040         }
00041 
00046         URISyntaxException( const Exception& ex ) throw() : Exception(), reason(), input(), index( -1 ) {
00047             *(Exception*)this = ex;
00048         }
00049 
00054         URISyntaxException( const URISyntaxException& ex ) throw()
00055             : Exception(), reason( ex.getReason() ), input( ex.getInput() ), index( ex.getIndex() ) {
00056 
00057             *(Exception*)this = ex;
00058         }
00059 
00070         URISyntaxException( const char* file, const int lineNumber,
00071                             const std::exception* cause,
00072                             const char* msg, ... )
00073         throw() : lang::Exception( cause ), reason(), input(), index( -1 )
00074         {
00075             va_list vargs;
00076             va_start( vargs, msg );
00077             buildMessage( msg, vargs );
00078 
00079             // Set the first mark for this exception.
00080             setMark( file, lineNumber );
00081         }
00082 
00088         URISyntaxException( const std::exception* cause )
00089             throw() : lang::Exception( cause ), reason(), input(), index( -1 ) {}
00090 
00100         URISyntaxException( const char* file, const int lineNumber,
00101                             const char* msg DECAF_UNUSED ) throw ()
00102         : Exception(), reason( "<Unknown Reason>" ), input( "<No Address Given>" ), index( -1 )
00103         {
00104             const char * message = "Input: %s, Reason it failed: %s";
00105             this->setMessage( message, input.c_str(), reason.c_str() );
00106 
00107             // Set the first mark for this exception.
00108             setMark( file, lineNumber );
00109         }
00110 
00121         URISyntaxException( const char* file, const int lineNumber,
00122                             const std::string& input,
00123                             const std::string& reason ) throw ()
00124         : Exception(), reason( reason ), input( input ), index( -1 ) {
00125 
00126             const char * message = "Input: %s, Reason it failed: %s";
00127             this->setMessage( message, input.c_str(), reason.c_str() );
00128 
00129             // Set the first mark for this exception.
00130             setMark( file, lineNumber );
00131         }
00132 
00144         URISyntaxException( const char* file, const int lineNumber,
00145                             const std::string& input,
00146                             const std::string& reason,
00147                             int index ) throw ()
00148         : Exception(), reason( reason ), input( input ), index( index ) {
00149 
00150             const char * message = "Input: %s, Index %d resulted in this error: %s";
00151             this->setMessage( message, input.c_str(), index, reason.c_str() );
00152 
00153             // Set the first mark for this exception.
00154             setMark( file, lineNumber );
00155         }
00156 
00164         virtual URISyntaxException* clone() const {
00165             return new URISyntaxException( *this );
00166         }
00167 
00168         virtual ~URISyntaxException() throw() {}
00169 
00173         std::string getInput() const {
00174             return input;
00175         }
00176 
00180         std::string getReason() const {
00181             return reason;
00182         }
00183 
00187         int getIndex() const {
00188             return index;
00189         }
00190 
00191     };
00192 
00193 }}
00194 
00195 #endif /*_DECAF_NET_URISYNTAXEXCEPTION_H_*/