Modify Scanner class
[platform/framework/native/appfw.git] / inc / FBaseResult.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                FBaseResult.h
20  * @brief               This is the header file for the %Result class.
21  *
22  * This header file contains the declaration of the %Result class.
23  */
24 #ifndef _FBASE_RESULT_H_
25 #define _FBASE_RESULT_H_
26
27 #include <FBaseTypes.h>
28 #include <FBaseErrors.h>
29 #include <stdarg.h>
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 #define SetLastResultReturn(r) \
38         SetLastResult(r); \
39         return r;
40
41
42 _OSP_EXPORT_ result GetLastResult(void);
43
44 _OSP_EXPORT_ void SetLastResult(result r);
45
46 _OSP_EXPORT_ void ClearLastResult(void);
47
48 struct ErrorTable
49 {
50         result error;
51         char errorString[50];
52 };
53
54 _OSP_EXPORT_ void RegisterErrorTable(unsigned long package, struct ErrorTable* pErrorTable);
55
56 _OSP_EXPORT_ const char* GetErrorMessage(result value);
57
58 _OSP_EXPORT_ result TransExceptionsExclusiveInternal(result r, result e, int num,...);
59
60 _OSP_EXPORT_ result TransExceptionsInclusiveInternal(result r, result e, int num,...);
61
62 #define NUMARGS(...)  (sizeof((result[]){0, ##__VA_ARGS__})/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_