Diff of /src/foreign/vigra/error.hxx [da984f] .. [8f0f49]  Maximize  Restore

Switch to side-by-side view

--- a/src/foreign/vigra/error.hxx
+++ b/src/foreign/vigra/error.hxx
@@ -4,19 +4,34 @@
 /*       Cognitive Systems Group, University of Hamburg, Germany        */
 /*                                                                      */
 /*    This file is part of the VIGRA computer vision library.           */
-/*    ( Version 1.2.0, Aug 07 2003 )                                    */
-/*    You may use, modify, and distribute this software according       */
-/*    to the terms stated in the LICENSE file included in               */
-/*    the VIGRA distribution.                                           */
-/*                                                                      */
+/*    ( Version 1.4.0, Dec 21 2005 )                                    */
 /*    The VIGRA Website is                                              */
 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
 /*    Please direct questions, bug reports, and contributions to        */
-/*        koethe@informatik.uni-hamburg.de                              */
-/*                                                                      */
-/*  THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR          */
-/*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED      */
-/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/*        koethe@informatik.uni-hamburg.de          or                  */
+/*        vigra@kogs1.informatik.uni-hamburg.de                         */
+/*                                                                      */
+/*    Permission is hereby granted, free of charge, to any person       */
+/*    obtaining a copy of this software and associated documentation    */
+/*    files (the "Software"), to deal in the Software without           */
+/*    restriction, including without limitation the rights to use,      */
+/*    copy, modify, merge, publish, distribute, sublicense, and/or      */
+/*    sell copies of the Software, and to permit persons to whom the    */
+/*    Software is furnished to do so, subject to the following          */
+/*    conditions:                                                       */
+/*                                                                      */
+/*    The above copyright notice and this permission notice shall be    */
+/*    included in all copies or substantial portions of the             */
+/*    Software.                                                         */
+/*                                                                      */
+/*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
+/*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
+/*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
+/*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
+/*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
+/*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
+/*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
+/*    OTHER DEALINGS IN THE SOFTWARE.                                   */                
 /*                                                                      */
 /************************************************************************/
  
@@ -26,6 +41,7 @@
 
 #include <stdexcept>
 #include <stdio.h>
+#include <string>
 #include "vigra/config.hxx"
           
 /*! \page ErrorReporting Error Reporting
@@ -56,9 +72,15 @@
     The MESSAGE is passed to the exception and can be retrieved via
     the overloaded member function '<TT>exception.what()</TT>'. If the compiler
     flag '<TT>NDEBUG</TT>' is <em>not</em> defined, the file name and line number of 
-    the error are automatically included in the message.
-    
-    The following macro
+    the error are automatically included in the message. The macro
+    
+    \code
+    vigra_assert(PREDICATE, MESSAGE);
+    \endcode
+    
+    is identical to <tt>vigra_precondition()</tt> except that it is completely removed
+    when '<TT>NDEBUG</TT>' is defined. This is useful for test that are only needed during 
+    debugging, such as array index bound checking. The following macro
     
     \code
     vigra_fail(MESSAGE);
@@ -172,6 +194,13 @@
 }
 
 inline
+void throw_invariant_error(bool predicate, std::string message, char const * file, int line)
+{
+    if(!predicate)
+	   throw vigra::InvariantViolation(message.c_str(), file, line); 
+}
+
+inline
 void throw_precondition_error(bool predicate, char const * message, char const * file, int line)
 {
     if(!predicate)
@@ -179,10 +208,24 @@
 }
 
 inline
+void throw_precondition_error(bool predicate, std::string message, char const * file, int line)
+{
+    if(!predicate)
+	   throw vigra::PreconditionViolation(message.c_str(), file, line); 
+}
+
+inline
 void throw_postcondition_error(bool predicate, char const * message, char const * file, int line)
 {
     if(!predicate)
 	   throw vigra::PostconditionViolation(message, file, line); 
+}
+
+inline
+void throw_postcondition_error(bool predicate, std::string message, char const * file, int line)
+{
+    if(!predicate)
+	   throw vigra::PostconditionViolation(message.c_str(), file, line); 
 }
 
 inline
@@ -193,7 +236,17 @@
     throw std::runtime_error(what_); 
 }
 
+inline
+void throw_runtime_error(std::string message, char const * file, int line)
+{
+    char what_[1100];
+    sprintf(what_, "\n%.900s\n(%.100s:%d)\n", message.c_str(), file, line);
+    throw std::runtime_error(what_); 
+}
+
 #define vigra_precondition(PREDICATE, MESSAGE) vigra::throw_precondition_error((PREDICATE), MESSAGE, __FILE__, __LINE__)
+
+#define vigra_assert(PREDICATE, MESSAGE) vigra_precondition(PREDICATE, MESSAGE)
 
 #define vigra_postcondition(PREDICATE, MESSAGE) vigra::throw_postcondition_error((PREDICATE), MESSAGE, __FILE__, __LINE__)
 
@@ -224,7 +277,30 @@
 	   throw vigra::PostconditionViolation(message); 
 }
 
+inline
+void throw_invariant_error(bool predicate, std::string message)
+{
+    if(!predicate)
+	   throw vigra::InvariantViolation(message.c_str()); 
+}
+
+inline
+void throw_precondition_error(bool predicate, std::string message)
+{
+    if(!predicate)
+	   throw vigra::PreconditionViolation(message.c_str()); 
+}
+
+inline
+void throw_postcondition_error(bool predicate, std::string message)
+{
+    if(!predicate)
+	   throw vigra::PostconditionViolation(message.c_str()); 
+}
+
 #define vigra_precondition(PREDICATE, MESSAGE) vigra::throw_precondition_error((PREDICATE), MESSAGE)
+
+#define vigra_assert(PREDICATE, MESSAGE)
 
 #define vigra_postcondition(PREDICATE, MESSAGE) vigra::throw_postcondition_error((PREDICATE), MESSAGE)
 

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks