2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
19 * @brief This is the header file for the %Result class.
21 * This header file contains the declaration of the %Result class.
23 #ifndef _FBASE_RESULT_H_
24 #define _FBASE_RESULT_H_
26 #include <FBaseTypes.h>
27 #include <FBaseErrors.h>
36 #define SetLastResultReturn(r) \
41 _OSP_EXPORT_ result GetLastResult(void);
43 _OSP_EXPORT_ void SetLastResult(result r);
45 _OSP_EXPORT_ void ClearLastResult(void);
53 _OSP_EXPORT_ void RegisterErrorTable(unsigned long package, struct ErrorTable* pErrorTable);
55 _OSP_EXPORT_ const char* GetErrorMessage(result value);
57 _OSP_EXPORT_ result TransExceptionsExclusiveInternal(result r, result e, int num, ...);
59 _OSP_EXPORT_ result TransExceptionsInclusiveInternal(result r, result e, int num, ...);
61 #define NUMARGS(...) (sizeof((result[]){0, ##__VA_ARGS__}) / sizeof(result) - 1)
64 * This macro returns translated exception when the checked exception doesn't correspond with the conditional exceptions.
65 * In contrast, this macro returns the checked exception if it corresponds with the conditional exceptions.
69 * @return The translated exception
70 * @param[in] r The result that will be checked
71 * @param[in] e The translated exception
72 * @param[in] ... The list of exceptions that will be excluded in translation process @n
73 * All other exceptions than this list will be translated into @c e.
78 #define TransExceptionsExclusive(r, e, ...) TransExceptionsExclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
82 * This macro returns translated exception when the checked exception corresponds with the conditional exceptions.
83 * In contrast, this macro returns the checked exception if it doesn't correspond with the conditional exceptions.
87 * @return The translated exception
88 * @param[in] r The result that will be checked
89 * @param[in] e The translated exception
90 * @param[in] ... The list of exceptions that will be included in translation process @n
91 * All exceptions in this list will be translated into @c e.
95 #define TransExceptionsInclusive(r, e, ...) TransExceptionsInclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
102 #endif //_FBASE_RESULT_H_