Bentley.r.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
11 
12 #if defined (mdl_resource_compiler) || defined (mdl_type_resource_generator)
13 
14  #define BEGIN_BENTLEY_NAMESPACE
15  #define END_BENTLEY_NAMESPACE
16  #define BEGIN_BENTLEY_GEOMETRY_NAMESPACE
17  #define END_BENTLEY_GEOMETRY_NAMESPACE
18  #define ALIGNMENT_ATTRIBUTE(B)
19  #define ENUM_UNDERLYING_TYPE(T)
20 #else
21 
23  #define BENTLEY_NAMESPACE_NAME Bentley
24  #define BEGIN_BENTLEY_NAMESPACE namespace BENTLEY_NAMESPACE_NAME {
25  #define END_BENTLEY_NAMESPACE }
26 
27  // BENTLEY_GEOMETRY_NAMESPACE may be the same or different as Bentley on various platforms
28  #define BENTLEY_GEOMETRY_NAMESPACE_NAME Bentley
29  #define BEGIN_BENTLEY_GEOMETRY_NAMESPACE BEGIN_BENTLEY_NAMESPACE
30  #define END_BENTLEY_GEOMETRY_NAMESPACE END_BENTLEY_NAMESPACE
31 
32  // use unnamed namespace instead of static in C++ source files.
33  #define BEGIN_UNNAMED_NAMESPACE namespace {
34  #define END_UNNAMED_NAMESPACE }
35 
36 #endif // (mdl_resource_compiler) || defined (mdl_type_resource_generator)
37 
40 
41 #if !defined (NO_BENTLEY_STDINT_TYPEDEDFS)
42 
43  // Use standard integer types
44  #if defined (mdl_resource_compiler) || defined (mdl_type_resource_generator)
45  // We must define the types for use by the resource compiler
46  #elif defined (_WIN32)
47  #if (_MSC_VER >= 1600)
48  // Microsoft started delivering stdint.h as of VS2010
49  #define HAVE_STDINT
50  // Microsoft started delivering inttypes.h as of VS2012
51  #if (_MSC_VER >= 1800)
52  #define HAVE_INTTYPES
53  #endif
54  #if (_MSC_VER == 1600)
55  // Without this definition of INT64_MAX etc. generate an error if intsafe.h was previously included.
56  // See http://connect.microsoft.com/VisualStudio/feedback/details/621653/including-stdint-after-intsafe-generates-warnings#
57  #undef INT8_MIN
58  #undef INT16_MIN
59  #undef INT32_MIN
60  #undef INT8_MAX
61  #undef INT16_MAX
62  #undef INT32_MAX
63  #undef UINT8_MAX
64  #undef UINT16_MAX
65  #undef UINT32_MAX
66  #undef INT64_MIN
67  #undef INT64_MAX
68  #undef UINT64_MAX
69  #endif
70  #endif
71  // WIP_ALIGN - in x86 build, we can't pass an aligned type by value to a function -- causes error C2718: 'const T_Adouble': actual parameter with __declspec(align('8')) won't be aligned
72  //#if !defined (_MANAGED)
73  // #define ALIGNMENT_ATTRIBUTE(B) __declspec(align(B))
74  //#else
75  #define ALIGNMENT_ATTRIBUTE(B)
76  //#endif
77  #elif defined (__unix__)
78  #define ALIGNMENT_ATTRIBUTE(B) __attribute__((aligned(B)))
79  // GCC always delivers stdint.h.
80  #define HAVE_STDINT
81  #else
82  #error unknown compiler
83  #endif
84 
85  #ifdef HAVE_STDINT
86  #include <stdint.h>
87  #else
88  typedef char int8_t;
89  typedef unsigned char uint8_t;
90  typedef short int16_t;
91  typedef unsigned short uint16_t;
92  typedef int int32_t;
93  typedef unsigned int uint32_t;
94  typedef long long int64_t;
95  typedef unsigned long long uint64_t;
96  #endif
97 
98  // Toolsets that don't have inttypes.h are of limited use anyway, so don't bother replicating inttypes.h here for them.
99  #ifdef HAVE_INTTYPES
100  #if defined (ANDROID)
101  // This define is only required on Android/GCC to get platform-independent printf macros such as PRI64d.
102  #define __STDC_FORMAT_MACROS
103  #endif
104  #include <inttypes.h>
105  #endif
106 
107 #endif // NO_BENTLEY_STDINT_TYPEDEDFS
108 
109 // ***
110 // *** Legacy aliases. These aliases predate stdint.h.
111 // ***
112 #if !defined (NO_BENTLEY_BASICTYPES)
113 
114  // NB: Do not #define these names, as they are used by .NET.
115  typedef int8_t Int8;
116  typedef uint8_t UInt8;
117  typedef int16_t Int16;
118  typedef uint16_t UInt16;
119  typedef int32_t Int32;
120 #if defined (__APPLE__)
121  // see MacTypes.h for conflicting definition of UInt32
122  #if defined (__LP64__)
123  typedef unsigned int UInt32;
124  #else
125  typedef unsigned long UInt32;
126  #endif
127 #else
128  typedef uint32_t UInt32;
129 #endif
130  typedef int64_t Int64;
131  typedef uint64_t UInt64;
132 
133  typedef unsigned short UShort;
134  typedef unsigned long ULong;
135  typedef short Short;
136 #if defined (__APPLE__) && !defined (__LP64__)
137  // force UInt and UInt32 types to match
138  typedef UInt32 UInt;
139 #else
140  typedef unsigned int UInt;
141 #endif
142  typedef unsigned char UChar;
143  typedef unsigned char Byte;
144  typedef unsigned char byte;
145  typedef long Long32;
146  typedef unsigned long ULong32;
147 
148 #endif // !defined (NO_BENTLEY_BASICTYPES)
149 
152 
153 // NB: Do not use WChar/wchar_t to declare stored data.
154 // Store strings as UTF-16 or UTF-8.
156 typedef char Utf8Char;
157 
158 typedef ALIGNMENT_ATTRIBUTE(8) double T_Adouble;
159 typedef ALIGNMENT_ATTRIBUTE(8) UInt64 T_AUInt64;
160 typedef ALIGNMENT_ATTRIBUTE(8) Int64 T_AInt64;
161 
162 
163 #if defined (__cplusplus)
164 #define ENUM_IS_FLAGS(ENUMTYPE) \
165 inline ENUMTYPE operator| (ENUMTYPE a, ENUMTYPE b) { return static_cast<ENUMTYPE>(static_cast<std::underlying_type<ENUMTYPE>::type>(a) | static_cast<std::underlying_type<ENUMTYPE>::type>(b)); } \
166 inline ENUMTYPE operator& (ENUMTYPE a, ENUMTYPE b) { return static_cast<ENUMTYPE>(static_cast<std::underlying_type<ENUMTYPE>::type>(a) & static_cast<std::underlying_type<ENUMTYPE>::type>(b)); } \
167 inline ENUMTYPE operator~ (ENUMTYPE a) { return static_cast<ENUMTYPE>(~(static_cast<std::underlying_type<ENUMTYPE>::type>(a))); } \
168 inline bool operator! (ENUMTYPE a) { return 0 == static_cast<std::underlying_type<ENUMTYPE>::type>(a); }
169 #else
170 #define ENUM_IS_FLAGS (ENUMTYPE)
171 #endif
172 
174 
uint16_t Utf16Char
Definition: Bentley.r.h:155
unsigned int UInt
Definition: Bentley.r.h:140
long long int64_t
Definition: Bentley.r.h:94
long Long32
Definition: Bentley.r.h:145
uint16_t UInt16
Definition: Bentley.r.h:118
unsigned long ULong32
Definition: Bentley.r.h:146
uint8_t UInt8
Definition: Bentley.r.h:116
int int32_t
Definition: Bentley.r.h:92
int16_t Int16
Definition: Bentley.r.h:117
short Short
Definition: Bentley.r.h:135
uint32_t UInt32
Definition: Bentley.r.h:128
int8_t Int8
Definition: Bentley.r.h:115
short int16_t
Definition: Bentley.r.h:90
unsigned long long uint64_t
Definition: Bentley.r.h:95
int32_t Int32
Definition: Bentley.r.h:119
unsigned short UShort
Definition: Bentley.r.h:133
unsigned long ULong
Definition: Bentley.r.h:134
unsigned char byte
Definition: Bentley.r.h:144
uint64_t UInt64
Definition: Bentley.r.h:131
unsigned short uint16_t
Definition: Bentley.r.h:91
unsigned char UChar
Definition: Bentley.r.h:142
int64_t Int64
Definition: Bentley.r.h:130
unsigned char Byte
Definition: Bentley.r.h:143
unsigned int uint32_t
Definition: Bentley.r.h:93
char int8_t
Definition: Bentley.r.h:88
typedef ALIGNMENT_ATTRIBUTE(8) double T_Adouble
unsigned char uint8_t
Definition: Bentley.r.h:89
char Utf8Char
Definition: Bentley.r.h:156

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.