2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : stdcpp_support.h
16 * Part of : standard c++ library.
23 #ifndef _STDCPP_SUPPORT_H_
24 #define _STDCPP_SUPPORT_H_
27 //This is required for the TRAP macro
29 // This is required for the Symbian error numbers
32 /* A utility funtion that takes a SymbianC++ error number and throws a corresponding
33 C++ exception. This mapping is done based on what is mentioned in Chapter 19.1 of
34 the C++ specification and Symbian's e32err.h.
36 IMPORT_C void TranslateSymErrorToCppException(TInt);
39 /* A utility function that takes an instance of std::exception and returns a
40 corresponding SymbianC++ error number. This mapping is done based on what is
41 mentioned in Chapter 19.1 of the C++ specification and Symbian's e32err.h.
43 IMPORT_C TInt TranslateCppExceptionToSymError(const std::exception&);
46 /* Executes the set of C++ statements _s under a trap harness and throws a suitable
47 C++ exception that matches the Symbian error code.
49 Use this macro as a C++ statement to translate a User::Leave
51 _s can consist of multiple C++ statements; in theory, _s can consist
52 of any legal C++ code but in practice, such statements consist of Symbian C++
53 function calls that may leave, e.g. FooL() or an assignment of some value to
54 the result of a function call, e.g. functionValue=GetFooL().
56 #define TRANSLATE_SYM_CPP_LEAVES(_s) \
60 if(err) TranslateSymErrorToCppException(err); \
63 class Symbian_error : public std::exception
66 /* A Symbian specific error can be encapsulated within this object*/
67 Symbian_error(TInt e):error_code(e) {}
69 inline TInt error() { return error_code; }
75 #endif //STDCPP_SUPPORT_H