]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/scopeguard.h
Restore wxFile docs
[wxWidgets.git] / interface / wx / scopeguard.h
CommitLineData
23324ae1 1/////////////////////////////////////////////////////////////////////////////
7c913512 2// Name: scopeguard.h
e54c96f1 3// Purpose: interface of global functions
7c913512
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
7fa7088e 9/** @ingroup group_funcmacro_misc */
7c913512 10//@{
23324ae1 11/**
7fa7088e 12 This macro ensures that the global @a function with 0, 1, 2 or more
d2a48d5c 13 parameters (up to some implementation-defined limit) is executed on scope
7fa7088e
BP
14 exit, whether due to a normal function return or because an exception has
15 been thrown. A typical example of its usage:
7c913512 16
23324ae1
FM
17 @code
18 void *buf = malloc(size);
7fa7088e 19 wxON_BLOCK_EXIT1(free, buf);
23324ae1 20 @endcode
7c913512 21
23324ae1 22 Please see the original article by Andrei Alexandrescu and Petru Marginean
7fa7088e
BP
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.
7c913512 39
7fa7088e 40 @header{wx/scopeguard.h}
23324ae1 41*/
7fa7088e
BP
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)
23324ae1
FM
45//@}
46
51c679d5
VZ
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
d2a48d5c
VZ
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