JSON Voorhees
Killer JSON for C++
config.hpp
Go to the documentation of this file.
1 /** \file jsonv/config.hpp
2  *
3  * Copyright (c) 2014-2019 by Travis Gockel. All rights reserved.
4  *
5  * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License
6  * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * \author Travis Gockel (travis@gockelhut.com)
10 **/
11 #ifndef __JSONV_CONFIG_HPP_INCLUDED__
12 #define __JSONV_CONFIG_HPP_INCLUDED__
13 
14 /** \def JSONV_USER_CONFIG
15  * \brief A user-defined configuration file to be included before all other JSON Voorhees content.
16 **/
17 #ifdef JSONV_USER_CONFIG
18 # include JSONV_USER_CONFIG
19 #endif
20 
21 #define JSONV_VERSION_MAJOR 1
22 #define JSONV_VERSION_MINOR 4
23 #define JSONV_VERSION_PATCH 0
24 
25 /** \def JSONV_DEBUG
26  * \brief Was JSON Voorhees compiled in debug mode?
27  * This value must be the same between when the SO was built and when you are compiling. In general, this is not useful
28  * outside of library maintainers.
29  *
30  * \warning
31  * Keep in mind this value is \e always defined. Use `#if JSONV_DEBUG`, \e not `#ifdef JSONV_DEBUG`.
32 **/
33 #ifndef JSONV_DEBUG
34 # define JSONV_DEBUG 0
35 #endif
36 
37 /** \def JSONV_SO
38  * \brief Are you using shared objects (DLLs in Windows)?
39 **/
40 #ifndef JSONV_SO
41 # define JSONV_SO 1
42 #endif
43 
44 /** \def JSONV_COMPILING
45  * \brief Is JSON Voorhees currently compiling?
46  * You probably do not want to set this by hand. It is set by the build system when the library is compiled.
47 **/
48 #ifndef JSONV_COMPILING
49 # ifdef jsonv_EXPORTS
50 # define JSONV_COMPILING 1
51 # else
52 # define JSONV_COMPILING 0
53 # endif
54 #endif
55 
56 /** \def JSONV_EXPORT
57  * If using shared objects, this class or function should be exported.
58  *
59  * \def JSONV_IMPORT
60  * If using shared objects, this class or function should be imported.
61  *
62  * \def JSONV_HIDDEN
63  * This symbol is only visible within the same shared object in which the translation unit will end up. Symbols which
64  * are "hidden" will \e not be put into the global offset table, which means code can be more optimal when it involves
65  * hidden symbols at the cost that nothing outside of the SO can access it.
66 **/
67 #if JSONV_SO
68 # if defined(__GNUC__)
69 # define JSONV_EXPORT __attribute__((visibility("default")))
70 # define JSONV_IMPORT
71 # define JSONV_HIDDEN __attribute__((visibility("hidden")))
72 # elif defined(_MSC_VER)
73 # if defined(_LIB)
74 # define JSONV_EXPORT
75 # define JSONV_IMPORT
76 # define JSONV_HIDDEN
77 # else
78 # define JSONV_EXPORT __declspec(dllexport)
79 # define JSONV_IMPORT __declspec(dllimport)
80 # define JSONV_HIDDEN
81 # endif
82 # else
83 # error "Unknown shared object semantics for this compiler."
84 # endif
85 #else
86 # define JSONV_EXPORT
87 # define JSONV_IMPORT
88 # define JSONV_HIDDEN
89 #endif
90 
91 /** \def JSONV_PUBLIC
92  * \brief This function or class is part of the public API for JsonVoorhees.
93  * If you are including JsonVoorhees for another library, this will have import semantics (\c JSONV_IMPORT); if you are
94  * building JsonVoorhees, this will have export semantics (\c JSONV_EXPORT).
95  *
96  * \def JSONV_LOCAL
97  * \brief This function or class is internal-use only.
98  * \see JSONV_HIDDEN
99 **/
100 #if JSONV_COMPILING
101 # define JSONV_PUBLIC JSONV_EXPORT
102 # define JSONV_LOCAL JSONV_HIDDEN
103 #else
104 # define JSONV_PUBLIC JSONV_IMPORT
105 # define JSONV_LOCAL JSONV_HIDDEN
106 #endif
107 
108 /** \def JSONV_UNUSED
109  * \brief Note that you know the variable is unused, but make the compiler stop complaining about it.
110 **/
111 #ifndef JSONV_UNUSED
112 # if defined(__GNUC__)
113 # define JSONV_UNUSED __attribute__((unused))
114 # else
115 # define JSONV_UNUSED
116 # endif
117 #endif
118 
119 /** \def JSONV_NO_RETURN
120  * \brief Mark that a given function will never return control to the caller, either by exiting or throwing an
121  * exception.
122 **/
123 #ifndef JSONV_NO_RETURN
124 # if defined(__GNUC__)
125 # define JSONV_NO_RETURN __attribute__((noreturn))
126 # else
127 # define JSONV_NO_RETURN
128 # endif
129 #endif
130 
131 /** \def JSONV_ALWAYS_INLINE
132  * \brief Always inline the function this decorates, no matter what the compiler might think is best.
133 **/
134 #ifndef JSONV_ALWAYS_INLINE
135 # if defined(__GNUC__)
136 # define JSONV_ALWAYS_INLINE __attribute__((always_inline))
137 # else
138 # define JSONV_ALWAYS_INLINE
139 # endif
140 #endif
141 
142 /** \def JSONV_INTEGER_ALTERNATES_LIST
143  * \brief An item list of types to also consider as an integer.
144  * This mostly exists to help resolve the C-induced type ambiguity for the literal \c 0. It most prefers to be an
145  * \c int, but might also become a \c long or a pointer type.
146 **/
147 #ifndef JSONV_INTEGER_ALTERNATES_LIST
148 # define JSONV_INTEGER_ALTERNATES_LIST(item) \
149  item(int) \
150  item(unsigned int) \
151  item(unsigned long) \
152  item(unsigned long long)
153 #endif
154 
155 /** \def JSONV_COMPILER_SUPPORTS_TEMPLATE_TEMPLATES
156  * Does the compiler properly support template templates? Most compilers do, MSVC does not.
157 **/
158 #ifndef JSONV_COMPILER_SUPPORTS_TEMPLATE_TEMPLATES
159 # ifdef _MSC_VER
160 # define JSONV_COMPILER_SUPPORTS_TEMPLATE_TEMPLATES 0
161 # else
162 # define JSONV_COMPILER_SUPPORTS_TEMPLATE_TEMPLATES 1
163 # endif
164 #endif
165 
166 #endif/*__JSONV_CONFIG_HPP_INCLUDED__*/