forked from project-jedi/jcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCppExceptions.dtx
201 lines (154 loc) · 5.54 KB
/
CppExceptions.dtx
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
@@JclInstallCppExceptionFilter
Summary
Installs the C++ exception filter.
Description
Calling the function JclInstallCppExceptionFilter() installs
an exception filter which generates wrapper exceptions of
type EJclCppStdException for external C++ exceptions. Returns
true if the installation was successful, false otherwise.
\NOTE: This function requires that JclHookExceptions from
JclHookExcept.pas has been called before. It will fail if
this is not the case; it will not set up the required hooks
implicitly!
@@JclCppExceptionFilterInstalled
Summary
Determines whether the C++ exception filter is installed.
Description
Determines whether the C++ exception filter has been
installed properly by calling JclInstallCppExceptionFilter.
@@JclUninstallCppExceptionFilter
Summary
Removes the C++ exception filter.
Description
Removes the C++ exception filter installed by
JclInstallCppExceptionFilter.
@@JclCppException.pas
Summary
JclCppException.pas contains utilities to handle C++
\exceptions in Delphi.
Description
Calling the function JclInstallCppExceptionFilter() installs
an exception filter which generates wrapper exceptions of
type EJclCppStdException for external C++ exceptions. This is
similar to Delphi's own mechanism of generating wrapper
\objects for unknown external exceptions.
An extensive discussion of the problem of C++ exceptions
leaking into Delphi code, possible workarounds and the
solution presented here can be read in the following article:
<extlink http://www.audacia-software.de/en/bcb/external-exception-eefface.htm>External
Exception EEFFACE</extlink>
See Also
EJclCppException
EJclCppStdException
JclInstallCppExceptionFilter
JclUninstallCppExceptionFilter
JclCppExceptionFilterInstalled
JclCppExceptionFlags
@@EJclCppException.IsCppClass
Summary
\Returns True if the underlying C++ exception object is a
class.
Description
C++ permits to throw exceptions of any type, even scalar
types or raw pointers. This function allows to distinguish
them from exceptions which are C++ classes.
@@EJclCppException.GetCppExceptionObject
Summary
\Returns an untyped pointer to the C++ exception object being
wrapped.
Description
@@EJclCppException.AsCppClass
Summary
(C++ only) Returns a pointer to the underlying exception
\object.
Description
This function is useful to access the original exception
type. Example:
<c>const char* msg = TheException-\>AsCppClass\<std::exception\>
()-\>what ();</c>
Supported in C++Builder XE and higher only.
@@EJclCppException.AsCppClass@AnsiString
Summary
(C++ only) Returns a pointer to the underlying exception
\object.
Description
This function is useful to access the original exception
type. Example:
<c>const char* msg = static_cast\<std::exception*\>
(TheException-\>AsCppClass ("std::exception"))-\>what ();</c>
Users of C++Builder XE or higher releases should consider
using EJclCppException.AsCppClass\<\> instead because it
avoids explicit string literals and type casting.
@@EJclCppException
Summary
Exception wrapper object created for C++ exceptions.
Description
To make them usable in Delphi code, the C++ exceptions are
wrapped into Delphi exceptions, the ECppException class and
the ECppStdException class (the latter one for exception
classes derived from std::exception).
@@EJclCppException.ThrowFile
Summary
\Returns the source file name from which the exception has
been thrown.
Description
This only works if position information is enabled; look up
the "-xp" switch in the <extlink http://docwiki.embarcadero.com/RADStudio/en/C%2B%2B_Compiler>compiler
command line</extlink>.
@@EJclCppException.ThrowLine
Summary
\Returns the source line on which the exception has been
thrown.
Description
This only works if position information is enabled; look up
the "-xp" switch in the <extlink http://docwiki.embarcadero.com/RADStudio/en/C%2B%2B_Compiler>compiler
command line</extlink>.
@@EJclCppException.TypeName
Summary
\Returns the typeid().name() of the C++ exception object
being wrapped.
Description
@@EJclCppStdException
Summary
Exception wrapper object created for C++ exceptions which
inherit from std::exception.
Description
If a C++ exception object derives from std::exception, we
have a common base class which simplifies things a lot. In
this case, the exception filter creates a wrapper object of
type ECppStdException, which itself inherits from
EJclCppException and provides one more property:
EJclCppStdException.StdException.
The exception message generated for objects of this type
propagates the original exception message returned by
std::exception::what().
@@EJclCppStdException.StdException
Summary
\Returns a pointer of type std::exception* which points to
the actual exception object. (Useful in C++ only.)
Description
Use dynamic_cast\<\> to dispatch the pointer provided by this
property.
@@TJclCppExceptionFlags
Summary
Controls the creation of Delphi exception wrapper objects for
C++ exceptions.
Description
The following values are defined:
\* cefPrependCppClassName - specifies whether the name of the
C++ class is to be included in the exception message. For
\example, a std::runtime_error will generate the error
message "[std::runtime_error] \<exception message\>". This
may be helpful for error diagnosis during development, but it
should not be in the final application because users will
find the cryptic prefix irritating. Note that the original
class name can still be retrieved using
EJclCppException.TypeName.
@@JclCppExceptionFlags
Summary
Controls the creation of Delphi exception wrapper objects for
C++ exceptions.
Description
See the description of TJclCppExceptionFlags for a list of
\options.