Merge "[ACR][20/08/2013][Add]Enhance Double::ToString() andFloat::ToString() to set...
[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 declaration 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__}     \
62         ) / sizeof(result) - 1)
63
64 /**
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.
67 *
68 * @since 2.0
69 *
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.
75 *
76 *
77 */
78
79 #define TransExceptionsExclusive(r, e, ...)     TransExceptionsExclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
80
81
82 /**
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.
85 *
86 * @since 2.0
87 *
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.
93 *
94 */
95
96 #define TransExceptionsInclusive(r, e, ...)     TransExceptionsInclusiveInternal(r, e, NUMARGS(__VA_ARGS__), __VA_ARGS__)
97
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif //_FBASE_RESULT_H_