RoadError.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (c) 2008-2011 C.B. Barber. All rights reserved.
00004 ** $Id: //main/2011/qhull/src/road/RoadError.cpp#3 $$Change: 1342 $
00005 ** $DateTime: 2011/03/07 21:55:47 $$Author: bbarber $
00006 **
00007 ****************************************************************************/
00008 
00009 #//! RoadError -- All exceptions thrown by Qhull are RoadErrors
00010 #//! Do not throw RoadError's from destructors.  Use e.logError() instead.
00011 
00012 #include "RoadError.h"
00013 
00014 #include <string>
00015 #include <sstream>
00016 #include <iostream>
00017 
00018 using std::cerr;
00019 using std::cout;
00020 using std::string;
00021 
00022 #ifdef _MSC_VER  // Microsoft Visual C++ -- warning level 4
00023 #endif
00024 
00025 namespace orgQhull {
00026 
00027 #//Class fields
00028 
00031 const char * RoadError::
00032 ROADtag= "QH";
00033 
00034 std::ostringstream RoadError::
00035 global_log;
00036 
00037 #//Constructor
00038 
00039 RoadError::
00040 RoadError()
00041 : error_code(0)
00042 , log_event()
00043 , error_message()
00044 { }
00045 
00046 RoadError::
00047 RoadError(const RoadError &other)
00048 : error_code(other.error_code)
00049 , log_event(other.log_event)
00050 , error_message(other.error_message)
00051 {
00052 }//copy construct
00053 
00054 RoadError::
00055 RoadError(int code, const std::string &message)
00056 : error_code(code)
00057 , log_event(message.c_str())
00058 , error_message(log_event.toString(ROADtag, error_code))
00059 {
00060     log_event.cstr_1= error_message.c_str(); // overwrites initial value
00061 }
00062 
00063 RoadError::
00064 RoadError(int code, const char *fmt)
00065 : error_code(code)
00066 , log_event(fmt)
00067 , error_message()
00068 { }
00069 
00070 RoadError::
00071 RoadError(int code, const char *fmt, int d)
00072 : error_code(code)
00073 , log_event(fmt, d)
00074 , error_message()
00075 { }
00076 
00077 RoadError::
00078 RoadError(int code, const char *fmt, int d, int d2)
00079 : error_code(code)
00080 , log_event(fmt, d, d2)
00081 , error_message()
00082 { }
00083 
00084 RoadError::
00085 RoadError(int code, const char *fmt, int d, int d2, float f)
00086 : error_code(code)
00087 , log_event(fmt, d, d2, f)
00088 , error_message()
00089 { }
00090 
00091 RoadError::
00092 RoadError(int code, const char *fmt, int d, int d2, float f, const char *s)
00093 : error_code(code)
00094 , log_event(fmt, d, d2, f, s)
00095 , error_message(log_event.toString(ROADtag, code)) // char * may go out of scope
00096 { }
00097 
00098 RoadError::
00099 RoadError(int code, const char *fmt, int d, int d2, float f, const void *x)
00100 : error_code(code)
00101 , log_event(fmt, d, d2, f, x)
00102 , error_message()
00103 { }
00104 
00105 RoadError::
00106 RoadError(int code, const char *fmt, int d, int d2, float f, int i)
00107 : error_code(code)
00108 , log_event(fmt, d, d2, f, i)
00109 , error_message()
00110 { }
00111 
00112 RoadError::
00113 RoadError(int code, const char *fmt, int d, int d2, float f, long long i)
00114 : error_code(code)
00115 , log_event(fmt, d, d2, f, i)
00116 , error_message()
00117 { }
00118 
00119 RoadError::
00120 RoadError(int code, const char *fmt, int d, int d2, float f, double e)
00121 : error_code(code)
00122 , log_event(fmt, d, d2, f, e)
00123 , error_message()
00124 { }
00125 
00126 RoadError & RoadError::
00127 operator=(const RoadError &other)
00128 {
00129     error_code= other.error_code;
00130     error_message= other.error_message;
00131     log_event= other.log_event;
00132     return *this;
00133 }//operator=
00134 
00135 #//Virtual
00136 const char * RoadError::
00137 what() const throw()
00138 {
00139     if(error_message.empty()){
00140         error_message= log_event.toString(ROADtag, error_code);
00141     }
00142     return error_message.c_str();
00143 }//what
00144 
00145 #//Updates
00146 
00148 void RoadError::
00149 logError() const
00150 {
00151     global_log << what() << endl;
00152 }//logError
00153 
00154 
00155 }//namespace orgQhull
00156 


libqhull-ours
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:11