Bentley.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 /************************************************************************************/
41 
44 #if !defined (__cplusplus)
45 #error "This file is for C++ compilands only"
46 #endif
47 
48 #if !defined (_WIN32)
49 #error "Windows is the only platform supported"
50 #endif
51 #ifndef BENTLEY_WIN32
52 #define BENTLEY_WIN32
53 #endif
54 
55 #define BENTLEYCONFIG_GRAPHICS_DIRECTX
56 
57 
59 
60  #include "suppress_warnings.h"
61 
62  #define DLLPUBLIC_ATTRIBUTE
63  #define EXPORT_ATTRIBUTE __declspec(dllexport)
64  #define IMPORT_ATTRIBUTE __declspec(dllimport)
65  #define DLLLOCAL_ATTRIBUTE /* For MSVC, a symbol is not visible outside of the DLL unless it is marked as EXPORT_ATTRIBUTE. */
66  #define DLLPUBLIC_ATTRIBUTE /* DLLPUBLIC_ATTRIBUTE is a GCC concept. For MSVC, we let EXPORT_ATTRIBUTE identify the members that must be exported */
67  #define EXPORT_VTABLE_ATTRIBUTE /* This is a GCC concept. In MSVC, it appears that the vtable and typeinfo of a class are always exported if the class contains any exported methods. */
68  #define CDECL_ATTRIBUTE __cdecl
69  #define STDCALL_ATTRIBUTE __stdcall
70  #define ENUM_UNDERLYING_TYPE(T) : T
71 
72  #if (_MSC_VER < 1600) // INTPTR_MIN et al are defined in stdint.h. Microsoft started delivering stdint.h as of VS2010
73  #include <limits.h>
74  #if defined(_M_X64)
75  #define INTPTR_MIN _I64_MIN
76  #define INTPTR_MAX _I64_MAX
77  #define UINTPTR_MAX _UI64_MAX
78  #else /* !_M_X64 */
79  #define INTPTR_MIN _I32_MIN
80  #define INTPTR_MAX _I32_MAX
81  #define UINTPTR_MAX _UI32_MAX
82  #endif
83  #endif
84 
85  #define HAVE_TR1
86  #define STD_TR1 std::tr1
87 
88  // The following is *NOT* equivalent to uintptr_t
89  #if defined(_M_X64)
90  typedef unsigned __int64 ULONG_PTR;
91  #else /* !_M_X64 */
92  typedef __w64 unsigned long ULONG_PTR;
93  #endif // WIN64
94 
95  #define DECLARE_KEY_METHOD
96 
97 
98 #ifdef CREATE_STATIC_LIBRARIES
99  #undef EXPORT_ATTRIBUTE
100  #undef IMPORT_ATTRIBUTE
101  #define EXPORT_ATTRIBUTE
102  #define IMPORT_ATTRIBUTE
103 #endif
104 
105 // Define the standard integer types, plus some Bentley aliases for them
106 
107 // Bentley.r.h includes stdint.h (or does the equivalent).
108 #include "Bentley.r.h"
109 
110 // Define standard macros and types for integer limits
111 #include <limits.h>
112 
113 // We define these alias macros to clarify what symbol to use for a given fixed-size type. For example, if you use Int32, use INT32_MIN/MAX.
114 #ifndef INT32_MAX
115 #define INT32_MAX INT_MAX
116 #endif
117 #ifndef UINT32_MAX
118 #define UINT32_MAX UINT_MAX
119 #endif
120 #ifndef INT64_MAX
121 #define INT64_MAX LLONG_MAX
122 #endif
123 #ifndef UINT64_MAX
124 #define UINT64_MAX ULLONG_MAX
125 #endif
126 #ifndef INT32_MIN
127 #define INT32_MIN INT_MIN
128 #endif
129 #ifndef INT64_MIN
130 #define INT64_MIN LLONG_MIN
131 #endif
132 
133 #define USING_NAMESPACE_BENTLEY using namespace BENTLEY_NAMESPACE_NAME;
134 
135 // Define standard pointer types (P, CP, R, CR) in the current namespace for the specified struct
136 #define DEFINE_POINTER_SUFFIX_TYPEDEFS(_structname_) \
137  struct _structname_; \
138  typedef _structname_* _structname_##P, &_structname_##R; \
139  typedef _structname_ const* _structname_##CP; \
140  typedef _structname_ const& _structname_##CR;
141 
142 // These macros make it easy to put typedefs in the Bentley namespace
143 #define ADD_BENTLEY_TYPEDEFS1(_namespace_,_sourceName_,_name_,structclass) \
144  namespace BENTLEY_NAMESPACE_NAME {\
145  typedef structclass _namespace_ :: _sourceName_* _name_##P, &_name_##R; \
146  typedef structclass _namespace_ :: _sourceName_ const* _name_##CP; \
147  typedef structclass _namespace_ :: _sourceName_ const& _name_##CR; }
148 
149 #define ADD_BENTLEY_TYPEDEFS(_namespace_,_name_) ADD_BENTLEY_TYPEDEFS1(_namespace_,_name_,_name_,struct)
150 #define ADD_BENTLEY_ENUM_TYPEDEF(_namespace_,_name_,_tEnum_) namespace BENTLEY_NAMESPACE_NAME {typedef enum _namespace_ :: _name_ _tEnum_;}
151 #define BENTLEY_TYPEDEF(t,tP) namespace BENTLEY_NAMESPACE_NAME {struct t; typedef struct BENTLEY_NAMESPACE_NAME::t* tP;}
152 #define BENTLEY_TYPEDEFS(_name_) namespace BENTLEY_NAMESPACE_NAME {struct _name_;} ADD_BENTLEY_TYPEDEFS(BENTLEY_NAMESPACE_NAME,_name_)
153 #define BENTLEY_REF_COUNTED_PTR(_sname_) namespace BENTLEY_NAMESPACE_NAME {struct _sname_; typedef RefCountedPtr<_sname_> _sname_##Ptr;}
154 
155 
156 #if !defined (NULL)
157  #define NULL 0
158 #endif
159 
160 #if !defined (NO_BENTLEY_PUBLIC)
161 #define Public
162 #endif
163 
164 #define BEGIN_EXTERN_C extern "C" {
165 #define END_EXTERN_C }
166 #define ALLOW_NULL_OUTPUT(var,out) _t_##var, &var(out?*out:_t_##var)
167 #define DEFINE_T_SUPER(B) private: typedef B T_Super; public:
168 
169 /*---------------------------------------------------------------------------------**/
184 #if !defined (_WINGDI_)
185  #define NOGDI // Do NOT let WinGDI.h define ERROR to 0 !!!!
186 #endif
187 
188 #ifdef TRUE
189  #undef TRUE
190 #endif
191 #ifdef FALSE
192  #undef FALSE
193 #endif
194 #ifdef ERROR
195  #undef ERROR
196 #endif
197 #ifdef SUCCESS
198  #undef SUCCESS
199 #endif
200 
203  {
204  TRUE = 1,
205  FALSE = 0
206  };
207 
209  {
210  SUCCESS = 0,
212  ERROR = 0x8000,
213  BSIERROR = 0x8000,
214  };
215 
217  {
218  Locale = 0,
219  Utf8 = 1
220  };
221 
222 typedef int StatusInt; // zero always means SUCCESS
223 typedef wchar_t WChar; // Note: do not use this type to declare, read, or write a stored string. Strings must be stored as UTF-16 or UTF-8.
224 typedef wchar_t const* WCharCP;
225 typedef wchar_t* WCharP;
226 typedef char const* CharCP;
227 typedef char* CharP;
228 typedef Utf8Char* Utf8P;
229 typedef Utf8Char const* Utf8CP;
230 typedef Utf16Char* Utf16P;
231 typedef Utf16Char const* Utf16CP;
232 
233 typedef void* UserDataP;
234 typedef void const* UserDataCP;
235 typedef void* CallbackArgP;
236 
238 
242 BENTLEY_TYPEDEFS (BeFileName)
245 
246 #if !defined (NO_USING_NAMESPACE_BENTLEY)
248 #endif
249  #define BENTLEYDLL_EXPORT IMPORT_ATTRIBUTE
Contains a UTF-8 encoded string.
Definition: WString.h:275
char * CharP
Definition: Bentley.h:227
uint16_t Utf16Char
Definition: Bentley.r.h:155
Definition: Bentley.h:212
wchar_t * WCharP
Definition: Bentley.h:225
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:30
wchar_t WChar
Definition: Bentley.h:223
Contains common typedefs and #defines to be used by .cpp, .r and .mt source files (Bentley/Bentley...
Utf16Char const * Utf16CP
Definition: Bentley.h:231
BentleyTrueFalse
Definition: Bentley.h:202
wchar_t const * WCharCP
Definition: Bentley.h:224
#define USING_NAMESPACE_BENTLEY
Definition: Bentley.h:133
__w64 unsigned long ULONG_PTR
Definition: Bentley.h:92
#define BEGIN_BENTLEY_NAMESPACE
Definition: Bentley.r.h:24
Definition: Bentley.h:205
Utf8Char * Utf8P
Definition: Bentley.h:228
BentleyStatus
Definition: Bentley.h:208
Utf16Char * Utf16P
Definition: Bentley.h:230
BentleyCharEncoding
Definition: Bentley.h:216
void const * UserDataCP
Definition: Bentley.h:234
Definition: Bentley.h:211
#define BENTLEY_TYPEDEFS(_name_)
Definition: Bentley.h:152
Definition: Bentley.h:204
int StatusInt
Definition: Bentley.h:222
Utf8Char const * Utf8CP
Definition: Bentley.h:229
char const * CharCP
Definition: Bentley.h:226
Definition: Bentley.h:210
#define END_BENTLEY_NAMESPACE
Definition: Bentley.r.h:25
void * CallbackArgP
Definition: Bentley.h:235
void * UserDataP
Definition: Bentley.h:233
Reads and Writes Text Files regardless of whether they are encoded on disk as locale-encoded ASCII...
Definition: BeTextFile.h:67
A string class that has many of the same capabilities as std::string, plus additional functions such ...
Definition: WString.h:51
Definition: Bentley.h:213
char Utf8Char
Definition: Bentley.r.h:156

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