KeePass   KeePass Help Center Home KeePass Home | Package Downloads | Flag Translations | Blocks Plugins | Donate Donate  
Home Help Center Home | People Forums | Award Awards | Link Links | Search Search  







SysDefEx.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2018 Dominik Reichl
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  POSSIBILITY OF SUCH DAMAGE.
28 */
29 
30 #ifndef ___SYS_DEF_EX_H___
31 #define ___SYS_DEF_EX_H___
32 
33 #pragma once
34 
35 // The following types and functions must be implemented for each
36 // supported platform:
37 
38 // Types:
39 // UINT8 -- 8-bit unsigned integer.
40 // UINT16 -- 16-bit unsigned integer.
41 // UINT32 -- 32-bit unsigned integer.
42 // UINT64 -- 64-bit unsigned integer.
43 // INT8 -- 8-bit unsigned integer.
44 // INT16 -- 16-bit unsigned integer.
45 // INT32 -- 32-bit unsigned integer.
46 // INT64 -- 64-bit unsigned integer.
47 
48 // Defines:
49 // CPP_CLASS_SHARE -- Define to a keyword that imports or exports a C++ class.
50 // CPP_FN_SHARE -- Define to a keyword that imports or exports a function
51 // that uses C++ types (class in parameters, STL type).
52 // C_FN_SHARE -- Define to a keyword that imports or exports a function.
53 // KP_EXP -- Define to the opposite of C_FN_SHARE.
54 // KP_API -- Define to a function call type (STDCALL / CDECL).
55 
56 // Include all system-specific definitions
57 #include "SysSpec_Windows/SysSpecWin.h"
58 // #include "SysSpec/SysSpecLinux.h"
59 #if defined _WIN32_WCE
60 #include "wce_wrap.h"
61 #endif
62 
63 // Implications, standard macros and other definitions follow.
64 
65 #ifndef UNREFERENCED_PARAMETER
66 #define UNREFERENCED_PARAMETER(p) (void)0
67 #endif
68 
69 #if (_MSC_VER >= 1600)
70 #include <stdint.h>
71 #else
72 #ifndef UINT32_MAX
73 #define UINT32_MAX 0xFFFFFFFF
74 #endif
75 #ifndef UINT64_MAX
76 #define UINT64_MAX 0xFFFFFFFFFFFFFFFFui64
77 #endif
78 #endif
79 
80 #ifndef DWORD_MAX
81 #define DWORD_MAX 0xFFFFFFFF
82 #endif
83 
84 #ifndef UTF8_BYTE
85 #define UTF8_BYTE BYTE
86 #endif
87 
88 #ifndef ROTL32UE
89 #define ROTL32UE(__uv,__nv) ((((__uv) << (__nv)) | ((__uv) >> (32 - (__nv)))) & 0xFFFFFFFF)
90 #endif
91 
92 // Safely delete pointers
93 #ifndef SAFE_DELETE
94 #define SAFE_DELETE(__kp_p) { if((__kp_p) != NULL) { delete (__kp_p); (__kp_p) = NULL; } }
99 
104 #define SAFE_DELETE_ARRAY(__kp_p) { if((__kp_p) != NULL) { delete [](__kp_p); (__kp_p) = NULL; } }
105 
109 #define SAFE_RELEASE(__kp_p) { if((__kp_p) != NULL) { (__kp_p)->Release(); (__kp_p) = NULL; } }
110 #endif
111 
112 #ifndef KP_DEFINE_GUID
113 #define KP_DEFINE_GUID(__kp_name,__kp_l,__kp_w1,__kp_w2,__kp_b1,__kp_b2,__kp_b3,__kp_b4,__kp_b5,__kp_b6,__kp_b7,__kp_b8) \
114  EXTERN_C const GUID DECLSPEC_SELECTANY __kp_name \
115  = { __kp_l, __kp_w1, __kp_w2, { __kp_b1, __kp_b2, __kp_b3, __kp_b4, \
116  __kp_b5, __kp_b6, __kp_b7, __kp_b8 } }
117 #endif
118 
119 #ifndef KP_DECLSPEC_UUID
120 #if ((_MSC_VER >= 1100) && defined(__cplusplus))
121 #define KP_DECLSPEC_UUID(__kp_uuid) __declspec(uuid(__kp_uuid))
122 #else
123 #define KP_DECLSPEC_UUID(__kp_uuid)
124 #endif
125 #endif
126 
127 #ifndef KP_DECLSPEC_NOVTABLE
128 #if ((_MSC_VER >= 1100) && defined(__cplusplus))
129 #define KP_DECLSPEC_NOVTABLE __declspec(novtable)
130 #else
131 #define KP_DECLSPEC_NOVTABLE
132 #endif
133 #endif
134 
135 #ifndef KP_DECL_INTERFACE
136 #define KP_DECL_INTERFACE(__kp_if_uuid) KP_DECLSPEC_UUID(__kp_if_uuid) KP_DECLSPEC_NOVTABLE
137 #endif
138 
139 #ifndef KP_DECL_IUNKNOWN
140 #define KP_DECL_IUNKNOWN STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject); \
141  STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release()
142 #endif
143 
144 #ifndef KP_DECL_STDREFIMPL
145 #define KP_DECL_STDREFIMPL ULONG __m_uInterfaceRefCount
146 #endif
147 
148 #ifndef KP_IMPL_STDREFIMPL
149 #define KP_IMPL_STDREFIMPL(__kp_class_name) STDMETHODIMP_(ULONG) \
150  __kp_class_name##::AddRef() { return ++__m_uInterfaceRefCount; } \
151  STDMETHODIMP_(ULONG) __kp_class_name##::Release() { \
152  ULONG __kp_ref = __m_uInterfaceRefCount; \
153  if(__m_uInterfaceRefCount != 0) { __kp_ref = --__m_uInterfaceRefCount; \
154  if(__m_uInterfaceRefCount == 0) delete this; } \
155  else { assert(false); } return __kp_ref; }
156 #endif
157 
158 #ifndef KP_IMPL_STDREFIMPL_SUB
159 #define KP_IMPL_STDREFIMPL_SUB(__kp_class_name,__kp_sub_name) STDMETHODIMP_(ULONG) \
160  __kp_class_name##::AddRef() { return ++__m_uInterfaceRefCount; } \
161  STDMETHODIMP_(ULONG) __kp_class_name##::Release() { \
162  ULONG __kp_ref = __m_uInterfaceRefCount; \
163  if(__m_uInterfaceRefCount != 0) { __kp_ref = --__m_uInterfaceRefCount; \
164  if(__m_uInterfaceRefCount == 0) { SAFE_DELETE(__kp_sub_name); delete this; } } \
165  else { assert(false); } return __kp_ref; }
166 #endif
167 
168 #ifndef KP_IMPL_STDREFIMPL_NODELETE
169 #define KP_IMPL_STDREFIMPL_NODELETE(__kp_class_name) STDMETHODIMP_(ULONG) \
170  __kp_class_name##::AddRef() { return ++__m_uInterfaceRefCount; } \
171  STDMETHODIMP_(ULONG) __kp_class_name##::Release() { \
172  if(__m_uInterfaceRefCount != 0) --__m_uInterfaceRefCount; \
173  else { assert(false); } return __m_uInterfaceRefCount; }
174 #endif
175 
176 #ifndef KP_IMPL_CONSTRUCT
177 #define KP_IMPL_CONSTRUCT { __m_uInterfaceRefCount = 1; }
178 #endif
179 
180 #ifndef KP_SUPPORT_INTERFACE
181 #define KP_SUPPORT_INTERFACE(__kp_iid,__kp_int) { assert(__m_uInterfaceRefCount > 0); \
182  if(riid == __kp_iid) { __kp_int##* __kp_p = this; *ppvObject = __kp_p; \
183  this->AddRef(); return S_OK; } }
184 #endif
185 
186 /* #ifndef KP_IMPL_SUPPORT_INTERFACES2
187 #define KP_IMPL_SUPPORT_INTERFACES2(__kp_class,__kp_iid1,__kp_int1,__kp_iid2,__kp_int2) \
188  STDMETHODIMP __kp_class##::QueryInterface(REFIID riid, void** ppvObject) { \
189  KP_SUPPORT_INTERFACE(__kp_iid1, __kp_int1); \
190  KP_SUPPORT_INTERFACE(__kp_iid2, __kp_int2); \
191  *ppvObject = NULL; return E_NOINTERFACE; }
192 #endif */
193 
194 #ifndef KP_ASSERT_REFS
195 #define KP_ASSERT_REFS(__kp_comobj,__kp_refcnt) ASSERT((__kp_comobj).AddRef() \
196  > 0); ASSERT((__kp_comobj).Release() == (__kp_refcnt));
197 #endif
198 
199 #ifndef KP_REQ_OUT_PTR
200 #define KP_REQ_OUT_PTR(__kp_ppv) { if((__kp_ppv) == NULL) { assert(false); \
201  return E_POINTER; } }
202 #endif
203 
204 #ifndef KP_REQ_OUT_PTR_INIT
205 #define KP_REQ_OUT_PTR_INIT(__kp_ppvx) { KP_REQ_OUT_PTR(__kp_ppvx); \
206  *(__kp_ppvx) = NULL; }
207 #endif
208 
209 // For use in CreateInstanceEx:
210 #ifndef KP_QUERY_INTERFACE_RELEASE_LOCAL_RET
211 #define KP_QUERY_INTERFACE_RELEASE_LOCAL_RET(__kp_comobj,__kp_riid,__kp_ppvout) { \
212  void* __kp_ip = NULL; if((__kp_comobj)->QueryInterface((__kp_riid), &__kp_ip) == \
213  S_OK) { *(__kp_ppvout) = __kp_ip; VERIFY((__kp_comobj)->Release() == 1); \
214  return S_OK; } else { VERIFY((__kp_comobj)->Release() == 0); return E_NOINTERFACE; } }
215 #endif
216 
217 #endif // ___SYS_DEF_EX_H___



Documentation generated with Doxygen.




Valid XHTML 1.0 Transitional Document

Get KeePass

Flattr this


KeePass is OSI Certified Open Source Software
Copyright © 2003-2018
Dominik Reichl, [Legal Contact / Imprint] [Disclaimer] [Acknowledgements] [Donate], Downloads hosted at

Get KeePass at SourceForge.net