b9919b0ff15409fc4e5c54dea8c70ece38fb3c6d
[platform/core/graphics/tizenvg.git] / src / lib / tvgCommon.h
1 /*
2  * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
3
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 #ifndef _TVG_COMMON_H_
23 #define _TVG_COMMON_H_
24
25 #include "config.h"
26 #ifdef THORVG_LOG_ENABLED
27 #include <dlog.h>
28 #endif
29 #include "thorvg.h"
30
31 using namespace std;
32 using namespace tvg;
33
34 //for MSVC Compat
35 #ifdef _MSC_VER
36     #define TVG_UNUSED
37     #define strncasecmp _strnicmp
38     #define strcasecmp _stricmp
39 #else
40     #define TVG_UNUSED __attribute__ ((__unused__))
41 #endif
42
43 // Portable 'fallthrough' attribute
44 #if __has_cpp_attribute(fallthrough)
45     #ifdef _MSC_VER
46         #define TVG_FALLTHROUGH [[fallthrough]];
47     #else
48         #define TVG_FALLTHROUGH __attribute__ ((fallthrough));
49     #endif
50 #else
51     #define TVG_FALLTHROUGH
52 #endif
53
54 #define TVG_LOG_TAG "ThorVG"
55
56 #if defined(_MSC_VER) && defined(__clang__)
57     #define strncpy strncpy_s
58     #define strdup _strdup
59 #endif
60
61 //TVG class identifier values
62 #define TVG_CLASS_ID_UNDEFINED 0
63 #define TVG_CLASS_ID_SHAPE     1
64 #define TVG_CLASS_ID_SCENE     2
65 #define TVG_CLASS_ID_PICTURE   3
66 #define TVG_CLASS_ID_LINEAR    4
67 #define TVG_CLASS_ID_RADIAL    5
68
69 enum class FileType { Tvg = 0, Svg, Raw, Png, Jpg, Unknown };
70
71 #ifdef THORVG_LOG_ENABLED
72     //#define TVGLOG(tag, fmt, ...) fprintf(stdout, tag ": " fmt "\n", ##__VA_ARGS__)  //Log Message for notifying user some useful info
73     //#define TVGERR(tag, fmt, ...) fprintf(stderr, tag ": " fmt "\n", ##__VA_ARGS__)  //Error Message for us to fix it
74
75     //Use dlog system in Tizen
76     #define TVGLOG(tag, fmt, ...)
77     #define TVGERR(tag, fmt, ...) dlog_print(DLOG_ERROR, TVG_LOG_TAG, tag ": " fmt "\n", ##__VA_ARGS__)
78 #else
79     #define TVGERR(...)
80     #define TVGLOG(...)
81 #endif
82
83 uint16_t THORVG_VERSION_NUMBER();
84
85 #endif //_TVG_COMMON_H_