Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

exceptions.hpp

Go to the documentation of this file.
00001 /*
00002 This header defines all of the exception classes for the commandl package.
00003     
00004     Copyright (C) 2002 Ross A. Beyer
00005 
00006         Contact Author: Ross A. Beyer, rbeyer@rossbeyer.net
00007 
00008     CVS $Id: exceptions.hpp,v 1.3 2003/03/03 00:52:30 rbeyer Exp $
00009 
00010 
00011   License & Copyright Information
00012   -------------------------------
00013 
00014     This file is part of the commandl package, 
00015     $Name: commandl_Beta-1 $.
00016 
00017     The commandl packge is free software; you can redistribute it
00018     and/or modify it under the terms of the GNU General Public License
00019     as published by the Free Software Foundation; either version 2 of the 
00020     License, or (at your option) any later version.
00021 
00022     The commandl package is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025     GNU General Public License for more details.
00026 
00027     You should have received a copy of the GNU General Public License
00028     along with this program; if not, write to the Free Software
00029     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030 
00031 */
00032 
00033 #ifndef EXCEPTIONS_HEADER   // Begin the Header Guard to prevent
00034 #define EXCEPTIONS_HEADER   //  multiple inclusions.
00035 
00036 #include <exception>
00037 #include <string>
00038 #include <vector>
00039 
00040 namespace commandl
00041 {
00042 class argument; // forward declaration
00043 
00044 /*
00045     \brief This is the base exception class for the commandl library.
00046 */
00047 class exception : public std::exception
00048 {
00049 
00050 // ==================== Constructors & Destructor ===================== //
00051 public:
00052 
00053 
00054     exception( const std::string& what_message )
00055         : What( what_message )
00056         { }
00057 
00058     virtual ~exception() throw()
00059         { }
00060 
00061 // =========================== Accessors ============================== //
00062 public:
00063 
00064     virtual const char* what() const throw() { return What.c_str(); }
00065 
00066 
00067 // =========================== Member Variables ======================= //
00068 protected:
00069 
00071     std::string What;
00072 
00073 }; // End of the class declaration
00074 
00075 
00076 
00080 class argument_exception : public exception
00081 {
00082 
00083 // ==================== Constructors & Destructor ===================== //
00084 public:
00085 
00086     /*
00087     argument_exception( const std::string& what_message )i
00088         : commandl::exception( what_message )
00089         { }
00090     */
00091 
00092     argument_exception  (
00093                         const   std::string&                what_message,
00094                                 commandl::argument*         argument
00095                         )
00096         :   commandl::exception(    what_message    ),
00097             Arg_ptr(                argument        )
00098         { }
00099 
00100     argument_exception  (
00101                         const   std::string&                what_message,
00102                                 commandl::argument*         argument,
00103                         const   std::string&                prefix,
00104                         const   std::string&                key
00105                         )
00106         :   commandl::exception(    what_message    ),
00107             Arg_ptr(                argument        ),
00108             Prefix(                 prefix          ),
00109             Key(                    key             )
00110         { }
00111 
00112     argument_exception  (
00113                         const   std::string&                what_message,
00114                                 commandl::argument*         argument,
00115                         const   std::string&                prefix,
00116                         const   std::string&                key,
00117                         const   std::string&                assign,
00118                         const   std::string&                value
00119                         )
00120         :   commandl::exception(    what_message    ),
00121             Arg_ptr(                argument        ),
00122             Prefix(                 prefix          ),
00123             Key(                    key             ),
00124             Assign(                 assign          )
00125         {
00126         Values.push_back( value );
00127         }
00128 
00129     argument_exception  (
00130                         const   std::string&                what_message,
00131                                 commandl::argument*         argument,
00132                         const   std::string&                prefix,
00133                         const   std::string&                key,
00134                         const   std::string&                assign,
00135                         const   std::vector<std::string>&   values
00136                         )
00137         :   commandl::exception(    what_message    ),
00138             Arg_ptr(                argument        ),
00139             Prefix(                 prefix          ),
00140             Key(                    key             ),
00141             Assign(                 assign          ),
00142             Values(                 values          )
00143         { }
00144 
00145     virtual ~argument_exception() throw()
00146         { }
00147 
00148 // =========================== Accessors ============================== //
00149 public:
00150 
00151     virtual argument*                   arg_ptr()   const { return Arg_ptr; }
00152     virtual std::string                 prefix()    const { return Prefix;  }
00153     virtual std::string                 key()       const { return Key;     }
00154     virtual std::string                 assign()    const { return Assign;  }
00155     virtual std::vector<std::string>    values()    const { return Values;  }
00156 
00157 
00158 // =========================== Methods ================================ //
00159 public:
00160 
00161 
00162 // --------------------------- Protected Methods ---------------------- //
00163 protected:
00164 
00165 
00166 // --------------------------- Private Methods ------------------------ //
00167 private:
00168     
00169 
00170 // =========================== Member Variables ======================= //
00171 protected:
00172 
00174     commandl::argument* Arg_ptr;
00175 
00177     std::string                 Prefix; 
00178 
00180     std::string                 Key;
00181 
00183     std::string                 Assign;
00184 
00186     std::vector<std::string>    Values;
00187 
00188 }; // End of the class declaration
00189 
00190 
00191 
00195 class matcher_exception : public exception
00196 {
00197 
00198 // ==================== Constructors & Destructor ===================== //
00199 public:
00200 
00204     matcher_exception( const std::string& what_message )
00205         : commandl::exception( what_message )
00206         { }
00207 
00215     matcher_exception   (
00216                         const std::string& what_message,
00217                         const std::string& key
00218                         )
00219         :   commandl::exception(    what_message    ),
00220             Key(                    key             )
00221         { }
00222 
00223     virtual ~matcher_exception() throw()
00224         { }
00225 
00226 // =========================== Accessors ============================== //
00227 public:
00228 
00229     virtual std::string key() const { return Key; }
00230 
00231 
00232 // =========================== Methods ================================ //
00233 public:
00234 
00235 
00236 // --------------------------- Protected Methods ---------------------- //
00237 protected:
00238 
00239 
00240 // --------------------------- Private Methods ------------------------ //
00241 private:
00242     
00243 
00244 // =========================== Member Variables ======================= //
00245 protected:
00246 
00247     std::string Key; 
00248 
00249 
00250 }; // End of the class declaration
00251 
00252 
00256 class parser_exception : public exception
00257 {
00258 
00259 // ==================== Constructors & Destructor ===================== //
00260 public:
00261 
00262     parser_exception( const std::string& what_message )
00263         : commandl::exception( what_message )
00264         { }
00265 
00266     parser_exception
00267         (
00268         const std::string& what_message,
00269         const std::string& element
00270         )
00271         :   commandl::exception( what_message ),
00272             Element( element )
00273         { }
00274 
00275     virtual ~parser_exception() throw()
00276         { }
00277 
00278 // =========================== Accessors ============================== //
00279 public:
00280 
00281     std::string element() const
00282         {
00283         return Element;
00284         }
00285 
00286 // =========================== Member Variables ======================= //
00287 protected:
00288 
00289     std::string Element;
00290 
00291 }; // End of the class declaration
00292 
00293 
00297 class no_prefix : public parser_exception
00298 {
00299 
00300 // ==================== Constructors & Destructor ===================== //
00301 public:
00302 
00303     no_prefix( const std::string& what_message )
00304         : parser_exception( what_message )
00305         { }
00306 
00307     no_prefix( const std::string& what_message, const std::string& element )
00308         :   parser_exception( what_message, element )
00309         { }
00310 
00311     ~no_prefix() throw()
00312         { }
00313 
00314 
00315 }; // End of the class declaration
00316 
00317 
00321 class stop_parsing: public parser_exception
00322 {
00323 
00324 // ==================== Constructors & Destructor ===================== //
00325 public:
00326 
00327     stop_parsing( const std::string& what_message )
00328         : parser_exception( what_message )
00329         { }
00330 
00331     stop_parsing( const std::string& what_message, const std::string& element )
00332         :   parser_exception( what_message, element )
00333         { }
00334 
00335     ~stop_parsing() throw()
00336         { }
00337 
00338 }; // End of the class declaration
00339 
00340 
00345 class usage_exception: public parser_exception
00346 {
00347 
00348 // ==================== Constructors & Destructor ===================== //
00349 public:
00350 
00351     usage_exception( const std::string& what_message )
00352         : parser_exception( what_message )
00353         { }
00354 
00355     usage_exception
00356         (
00357         const std::string& what_message,
00358         const std::string& element
00359         )
00360         : parser_exception( what_message, element )
00361         { }
00362 
00363     ~usage_exception() throw()
00364         { }
00365 
00366 }; // End of the class declaration
00367 
00368 
00369 
00373 class no_key: public parser_exception
00374 {
00375 
00376 // ==================== Constructors & Destructor ===================== //
00377 public:
00378 
00379     no_key( const std::string& what_message )
00380         : parser_exception( what_message )
00381         { }
00382 
00383     no_key( const std::string& what_message, const std::string& element )
00384         :   parser_exception( what_message, element )
00385         { }
00386 
00387     ~no_key() throw()
00388         { }
00389 
00390 
00391 }; // End of the class declaration
00392 
00393 
00394 } // End of namespace declaration
00395 
00396 #endif  // End the Header Guard
00397 

Generated on Sat Apr 5 21:17:27 2003 for commandl Library by doxygen1.2.15