Enable build with iniparser v 3.1
[platform/framework/native/appfw.git] / inc / FBaseResult.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file                FBaseResult.h
19  * @brief               This is the header file for the %Result class.
20  *
21  * This header file contains the declarations of the %Result class.
22  */
23 #ifndef _FBASE_RESULT_H_
24 #define _FBASE_RESULT_H_
25
26 #include <FBaseTypes.h>
27 #include <FBaseErrors.h>
28 #include <stdarg.h>
29
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35
36 #define SetLastResultReturn(r) \
37         SetLastResult(r); \
38         return r;
39
40
41 _OSP_EXPORT_ result GetLastResult(void);
42
43 _OSP_EXPORT_ void SetLastResult(result r);
44
45 _OSP_EXPORT_ void ClearLastResult(void);
46
47 struct ErrorTable
48 {
49         result error;
50         char errorString[50];
51 };
52
53 _OSP_EXPORT_ void RegisterErrorTable(unsigned long package, struct ErrorTable* pErrorTable);
54
55 _OSP_EXPORT_ const char* GetErrorMessage(result value);
56
57 _OSP_EXPORT_ result TransExceptionsExclusiveInternal(result r, result e, int num, ...);
58
59 _OSP_EXPORT_ result TransExceptionsInclusiveInternal(result r, result e, int num, ...);
60
61 #define NUMARGS(...)  (sizeof((result[]){0, ##__VA_ARGS__}) / sizeof(result) - 1)
62
63 /**
64 * This macro returns a translated exception when the checked exception does not correspond to the conditional exceptions.
65 * In contrast, this macro returns a checked exception if it corresponds to the conditional exceptions.
66 *
67 * @since 2.0
68 *
69 * @return                                       The translated exception
70 * @param[in]   r                        The result that is checked
71 * @param[in]   e                        The translated exception
72 * @param[in]   ...                      The list of exceptions that are excluded from the translation process @n
73 *                                                       All the exceptions other than this list are translated into @c e.
74 *
75 *
76 */
77
78 #define TransExceptionsExclusive(r, e, ...)     TransExceptionsExclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
79
80
81 /**
82 * This macro returns a translated exception when the checked exception corresponds to the conditional exceptions.
83 * In contrast, this macro returns a checked exception if it does not correspond to the conditional exceptions.
84 *
85 * @since 2.0
86 *
87 * @return                                       The translated exception
88 * @param[in]   r                        The result that is checked
89 * @param[in]   e                        The translated exception
90 * @param[in]   ...                      The list of exceptions that are included in the translation process @n
91 *                                                       All the exceptions in this list are translated into @c e.
92 *
93 */
94
95 #define TransExceptionsInclusive(r, e, ...)     TransExceptionsInclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
96
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif //_FBASE_RESULT_H_