2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 * @brief This is the header file for the %Result class.
22 * This header file contains the declaration of the %Result class.
24 #ifndef _FBASE_RESULT_H_
25 #define _FBASE_RESULT_H_
27 #include <FBaseTypes.h>
28 #include <FBaseErrors.h>
37 #define SetLastResultReturn(r) \
42 _OSP_EXPORT_ result GetLastResult(void);
44 _OSP_EXPORT_ void SetLastResult(result r);
46 _OSP_EXPORT_ void ClearLastResult(void);
54 _OSP_EXPORT_ void RegisterErrorTable(unsigned long package, struct ErrorTable* pErrorTable);
56 _OSP_EXPORT_ const char* GetErrorMessage(result value);
58 _OSP_EXPORT_ result TransExceptionsExclusiveInternal(result r, result e, int num,...);
60 _OSP_EXPORT_ result TransExceptionsInclusiveInternal(result r, result e, int num,...);
62 #define NUMARGS(...) (sizeof((result[]){0, ##__VA_ARGS__})/sizeof(result)-1)
65 * This macro returns translated exception when the checked exception doesn't correspond with the conditional exceptions.
66 * In contrast, this macro returns the checked exception if it corresponds with the conditional exceptions.
70 * @return The translated exception
71 * @param[in] r The result that will be checked
72 * @param[in] e The translated exception
73 * @param[in] ... The list of exceptions that will be excluded in translation process @n
74 * All other exceptions than this list will be translated into @c e.
79 #define TransExceptionsExclusive(r, e, ...) TransExceptionsExclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
83 * This macro returns translated exception when the checked exception corresponds with the conditional exceptions.
84 * In contrast, this macro returns the checked exception if it doesn't correspond with the conditional exceptions.
88 * @return The translated exception
89 * @param[in] r The result that will be checked
90 * @param[in] e The translated exception
91 * @param[in] ... The list of exceptions that will be included in translation process @n
92 * All exceptions in this list will be translated into @c e.
96 #define TransExceptionsInclusive(r, e, ...) TransExceptionsInclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
103 #endif //_FBASE_RESULT_H_