tizen 2.3.1 release
[framework/api/base-utils.git] / src / include / mobile / utils_i18n_private.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __UTILS_I18N_PRIVATE_H__
18 #define __UTILS_I18N_PRIVATE_H__
19
20 #include <stdbool.h>
21 #include <dlog.h>
22 #include <utils_i18n_types.h>
23 #include <unicode/utypes.h>
24
25 /**
26  * @file utils_i18n_private.h
27  * @version 0.1
28  * @brief utils_i18n_private
29  */
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifdef LOG_TAG
36 #undef LOG_TAG
37 #endif
38 #define LOG_TAG "BASE_UTILS"
39
40 #define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
41
42 #define ret_if(expr) do { \
43     if (expr) { \
44         ERR("(%s)", #expr); \
45         return; \
46     } \
47 } while (0)
48 #define retv_if(expr, val) do { \
49     if (expr) { \
50         ERR("(%s)", #expr); \
51         return (val); \
52     } \
53 } while (0)
54 #define retm_if(expr, fmt, arg...) do { \
55     if (expr) { \
56         ERR(fmt, ##arg); \
57         return; \
58     } \
59 } while (0)
60 #define retvm_if(expr, val, fmt, arg...) do { \
61     if (expr) { \
62         ERR(fmt, ##arg); \
63         return (val); \
64     } \
65 } while (0)
66
67 #define retex_if(expr, val, fmt, arg...) do { \
68       if(expr) { \
69          ERR(fmt, ##arg); \
70          val; \
71          goto CATCH; \
72       } \
73     } while (0);
74
75 #define ERR_MAPPING_REVERSE(BASE_UTILS_ERROR, ICU_ERROR) ICU_ERROR = \
76     (UErrorCode)_i18n_error_mapping_reverse((int)BASE_UTILS_ERROR)
77
78 #define ERR_MAPPING(ICU_ERROR, BASE_UTILS_ERROR) BASE_UTILS_ERROR = \
79     (i18n_error_code_e)_i18n_error_mapping((int)ICU_ERROR)
80
81 int _i18n_error_mapping ( int err );
82 int _i18n_error_mapping_reverse ( int err );
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif  /* __UTILS_I18N_PRIVATE_H__*/