1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/stlportv5/stdcpp_support.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,76 @@
1.4 +/*
1.5 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Name : stdcpp_support.h
1.19 +* Part of : standard c++ library.
1.20 +*
1.21 +*
1.22 +*/
1.23 +
1.24 +
1.25 +
1.26 +#ifndef _STDCPP_SUPPORT_H_
1.27 +#define _STDCPP_SUPPORT_H_
1.28 +
1.29 +#include <exception>
1.30 +//This is required for the TRAP macro
1.31 +#include <e32cmn.h>
1.32 +// This is required for the Symbian error numbers
1.33 +#include <e32err.h>
1.34 +
1.35 +/* A utility funtion that takes a SymbianC++ error number and throws a corresponding
1.36 +C++ exception. This mapping is done based on what is mentioned in Chapter 19.1 of
1.37 +the C++ specification and Symbian's e32err.h.
1.38 +*/
1.39 +IMPORT_C void TranslateSymErrorToCppException(TInt);
1.40 +
1.41 +
1.42 +/* A utility function that takes an instance of std::exception and returns a
1.43 +corresponding SymbianC++ error number. This mapping is done based on what is
1.44 +mentioned in Chapter 19.1 of the C++ specification and Symbian's e32err.h.
1.45 +*/
1.46 +IMPORT_C TInt TranslateCppExceptionToSymError(const std::exception&);
1.47 +
1.48 +
1.49 +/* Executes the set of C++ statements _s under a trap harness and throws a suitable
1.50 +C++ exception that matches the Symbian error code.
1.51 +
1.52 +Use this macro as a C++ statement to translate a User::Leave
1.53 +
1.54 +_s can consist of multiple C++ statements; in theory, _s can consist
1.55 +of any legal C++ code but in practice, such statements consist of Symbian C++
1.56 +function calls that may leave, e.g. FooL() or an assignment of some value to
1.57 +the result of a function call, e.g. functionValue=GetFooL().
1.58 +*/
1.59 +#define TRANSLATE_SYM_CPP_LEAVES(_s) \
1.60 + { \
1.61 + TInt err; \
1.62 + TRAP(err, _s); \
1.63 + if(err) TranslateSymErrorToCppException(err); \
1.64 + }
1.65 +
1.66 +class Symbian_error : public std::exception
1.67 +{
1.68 +public:
1.69 + /* A Symbian specific error can be encapsulated within this object*/
1.70 + Symbian_error(TInt e):error_code(e) {}
1.71 +
1.72 + inline TInt error() { return error_code; }
1.73 +private:
1.74 + TInt error_code;
1.75 +};
1.76 +
1.77 +
1.78 +#endif //STDCPP_SUPPORT_H
1.79 +