Exception.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 ** 
00004 ** Copyright (C) 2006 The TBT Team.
00005 ** 
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 ** 
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 ** 
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef EXCEPTION_HH_
00018 # define EXCEPTION_HH_
00019 
00020 # include <string>
00021 # include <sstream>
00022 
00024 class Exception
00025 {
00026 public:
00027   Exception();
00028   Exception(const std::string& msg);
00029   virtual ~Exception();
00030 
00031   const std::string& what() const;
00032   friend std::ostream& operator<< (std::ostream& os, const Exception& e);
00033   
00034 protected:
00035   std::string msg_;
00036 };
00037 
00038 
00039 inline Exception::Exception()
00040   : msg_("Undefined exception")
00041 {
00042 }
00043 
00044 inline Exception::Exception(const std::string& msg)
00045   : msg_(msg)
00046 {
00047 }
00048 
00049 inline Exception::~Exception()
00050 {
00051 }
00052 
00053 inline const std::string& Exception::what() const
00054 {
00055   return msg_;
00056 }
00057 
00058 inline std::ostream& operator<< (std::ostream& os, const Exception& e)
00059 {
00060   os << e.msg_;
00061   return os;
00062 }
00063 
00064 #endif /* !EXCEPTION_HH_ */

Generated on Sat Jun 23 16:07:23 2007 for Stechec/TBT by  doxygen 1.4.7