throwable_type.h

Go to the documentation of this file.
00001 /* libthrowable - a C++ library to ease error handling and debugging
00002  *
00003  * Copyright (C) Matthias Langer 2006 <mlangc@gmx.at>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 #ifndef H_LIBTHROWABLE_THROWABLE_TYPE
00021 #define H_LIBTHROWABLE_THROWABLE_TYPE
00022 #include "throwable.h"
00023 #include "util/util.h"
00024 namespace libthrowable {
00025 
00052 template<class ThrowableT, class TagT>
00053 class ThrowableType : public ThrowableT
00054 {
00055     public:
00056     ThrowableType() throw() 
00057     : ThrowableT(TagT::name(), 
00058             typename ThrowableT::DontManipulateStr()) {}
00059 
00060     explicit ThrowableType(const std::string& msg) throw()
00061     : ThrowableT(TagT::name() + ":\n  message:\n" + util::addIndent(msg, 4), 
00062             typename ThrowableT::DontManipulateStr()) {}
00063 
00064     ThrowableType(const char* filename, int linenumber) throw()
00065     : ThrowableT(ThrowableT::internalStrFromFilenameAndLinenumber(TagT::name(), filename, linenumber), 
00066             typename ThrowableT::DontManipulateStr()) {}
00067 
00068     ThrowableType(const char* filename, int linenumber, const char *function) throw()
00069     : ThrowableT(
00070         ThrowableT::internalStrFromFilenameLinenumberAndFunction(
00071             TagT::name(), filename, linenumber, function),
00072         typename ThrowableT::DontManipulateStr()) {}    
00073 
00074     ThrowableType(const char* filename, int linenumber, const std::string& msg) throw()
00075     : ThrowableT(
00076         ThrowableT::internalStrFromFilenameLinenumberAndMessage(TagT::name(), filename, linenumber, msg), 
00077             typename ThrowableT::DontManipulateStr()) {}
00078 
00079     ThrowableType(const char *filename, int linenumber, const char *function, const std::string& msg) throw()
00080     : ThrowableT(
00081         ThrowableT::internalStrFromFilenameLinenumberFunctionAndMessage(
00082             TagT::name(), filename, linenumber, function, msg),
00083         typename ThrowableT::DontManipulateStr()) {}    
00084 
00085     explicit ThrowableType(const std::exception& cause) throw()
00086     : ThrowableT(ThrowableT::internalStrFromCause(TagT::name(), cause), 
00087         typename ThrowableT::DontManipulateStr()) {}
00088 
00089     ThrowableType(const std::exception& cause, const std::string& msg) throw()
00090     : ThrowableT(ThrowableT::internalStrFromCauseAndMessage(TagT::name(), cause, msg),
00091         typename ThrowableT::DontManipulateStr()) {}    
00092 
00093     ThrowableType(const char *filename, int linenumber, const std::exception& cause) throw()
00094     : ThrowableT(ThrowableT::internalStrFromFilenameLinenumberAndCause(TagT::name(), filename, linenumber, cause), 
00095             typename ThrowableT::DontManipulateStr()) {}
00096 
00097     ThrowableType(const char *filename, int linenumber, const char *function, const std::exception& cause) throw()
00098     : ThrowableT(
00099         ThrowableT::internalStrFromFilenameLinenumberFunctionAndCause(
00100             TagT::name(), filename, linenumber, function, cause),
00101         typename ThrowableT::DontManipulateStr()) {}
00102 
00103     ThrowableType(const char *filename, int linenumber, const char *function,
00104         const std::exception& cause, const std::string& msg) throw()
00105     : ThrowableT(
00106         ThrowableT::internalStrFromFilenameLinenumberFunctionCauseAndMessage(
00107             TagT::name(), filename, linenumber, function, cause, msg),
00108         typename ThrowableT::DontManipulateStr()) {}
00109 
00110     virtual ~ThrowableType() throw() {}
00111 
00112     protected:
00113     ThrowableType(const std::string& msg, const typename ThrowableT::DontManipulateStr& dummy) throw()
00114     : ThrowableT(msg, dummy) {} 
00115 
00116 };
00117 }//namespace
00118 #endif

Generated on Wed Jan 9 18:07:17 2008 for libthrowable by  doxygen 1.5.4  Hosted on  SourceForge.net Logo