]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/scopeguard.h
removed automatically generated code for frame layout with human-readable version...
[wxWidgets.git] / interface / wx / scopeguard.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: scopeguard.h
3 // Purpose: interface of global functions
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /** @ingroup group_funcmacro_misc */
10 //@{
11 /**
12 This macro ensures that the global @a function with 0, 1, 2 or more
13 parameters (up to some implementation-defined limit) is executed on scope
14 exit, whether due to a normal function return or because an exception has
15 been thrown. A typical example of its usage:
16
17 @code
18 void *buf = malloc(size);
19 wxON_BLOCK_EXIT1(free, buf);
20 @endcode
21
22 Please see the original article by Andrei Alexandrescu and Petru Marginean
23 published in December 2000 issue of C/C++ Users Journal for more details.
24
25 @see wxON_BLOCK_EXIT_OBJ0()
26
27 @header{wx/scopeguard.h}
28 */
29 #define wxON_BLOCK_EXIT0(function)
30 #define wxON_BLOCK_EXIT1(function, p1)
31 #define wxON_BLOCK_EXIT2(function, p1, p2)
32 //@}
33
34 /** @ingroup group_funcmacro_misc */
35 //@{
36 /**
37 This family of macros is similar to wxON_BLOCK_EXIT0(), but calls a method
38 of the given object instead of a free function.
39
40 @header{wx/scopeguard.h}
41 */
42 #define wxON_BLOCK_EXIT_OBJ0(object, method)
43 #define wxON_BLOCK_EXIT_OBJ1(object, method, p1)
44 #define wxON_BLOCK_EXIT_OBJ2(object, method, p1, p2)
45 //@}
46
47 /** @ingroup group_funcmacro_misc */
48 //@{
49 /**
50 This family of macros is similar to wxON_BLOCK_OBJ0(), but calls a method
51 of @c this object instead of a method of the specified object.
52
53 @header{wx/scopeguard.h}
54 */
55 #define wxON_BLOCK_EXIT_THIS0(method)
56 #define wxON_BLOCK_EXIT_THIS1(method, p1)
57 #define wxON_BLOCK_EXIT_THIS2(method, p1, p2)
58 //@}
59
60 /** @ingroup group_funcmacro_misc */
61 //@{
62 /**
63 This macro sets a variable to the specified value on scope exit.
64
65 Example of usage:
66 @code
67 void foo()
68 {
69 bool isDoingSomething = true;
70 {
71 wxON_BLOCK_EXIT_SET(isDoingSomething, false);
72 ... do something ...
73 }
74 ... isDoingSomething is false now ...
75 }
76 @endcode
77
78 @see wxON_BLOCK_EXIT_OBJ0(), wxON_BLOCK_EXIT_NULL()
79
80 @header{wx/scopeguard.h}
81 */
82 #define wxON_BLOCK_EXIT_SET(var, value)
83
84 /**
85 This macro sets the pointer passed to it as argument to NULL on scope exit.
86
87 It must be used instead of wxON_BLOCK_EXIT_SET() when the value being set
88 is @c NULL.
89
90 @header{wx/scopeguard.h}
91 */
92 #define wxON_BLOCK_EXIT_NULL(ptr)
93
94 //@}
95