Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Exception.cti
index f0be6aa..ea12370 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 //#include "Exception.ih"
 
 // Custom includes
+#include <boost/lexical_cast.hpp>
 
 #define prefix_ inline
 ///////////////////////////////cti.p///////////////////////////////////////
 
-template <int Code>
-prefix_ senf::ErrnoException<Code>::ErrnoException(std::string const & where)
-    : SystemException(where,fixed_code)
+template <class Exc, class Arg>
+prefix_ typename boost::enable_if< boost::is_convertible<Exc*,senf::ExceptionMixin*>, Exc & >::type
+senf::operator<<(Exc const & exc, Arg const & arg)
+{
+    const_cast<Exc &>(exc).append( boost::lexical_cast<std::string>(arg) );
+    return const_cast<Exc &>(exc);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::WrapExcecption<BaseException>
+
+template <class BaseException>
+prefix_ senf::WrapException<BaseException>::WrapException(BaseException const & base)
+    : ExceptionMixin(base.what()), BaseException(base)
 {}
 
-// I for some reason need to explicitly define this constructor even though it's defined identically
-// to the default version (even though SyntaxException has a custom copy constructor, the
-// non-existent std::stringstream copy constructor will be called otherwise). I believe this is a
-// g++ bug.
-template <int Code>
-prefix_ senf::ErrnoException<Code>::ErrnoException(ErrnoException const & other)
-    : SystemException(other)
+template <class BaseException>
+prefix_ senf::WrapException<BaseException>::~WrapException()
+    throw()
 {}
 
+template <class BaseException>
+prefix_ char const * senf::WrapException<BaseException>::what()
+    const throw()
+{
+    return message().c_str();
+}
+
 /////////////////////////////cti.e///////////////////////////////////////
 #undef prefix_