"Fossies" - the Fresh Open Source Software Archive

Member "src/Platform/Finally.h" (10 Oct 2018, 1574 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Finally.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #ifndef TC_HEADER_Platform_Finally
   14 #define TC_HEADER_Platform_Finally
   15 
   16 #include "PlatformBase.h"
   17 
   18 // Execute code when leaving scope
   19 #define finally_do(code) \
   20 struct TC_JOIN(Finally,__LINE__) \
   21 { \
   22     TC_JOIN(~Finally,__LINE__) () { try { code } catch (...) { } } \
   23 } \
   24 TC_UNUSED_VAR \
   25 TC_JOIN(finally,__LINE__)
   26 
   27 // Execute code with argument 'finally_arg' when leaving scope
   28 #define finally_do_arg(argType, arg, code) \
   29 struct TC_JOIN(Finally,__LINE__) \
   30 { \
   31     TC_JOIN(Finally,__LINE__) (argType a) : finally_arg (a) { } \
   32     TC_JOIN(~Finally,__LINE__) () { try { code } catch (...) { } } \
   33     argType finally_arg; \
   34 } \
   35 TC_UNUSED_VAR \
   36 TC_JOIN(finally,__LINE__) (arg)
   37 
   38 #define finally_do_arg2(argType, arg, argType2, arg2, code) \
   39 struct TC_JOIN(Finally,__LINE__) \
   40 { \
   41     TC_JOIN(Finally,__LINE__) (argType a, argType2 a2) : finally_arg (a), finally_arg2 (a2) { } \
   42     TC_JOIN(~Finally,__LINE__) () { try { code } catch (...) { } } \
   43     argType finally_arg; \
   44     argType2 finally_arg2; \
   45 } \
   46 TC_UNUSED_VAR \
   47 TC_JOIN(finally,__LINE__) (arg, arg2)
   48 
   49 
   50 #endif // TC_HEADER_Platform_Finally