CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
RoadError.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (c) 2008-2015 C.B. Barber. All rights reserved.
4 ** $Id: //main/2015/qhull/src/libqhullcpp/RoadError.cpp#1 $$Change: 1981 $
5 ** $DateTime: 2015/09/28 20:26:32 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 #
11 
12 #include "RoadError.h"
13 
14 #include <string>
15 #include <sstream>
16 #include <iostream>
17 
18 using std::cerr;
19 using std::cout;
20 using std::string;
21 
22 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
23 #endif
24 
25 namespace orgQhull {
26 
27 #
28 
29 const char * RoadError::
32 ROADtag= "QH";
33 
34 std::ostringstream RoadError::
35 global_log;
36 
37 #
38 
39 RoadError::
40 RoadError()
41 : error_code(0)
42 , log_event()
43 , error_message()
44 { }
45 
46 RoadError::
47 RoadError(const RoadError &other)
48 : error_code(other.error_code)
49 , log_event(other.log_event)
50 , error_message(other.error_message)
51 {
52 }//copy construct
53 
54 RoadError::
55 RoadError(int code, const std::string &message)
56 : error_code(code)
57 , log_event(message.c_str())
58 , error_message(log_event.toString(ROADtag, error_code))
59 {
60  log_event.cstr_1= error_message.c_str(); // overwrites initial value
61 }
62 
63 RoadError::
64 RoadError(int code, const char *fmt)
65 : error_code(code)
66 , log_event(fmt)
67 , error_message()
68 { }
69 
70 RoadError::
71 RoadError(int code, const char *fmt, int d)
72 : error_code(code)
73 , log_event(fmt, d)
74 , error_message()
75 { }
76 
77 RoadError::
78 RoadError(int code, const char *fmt, int d, int d2)
79 : error_code(code)
80 , log_event(fmt, d, d2)
81 , error_message()
82 { }
83 
84 RoadError::
85 RoadError(int code, const char *fmt, int d, int d2, float f)
86 : error_code(code)
87 , log_event(fmt, d, d2, f)
88 , error_message()
89 { }
90 
91 RoadError::
92 RoadError(int code, const char *fmt, int d, int d2, float f, const char *s)
93 : error_code(code)
94 , log_event(fmt, d, d2, f, s)
95 , error_message(log_event.toString(ROADtag, code)) // char * may go out of scope
96 { }
97 
98 RoadError::
99 RoadError(int code, const char *fmt, int d, int d2, float f, const void *x)
100 : error_code(code)
101 , log_event(fmt, d, d2, f, x)
102 , error_message()
103 { }
104 
105 RoadError::
106 RoadError(int code, const char *fmt, int d, int d2, float f, int i)
107 : error_code(code)
108 , log_event(fmt, d, d2, f, i)
109 , error_message()
110 { }
111 
112 RoadError::
113 RoadError(int code, const char *fmt, int d, int d2, float f, long long i)
114 : error_code(code)
115 , log_event(fmt, d, d2, f, i)
116 , error_message()
117 { }
118 
119 RoadError::
120 RoadError(int code, const char *fmt, int d, int d2, float f, double e)
121 : error_code(code)
122 , log_event(fmt, d, d2, f, e)
123 , error_message()
124 { }
125 
126 RoadError & RoadError::
127 operator=(const RoadError &other)
128 {
129  error_code= other.error_code;
130  error_message= other.error_message;
131  log_event= other.log_event;
132  return *this;
133 }//operator=
134 
135 #
136 const char * RoadError::
137 what() const throw()
138 {
139  if(error_message.empty()){
140  error_message= log_event.toString(ROADtag, error_code);
141  }
142  return error_message.c_str();
143 }//what
144 
145 #
146 
147 void RoadError::
151 logErrorLastResort() const
152 {
153  global_log << what() << endl;
154 }//logError
155 
156 
157 }//namespace orgQhull
158 
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:20