-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathopennurbs_error.h
137 lines (118 loc) · 4.9 KB
/
opennurbs_error.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* $NoKeywords: $ */
/*
//
// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
*/
#if !defined(OPENNURBS_ERROR_INC_)
#define OPENNURBS_ERROR_INC_
/*
// Macros used to log errors and warnings. The ON_Warning() and ON_Error()
// functions are defined in opennurbs_error.cpp.
*/
#if defined(__FUNCTION__)
// __FUNCTION__ macro exists
#define ON_ERROR(msg) ON_ErrorEx(__FILE__,__LINE__,__FUNCTION__,msg)
#define ON_WARNING(msg) ON_WarningEx(__FILE__,__LINE__,__FUNCTION__,msg)
#define ON_ASSERT(cond) ON_AssertEx(cond,__FILE__,__LINE__,__FUNCTION__, #cond " is false")
#define ON_ASSERT_OR_RETURN(cond,returncode) do{if (!(cond)) {ON_AssertEx(false,__FILE__,__LINE__,__FUNCTION__, #cond " is false");return(returncode);}}while(0)
#else
// __FUNCTION__ macro does not exist
#define ON_ERROR(msg) ON_Error(__FILE__,__LINE__,msg)
#define ON_WARNING(msg) ON_Warning(__FILE__,__LINE__,msg)
#define ON_ASSERT(cond) ON_Assert(cond,__FILE__,__LINE__, #cond " is false")
#define ON_ASSERT_OR_RETURN(cond,returncode) do{if (!(cond)) {ON_Assert(false,__FILE__,__LINE__, #cond " is false");return(returncode);}}while(0)
#endif
ON_BEGIN_EXTERNC
/*
// All error/warning messages are sent to ON_ErrorMessage(). Replace the
// default handler (defined in opennurbs_error_message.cpp) with something
// that is appropriate for debugging your application.
*/
ON_DECL
void ON_ErrorMessage(
int, /* 0 = warning message, 1 = serious error message, 2 = assert failure */
const char*
);
/*
Returns:
Number of opennurbs errors since program started.
*/
ON_DECL
int ON_GetErrorCount(void);
/*
Returns:
Number of opennurbs warnings since program started.
*/
ON_DECL
int ON_GetWarningCount(void);
/*
Returns:
Number of math library or floating point errors that have
been handled since program started.
*/
ON_DECL
int ON_GetMathErrorCount(void);
ON_DECL
int ON_GetDebugErrorMessage(void);
ON_DECL
void ON_EnableDebugErrorMessage( int bEnableDebugErrorMessage );
ON_DECL
void ON_Error( const char*, /* sFileName: __FILE__ will do fine */
int, /* line number: __LINE__ will do fine */
const char*, /* printf() style format string */
... /* printf() style ags */
);
ON_DECL
void ON_ErrorEx( const char*, // sFileName: __FILE__ will do fine
int, // line number: __LINE__ will do fine
const char*, // sFunctionName: __FUNCTION__ will do fine
const char*, // printf() style format string
... // printf() style ags
);
ON_DECL
void ON_Warning( const char*, /* sFileName: __FILE__ will do fine */
int, /* line number: __LINE__ will do fine */
const char*, /* printf() style format string */
... /* printf() style ags */
);
ON_DECL
void ON_WarningEx( const char*, // sFileName: __FILE__ will do fine
int, // line number: __LINE__ will do fine
const char*, // sFunctionName: __FUNCTION__ will do fine
const char*, // printf() style format string
... // printf() style ags
);
// Ideally - these "assert" functions will be deleted when the SDK can be changed.
ON_DECL
void ON_Assert( int, /* if false, error is flagged */
const char*, /* sFileName: __FILE__ will do fine */
int, /* line number: __LINE__ will do fine */
const char*, /* printf() style format string */
... /* printf() style ags */
);
ON_DECL
void ON_AssertEx( int, // if false, error is flagged
const char*, // sFileName: __FILE__ will do fine
int, // line number: __LINE__ will do fine
const char*, // sFunctionName: __FUNCTION__ will do fine
const char*, // printf() style format string
... // printf() style ags
);
ON_DECL
void ON_MathError(
const char*, /* sModuleName */
const char*, /* sErrorType */
const char* /* sFunctionName */
);
ON_END_EXTERNC
#endif