Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1577 lines
65 KiB

  1. #ifndef __WSBDATE_H__
  2. #define __WSBDATE_H__
  3. #include "time.h"
  4. // WSBAPI is used on global public functions
  5. #ifndef WSBAPI
  6. #define WSBAPI __stdcall
  7. #endif
  8. // #ifdef _WSB_NO_WSB_SUPPORT
  9. // #error WSB classes not supported in this library variant.
  10. // #endif
  11. //
  12. // #ifndef __WSBWIN_H__
  13. // #include <afxwin.h>
  14. // #endif
  15. //
  16. // // include necessary WSB headers
  17. // #ifndef _OBJBASE_H_
  18. // #include <objbase.h>
  19. // #endif
  20. // #ifndef _WSBAUTO_H_
  21. // #include <oleauto.h>
  22. // #endif
  23. // #ifndef _WSBCTL_H_
  24. // #include <olectl.h>
  25. // #endif
  26. // //REVIEW: This header has no symbol to prevent repeated includes
  27. // #include <olectlid.h>
  28. // #ifndef __ocidl_h__
  29. // #include <ocidl.h>
  30. // #endif
  31. //
  32. // #ifdef _WSB_MINREBUILD
  33. // #pragma component(minrebuild, off)
  34. // #endif
  35. // #ifndef _WSB_FULLTYPEINFO
  36. // #pragma component(mintypeinfo, on)
  37. // #endif
  38. //
  39. // #ifndef _WSB_NOFORCE_LIBS
  40. // #ifndef _MAC
  41. //
  42. // /////////////////////////////////////////////////////////////////////////////
  43. // // Win32 libraries
  44. //
  45. // #ifdef _WSBDLL
  46. // #if defined(_DEBUG) && !defined(_WSB_MONOLITHIC)
  47. // #ifndef _UNICODE
  48. // #pragma comment(lib, "mfco42d.lib")
  49. // #else
  50. // #pragma comment(lib, "mfco42ud.lib")
  51. // #endif
  52. // #endif
  53. // #endif
  54. //
  55. // #pragma comment(lib, "oledlg.lib")
  56. // #pragma comment(lib, "ole32.lib")
  57. // #pragma comment(lib, "olepro32.lib")
  58. // #pragma comment(lib, "oleaut32.lib")
  59. // #pragma comment(lib, "uuid.lib")
  60. // #pragma comment(lib, "urlmon.lib")
  61. //
  62. // #else //!_MAC
  63. //
  64. // /////////////////////////////////////////////////////////////////////////////
  65. // // Mac libraries
  66. //
  67. // #ifdef _WSBDLL
  68. // #ifdef _DEBUG
  69. // #pragma comment(lib, "mfco42pd.lib")
  70. // #else
  71. // #pragma comment(lib, "mfco42p.lib")
  72. // #endif
  73. // #endif
  74. //
  75. // #if !defined(_WSBDLL) && !defined(_USRDLL)
  76. // #ifdef _DEBUG
  77. // #pragma comment(lib, "wlmoled.lib")
  78. // #pragma comment(lib, "ole2uid.lib")
  79. // #else
  80. // #pragma comment(lib, "wlmole.lib")
  81. // #pragma comment(lib, "ole2ui.lib")
  82. // #endif
  83. // #pragma comment(linker, "/macres:ole2ui.rsc")
  84. // #else
  85. // #ifdef _DEBUG
  86. // #pragma comment(lib, "oledlgd.lib")
  87. // #pragma comment(lib, "msvcoled.lib")
  88. // #else
  89. // #pragma comment(lib, "oledlg.lib")
  90. // #pragma comment(lib, "msvcole.lib")
  91. // #endif
  92. // #endif
  93. //
  94. // #pragma comment(lib, "uuid.lib")
  95. //
  96. // #ifdef _DEBUG
  97. // #pragma comment(lib, "ole2d.lib")
  98. // #pragma comment(lib, "ole2autd.lib")
  99. // #else
  100. // #pragma comment(lib, "ole2.lib")
  101. // #pragma comment(lib, "ole2auto.lib")
  102. // #endif
  103. //
  104. // #endif //_MAC
  105. // #endif //!_WSB_NOFORCE_LIBS
  106. //
  107. // /////////////////////////////////////////////////////////////////////////////
  108. //
  109. // #ifdef _WSB_PACKING
  110. // #pragma pack(push, _WSB_PACKING)
  111. // #endif
  112. //
  113. // /////////////////////////////////////////////////////////////////////////////
  114. // // WSBDATE - MFC IDispatch & ClassFactory support
  115. //
  116. // // Classes declared in this file
  117. //
  118. // //CCmdTarget
  119. // class CWsbObjectFactory; // glue for IClassFactory -> runtime class
  120. // class CWsbTemplateServer; // server documents using CDocTemplate
  121. //
  122. // class CWsbDispatchDriver; // helper class to call IDispatch
  123. // class CWsbCurrency; // Based on OLE CY
  124. // class CWsbSafeArray; // Based on WSB VARIANT
  125. // //CException
  126. // class CWsbException; // caught by client or server
  127. // class CWsbDispatchException; // special exception for IDispatch calls
  128. class CWsbDVariant; // WSB VARIANT wrapper
  129. class CWsbDateTime; // Based on WSB DATE
  130. class CWsbDateTimeSpan; // Based on a double
  131. /////////////////////////////////////////////////////////////////////////////
  132. // // WSBDLL support
  133. // #undef WSB_DATA
  134. // #define WSB_DATA WSB_DATA
  135. //
  136. // /////////////////////////////////////////////////////////////////////////////
  137. // // WSB COM (Component Object Model) implementation infrastructure
  138. // // - data driven QueryInterface
  139. // // - standard implementation of aggregate AddRef and Release
  140. // // (see CCmdTarget in WSBWIN.H for more information)
  141. //
  142. // #define METHOD_PROLOGUE(theClass, localClass) \
  143. // theClass* pThis = \
  144. // ((theClass*)((BYTE*)this - offsetof(theClass, m_x##localClass))); \
  145. // WSB_MANAGE_STATE(pThis->m_pModuleState) \
  146. //
  147. // #define METHOD_PROLOGUE_(theClass, localClass) \
  148. // theClass* pThis = \
  149. // ((theClass*)((BYTE*)this - offsetof(theClass, m_x##localClass))); \
  150. //
  151. // #ifndef _WSB_NO_NESTED_DERIVATION
  152. // #define METHOD_PROLOGUE_EX(theClass, localClass) \
  153. // theClass* pThis = ((theClass*)((BYTE*)this - m_nOffset)); \
  154. // WSB_MANAGE_STATE(pThis->m_pModuleState) \
  155. //
  156. // #define METHOD_PROLOGUE_EX_(theClass, localClass) \
  157. // theClass* pThis = ((theClass*)((BYTE*)this - m_nOffset)); \
  158. //
  159. // #else
  160. // #define METHOD_PROLOGUE_EX(theClass, localClass) \
  161. // METHOD_PROLOGUE(theClass, localClass) \
  162. //
  163. // #define METHOD_PROLOGUE_EX_(theClass, localClass) \
  164. // METHOD_PROLOGUE_(theClass, localClass) \
  165. //
  166. // #endif
  167. //
  168. // // Provided only for compatibility with CDK 1.x
  169. // #define METHOD_MANAGE_STATE(theClass, localClass) \
  170. // METHOD_PROLOGUE_EX(theClass, localClass) \
  171. //
  172. // #define BEGIN_INTERFACE_PART(localClass, baseClass) \
  173. // class X##localClass : public baseClass \
  174. // { \
  175. // public: \
  176. // STDMETHOD_(ULONG, AddRef)(); \
  177. // STDMETHOD_(ULONG, Release)(); \
  178. // STDMETHOD(QueryInterface)(REFIID iid, LPVOID* ppvObj); \
  179. //
  180. // #ifndef _WSB_NO_NESTED_DERIVATION
  181. // #define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass) \
  182. // class X##localClass : public baseClass \
  183. // { \
  184. // public: \
  185. //
  186. // #else
  187. // #define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass) \
  188. // BEGIN_INTERFACE_PART(localClass, baseClass) \
  189. //
  190. // #endif
  191. //
  192. // #ifndef _WSB_NO_NESTED_DERIVATION
  193. // #define INIT_INTERFACE_PART(theClass, localClass) \
  194. // size_t m_nOffset; \
  195. // INIT_INTERFACE_PART_DERIVE(theClass, localClass) \
  196. //
  197. // #define INIT_INTERFACE_PART_DERIVE(theClass, localClass) \
  198. // X##localClass() \
  199. // { m_nOffset = offsetof(theClass, m_x##localClass); } \
  200. //
  201. // #else
  202. // #define INIT_INTERFACE_PART(theClass, localClass)
  203. // #define INIT_INTERFACE_PART_DERIVE(theClass, localClass)
  204. //
  205. // #endif
  206. //
  207. // // Note: Inserts the rest of WSB functionality between these two macros,
  208. // // depending upon the interface that is being implemented. It is not
  209. // // necessary to include AddRef, Release, and QueryInterface since those
  210. // // member functions are declared by the macro.
  211. //
  212. // #define END_INTERFACE_PART(localClass) \
  213. // } m_x##localClass; \
  214. // friend class X##localClass; \
  215. //
  216. // #ifdef _WSBDLL
  217. // #define BEGIN_INTERFACE_MAP(theClass, theBase) \
  218. // const WSB_INTERFACEMAP* PASCAL theClass::_GetBaseInterfaceMap() \
  219. // { return &theBase::interfaceMap; } \
  220. // const WSB_INTERFACEMAP* theClass::GetInterfaceMap() const \
  221. // { return &theClass::interfaceMap; } \
  222. // const WSB_DATADEF WSB_INTERFACEMAP theClass::interfaceMap = \
  223. // { &theClass::_GetBaseInterfaceMap, &theClass::_interfaceEntries[0], }; \
  224. // const WSB_DATADEF WSB_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \
  225. // { \
  226. //
  227. // #else
  228. // #define BEGIN_INTERFACE_MAP(theClass, theBase) \
  229. // const WSB_INTERFACEMAP* theClass::GetInterfaceMap() const \
  230. // { return &theClass::interfaceMap; } \
  231. // const WSB_DATADEF WSB_INTERFACEMAP theClass::interfaceMap = \
  232. // { &theBase::interfaceMap, &theClass::_interfaceEntries[0], }; \
  233. // const WSB_DATADEF WSB_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \
  234. // { \
  235. //
  236. // #endif
  237. //
  238. // #define INTERFACE_PART(theClass, iid, localClass) \
  239. // { &iid, offsetof(theClass, m_x##localClass) }, \
  240. //
  241. // #define INTERFACE_AGGREGATE(theClass, theAggr) \
  242. // { NULL, offsetof(theClass, theAggr) }, \
  243. //
  244. // #define END_INTERFACE_MAP() \
  245. // { NULL, (size_t)-1 } \
  246. // }; \
  247. // /////////////////////////////////////////////////////////////////////////////
  248. // // CWsbException - unexpected or rare WSB error returned
  249. //
  250. // class CWsbException : public CException
  251. // {
  252. // DECLARE_DYNAMIC(CWsbException)
  253. //
  254. // public:
  255. // SCODE m_sc;
  256. // static SCODE PASCAL Process(const CException* pAnyException);
  257. //
  258. // // Implementation (use WsbThrowWsbException to create)
  259. // public:
  260. // CWsbException();
  261. // virtual ~CWsbException();
  262. //
  263. // virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
  264. // PUINT pnHelpContext = NULL);
  265. // };
  266. //
  267. // void WSBAPI WsbThrowWsbException(SCODE sc);
  268. // /////////////////////////////////////////////////////////////////////////////
  269. // // IDispatch specific exception
  270. //
  271. // class CWsbDispatchException : public CException
  272. // {
  273. // DECLARE_DYNAMIC(CWsbDispatchException)
  274. //
  275. // public:
  276. // // Attributes
  277. // WORD m_wCode; // error code (specific to IDispatch implementation)
  278. // CString m_strDescription; // human readable description of the error
  279. // DWORD m_dwHelpContext; // help context for error
  280. //
  281. // // usually empty in application which creates it (eg. servers)
  282. // CString m_strHelpFile; // help file to use with m_dwHelpContext
  283. // CString m_strSource; // source of the error (name of server)
  284. //
  285. // // Implementation
  286. // public:
  287. // CWsbDispatchException(LPCTSTR lpszDescription, UINT nHelpID, WORD wCode);
  288. // virtual ~CWsbDispatchException();
  289. // static void PASCAL Process(
  290. // EXCEPINFO* pInfo, const CException* pAnyException);
  291. //
  292. // virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
  293. // PUINT pnHelpContext = NULL);
  294. //
  295. // SCODE m_scError; // SCODE describing the error
  296. // };
  297. //
  298. // void WSBAPI WsbThrowWsbDispatchException(WORD wCode, LPCTSTR lpszDescription,
  299. // UINT nHelpID = 0);
  300. // void WSBAPI WsbThrowWsbDispatchException(WORD wCode, UINT nDescriptionID,
  301. // UINT nHelpID = (UINT)-1);
  302. // /////////////////////////////////////////////////////////////////////////////
  303. // // Macros for CCmdTarget IDispatchable classes
  304. //
  305. // #ifdef _WSBDLL
  306. // #define BEGIN_DISPATCH_MAP(theClass, baseClass) \
  307. // const WSB_DISPMAP* PASCAL theClass::_GetBaseDispatchMap() \
  308. // { return &baseClass::dispatchMap; } \
  309. // const WSB_DISPMAP* theClass::GetDispatchMap() const \
  310. // { return &theClass::dispatchMap; } \
  311. // const WSB_DISPMAP theClass::dispatchMap = \
  312. // { &theClass::_GetBaseDispatchMap, &theClass::_dispatchEntries[0], \
  313. // &theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \
  314. // UINT theClass::_dispatchEntryCount = (UINT)-1; \
  315. // DWORD theClass::_dwStockPropMask = (DWORD)-1; \
  316. // const WSB_DISPMAP_ENTRY theClass::_dispatchEntries[] = \
  317. // { \
  318. //
  319. // #else
  320. // #define BEGIN_DISPATCH_MAP(theClass, baseClass) \
  321. // const WSB_DISPMAP* theClass::GetDispatchMap() const \
  322. // { return &theClass::dispatchMap; } \
  323. // const WSB_DISPMAP theClass::dispatchMap = \
  324. // { &baseClass::dispatchMap, &theClass::_dispatchEntries[0], \
  325. // &theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \
  326. // UINT theClass::_dispatchEntryCount = (UINT)-1; \
  327. // DWORD theClass::_dwStockPropMask = (DWORD)-1; \
  328. // const WSB_DISPMAP_ENTRY theClass::_dispatchEntries[] = \
  329. // { \
  330. //
  331. // #endif
  332. //
  333. // #define END_DISPATCH_MAP() \
  334. // { VTS_NONE, DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  335. // (WSB_PMSG)NULL, (WSB_PMSG)NULL, (size_t)-1, afxDispCustom } }; \
  336. //
  337. // // parameter types: by value VTs
  338. // #define VTS_I2 "\x02" // a 'short'
  339. // #define VTS_I4 "\x03" // a 'long'
  340. // #define VTS_R4 "\x04" // a 'float'
  341. // #define VTS_R8 "\x05" // a 'double'
  342. // #define VTS_CY "\x06" // a 'CY' or 'CY*'
  343. // #define VTS_DATE "\x07" // a 'DATE'
  344. // #define VTS_WBSTR "\x08" // an 'LPCWSBSTR'
  345. // #define VTS_DISPATCH "\x09" // an 'IDispatch*'
  346. // #define VTS_SCODE "\x0A" // an 'SCODE'
  347. // #define VTS_BOOL "\x0B" // a 'BOOL'
  348. // #define VTS_VARIANT "\x0C" // a 'const VARIANT&' or 'VARIANT*'
  349. // #define VTS_UNKNOWN "\x0D" // an 'IUnknown*'
  350. // #if defined(_UNICODE) || defined(WSB2ANSI)
  351. // #define VTS_BSTR VTS_WBSTR// an 'LPCWSBSTR'
  352. // #define VT_BSTRT VT_BSTR
  353. // #else
  354. // #define VTS_BSTR "\x0E" // an 'LPCSTR'
  355. // #define VT_BSTRA 14
  356. // #define VT_BSTRT VT_BSTRA
  357. // #endif
  358. //
  359. // // parameter types: by reference VTs
  360. // #define VTS_PI2 "\x42" // a 'short*'
  361. // #define VTS_PI4 "\x43" // a 'long*'
  362. // #define VTS_PR4 "\x44" // a 'float*'
  363. // #define VTS_PR8 "\x45" // a 'double*'
  364. // #define VTS_PCY "\x46" // a 'CY*'
  365. // #define VTS_PDATE "\x47" // a 'DATE*'
  366. // #define VTS_PBSTR "\x48" // a 'BSTR*'
  367. // #define VTS_PDISPATCH "\x49" // an 'IDispatch**'
  368. // #define VTS_PSCODE "\x4A" // an 'SCODE*'
  369. // #define VTS_PBOOL "\x4B" // a 'VARIANT_BOOL*'
  370. // #define VTS_PVARIANT "\x4C" // a 'VARIANT*'
  371. // #define VTS_PUNKNOWN "\x4D" // an 'IUnknown**'
  372. //
  373. // // special VT_ and VTS_ values
  374. // #define VTS_NONE NULL // used for members with 0 params
  375. // #define VT_MFCVALUE 0xFFF // special value for DISPID_VALUE
  376. // #define VT_MFCBYREF 0x40 // indicates VT_BYREF type
  377. // #define VT_MFCMARKER 0xFF // delimits named parameters (INTERNAL USE)
  378. //
  379. // // variant handling (use V_BSTRT when you have ANSI BSTRs, as in DAO)
  380. // #ifndef _UNICODE
  381. // #define V_BSTRT(b) (LPSTR)V_BSTR(b)
  382. // #else
  383. // #define V_BSTRT(b) V_BSTR(b)
  384. // #endif
  385. //
  386. // /////////////////////////////////////////////////////////////////////////////
  387. // // WSB control parameter types
  388. //
  389. // #define VTS_COLOR VTS_I4 // WSB_COLOR
  390. // #define VTS_XPOS_PIXELS VTS_I4 // WSB_XPOS_PIXELS
  391. // #define VTS_YPOS_PIXELS VTS_I4 // WSB_YPOS_PIXELS
  392. // #define VTS_XSIZE_PIXELS VTS_I4 // WSB_XSIZE_PIXELS
  393. // #define VTS_YSIZE_PIXELS VTS_I4 // WSB_YSIZE_PIXELS
  394. // #define VTS_XPOS_HIMETRIC VTS_I4 // WSB_XPOS_HIMETRIC
  395. // #define VTS_YPOS_HIMETRIC VTS_I4 // WSB_YPOS_HIMETRIC
  396. // #define VTS_XSIZE_HIMETRIC VTS_I4 // WSB_XSIZE_HIMETRIC
  397. // #define VTS_YSIZE_HIMETRIC VTS_I4 // WSB_YSIZE_HIMETRIC
  398. // #define VTS_TRISTATE VTS_I2 // WSB_TRISTATE
  399. // #define VTS_OPTEXCLUSIVE VTS_BOOL // WSB_OPTEXCLUSIVE
  400. //
  401. // #define VTS_PCOLOR VTS_PI4 // WSB_COLOR*
  402. // #define VTS_PXPOS_PIXELS VTS_PI4 // WSB_XPOS_PIXELS*
  403. // #define VTS_PYPOS_PIXELS VTS_PI4 // WSB_YPOS_PIXELS*
  404. // #define VTS_PXSIZE_PIXELS VTS_PI4 // WSB_XSIZE_PIXELS*
  405. // #define VTS_PYSIZE_PIXELS VTS_PI4 // WSB_YSIZE_PIXELS*
  406. // #define VTS_PXPOS_HIMETRIC VTS_PI4 // WSB_XPOS_HIMETRIC*
  407. // #define VTS_PYPOS_HIMETRIC VTS_PI4 // WSB_YPOS_HIMETRIC*
  408. // #define VTS_PXSIZE_HIMETRIC VTS_PI4 // WSB_XSIZE_HIMETRIC*
  409. // #define VTS_PYSIZE_HIMETRIC VTS_PI4 // WSB_YSIZE_HIMETRIC*
  410. // #define VTS_PTRISTATE VTS_PI2 // WSB_TRISTATE*
  411. // #define VTS_POPTEXCLUSIVE VTS_PBOOL // WSB_OPTEXCLUSIVE*
  412. //
  413. // #define VTS_FONT VTS_DISPATCH // IFontDispatch*
  414. // #define VTS_PICTURE VTS_DISPATCH // IPictureDispatch*
  415. //
  416. // #define VTS_HANDLE VTS_I4 // WSB_HANDLE
  417. // #define VTS_PHANDLE VTS_PI4 // WSB_HANDLE*
  418. //
  419. // // these DISP_ macros cause the framework to generate the DISPID
  420. // #define DISP_FUNCTION(theClass, szExternalName, pfnMember, vtRetVal, vtsParams) \
  421. // { _T(szExternalName), DISPID_UNKNOWN, vtsParams, vtRetVal, \
  422. // (WSB_PMSG)(void (theClass::*)(void))&pfnMember, (WSB_PMSG)0, 0, \
  423. // afxDispCustom }, \
  424. //
  425. // #define DISP_PROPERTY(theClass, szExternalName, memberName, vtPropType) \
  426. // { _T(szExternalName), DISPID_UNKNOWN, NULL, vtPropType, (WSB_PMSG)0, (WSB_PMSG)0, \
  427. // offsetof(theClass, memberName), afxDispCustom }, \
  428. //
  429. // #define DISP_PROPERTY_NOTIFY(theClass, szExternalName, memberName, pfnAfterSet, vtPropType) \
  430. // { _T(szExternalName), DISPID_UNKNOWN, NULL, vtPropType, (WSB_PMSG)0, \
  431. // (WSB_PMSG)(void (theClass::*)(void))&pfnAfterSet, \
  432. // offsetof(theClass, memberName), afxDispCustom }, \
  433. //
  434. // #define DISP_PROPERTY_EX(theClass, szExternalName, pfnGet, pfnSet, vtPropType) \
  435. // { _T(szExternalName), DISPID_UNKNOWN, NULL, vtPropType, \
  436. // (WSB_PMSG)(void (theClass::*)(void))&pfnGet, \
  437. // (WSB_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  438. //
  439. // #define DISP_PROPERTY_PARAM(theClass, szExternalName, pfnGet, pfnSet, vtPropType, vtsParams) \
  440. // { _T(szExternalName), DISPID_UNKNOWN, vtsParams, vtPropType, \
  441. // (WSB_PMSG)(void (theClass::*)(void))&pfnGet, \
  442. // (WSB_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  443. //
  444. // // these DISP_ macros allow the app to determine the DISPID
  445. // #define DISP_FUNCTION_ID(theClass, szExternalName, dispid, pfnMember, vtRetVal, vtsParams) \
  446. // { _T(szExternalName), dispid, vtsParams, vtRetVal, \
  447. // (WSB_PMSG)(void (theClass::*)(void))&pfnMember, (WSB_PMSG)0, 0, \
  448. // afxDispCustom }, \
  449. //
  450. // #define DISP_PROPERTY_ID(theClass, szExternalName, dispid, memberName, vtPropType) \
  451. // { _T(szExternalName), dispid, NULL, vtPropType, (WSB_PMSG)0, (WSB_PMSG)0, \
  452. // offsetof(theClass, memberName), afxDispCustom }, \
  453. //
  454. // #define DISP_PROPERTY_NOTIFY_ID(theClass, szExternalName, dispid, memberName, pfnAfterSet, vtPropType) \
  455. // { _T(szExternalName), dispid, NULL, vtPropType, (WSB_PMSG)0, \
  456. // (WSB_PMSG)(void (theClass::*)(void))&pfnAfterSet, \
  457. // offsetof(theClass, memberName), afxDispCustom }, \
  458. //
  459. // #define DISP_PROPERTY_EX_ID(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType) \
  460. // { _T(szExternalName), dispid, NULL, vtPropType, \
  461. // (WSB_PMSG)(void (theClass::*)(void))&pfnGet, \
  462. // (WSB_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  463. //
  464. // #define DISP_PROPERTY_PARAM_ID(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType, vtsParams) \
  465. // { _T(szExternalName), dispid, vtsParams, vtPropType, \
  466. // (WSB_PMSG)(void (theClass::*)(void))&pfnGet, \
  467. // (WSB_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  468. //
  469. // // the DISP_DEFVALUE is a special case macro that creates an alias for DISPID_VALUE
  470. // #define DISP_DEFVALUE(theClass, szExternalName) \
  471. // { _T(szExternalName), DISPID_UNKNOWN, NULL, VT_MFCVALUE, \
  472. // (WSB_PMSG)0, (WSB_PMSG)0, 0, afxDispCustom }, \
  473. //
  474. // #define DISP_DEFVALUE_ID(theClass, dispid) \
  475. // { NULL, dispid, NULL, VT_MFCVALUE, (WSB_PMSG)0, (WSB_PMSG)0, 0, \
  476. // afxDispCustom }, \
  477. //
  478. // /////////////////////////////////////////////////////////////////////////////
  479. // // Macros for creating "creatable" automation classes.
  480. //
  481. // #define DECLARE_WSBCREATE(class_name) \
  482. // public: \
  483. // static WSB_DATA CWsbObjectFactory factory; \
  484. // static WSB_DATA const GUID guid; \
  485. //
  486. // #define IMPLEMENT_WSBCREATE(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  487. // WSB_DATADEF CWsbObjectFactory class_name::factory(class_name::guid, \
  488. // RUNTIME_CLASS(class_name), FALSE, _T(external_name)); \
  489. // const WSB_DATADEF GUID class_name::guid = \
  490. // { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }; \
  491. //
  492. // /////////////////////////////////////////////////////////////////////////////
  493. // // Helper class for driving IDispatch
  494. //
  495. // class CWsbDispatchDriver
  496. // {
  497. // // Constructors
  498. // public:
  499. // CWsbDispatchDriver();
  500. // CWsbDispatchDriver(LPDISPATCH lpDispatch, BOOL bAutoRelease = TRUE);
  501. // CWsbDispatchDriver(const CWsbDispatchDriver& dispatchSrc);
  502. //
  503. // // Attributes
  504. // LPDISPATCH m_lpDispatch;
  505. // BOOL m_bAutoRelease;
  506. //
  507. // // Operations
  508. // BOOL CreateDispatch(REFCLSID clsid, CWsbException* pError = NULL);
  509. // BOOL CreateDispatch(LPCTSTR lpszProgID, CWsbException* pError = NULL);
  510. //
  511. // void AttachDispatch(LPDISPATCH lpDispatch, BOOL bAutoRelease = TRUE);
  512. // LPDISPATCH DetachDispatch();
  513. // // detach and get ownership of m_lpDispatch
  514. // void ReleaseDispatch();
  515. //
  516. // // helpers for IDispatch::Invoke
  517. // void WSB_CDECL InvokeHelper(DISPID dwDispID, WORD wFlags,
  518. // VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ...);
  519. // void WSB_CDECL SetProperty(DISPID dwDispID, VARTYPE vtProp, ...);
  520. // void GetProperty(DISPID dwDispID, VARTYPE vtProp, void* pvProp) const;
  521. //
  522. // // special operators
  523. // operator LPDISPATCH();
  524. // const CWsbDispatchDriver& operator=(const CWsbDispatchDriver& dispatchSrc);
  525. //
  526. // // Implementation
  527. // public:
  528. // ~CWsbDispatchDriver();
  529. // void InvokeHelperV(DISPID dwDispID, WORD wFlags, VARTYPE vtRet,
  530. // void* pvRet, const BYTE* pbParamInfo, va_list argList);
  531. // };
  532. //
  533. // /////////////////////////////////////////////////////////////////////////////
  534. // // Class Factory implementation (binds WSB class factory -> runtime class)
  535. // // (all specific class factories derive from this class factory)
  536. //
  537. // class CWsbObjectFactory : public CCmdTarget
  538. // {
  539. // DECLARE_DYNAMIC(CWsbObjectFactory)
  540. //
  541. // // Construction
  542. // public:
  543. // CWsbObjectFactory(REFCLSID clsid, CRuntimeClass* pRuntimeClass,
  544. // BOOL bMultiInstance, LPCTSTR lpszProgID);
  545. //
  546. // // Attributes
  547. // virtual BOOL IsRegistered() const;
  548. // REFCLSID GetClassID() const;
  549. //
  550. // // Operations
  551. // virtual BOOL Register();
  552. // void Revoke();
  553. // void UpdateRegistry(LPCTSTR lpszProgID = NULL);
  554. // // default uses m_lpszProgID if not NULL
  555. // BOOL IsLicenseValid();
  556. //
  557. // static BOOL PASCAL RegisterAll();
  558. // static void PASCAL RevokeAll();
  559. // static BOOL PASCAL UpdateRegistryAll(BOOL bRegister = TRUE);
  560. //
  561. // // Overridables
  562. // protected:
  563. // virtual CCmdTarget* OnCreateObject();
  564. // virtual BOOL UpdateRegistry(BOOL bRegister);
  565. // virtual BOOL VerifyUserLicense();
  566. // virtual BOOL GetLicenseKey(DWORD dwReserved, BSTR* pbstrKey);
  567. // virtual BOOL VerifyLicenseKey(BSTR bstrKey);
  568. //
  569. // // Implementation
  570. // public:
  571. // virtual ~CWsbObjectFactory();
  572. // #ifdef _DEBUG
  573. // void AssertValid() const;
  574. // void Dump(CDumpContext& dc) const;
  575. // #endif
  576. //
  577. // public:
  578. // CWsbObjectFactory* m_pNextFactory; // list of factories maintained
  579. //
  580. // protected:
  581. // DWORD m_dwRegister; // registry identifier
  582. // CLSID m_clsid; // registered class ID
  583. // CRuntimeClass* m_pRuntimeClass; // runtime class of CCmdTarget derivative
  584. // BOOL m_bMultiInstance; // multiple instance?
  585. // LPCTSTR m_lpszProgID; // human readable class ID
  586. // BYTE m_bLicenseChecked;
  587. // BYTE m_bLicenseValid;
  588. // BYTE m_bRegistered; // is currently registered w/ system
  589. // BYTE m_bReserved; // reserved for future use
  590. //
  591. // // Interface Maps
  592. // public:
  593. // BEGIN_INTERFACE_PART(ClassFactory, IClassFactory2)
  594. // INIT_INTERFACE_PART(CWsbObjectFactory, ClassFactory)
  595. // STDMETHOD(CreateInstance)(LPUNKNOWN, REFIID, LPVOID*);
  596. // STDMETHOD(LockServer)(BOOL);
  597. // STDMETHOD(GetLicInfo)(LPLICINFO);
  598. // STDMETHOD(RequestLicKey)(DWORD, BSTR*);
  599. // STDMETHOD(CreateInstanceLic)(LPUNKNOWN, LPUNKNOWN, REFIID, BSTR,
  600. // LPVOID*);
  601. // END_INTERFACE_PART(ClassFactory)
  602. //
  603. // DECLARE_INTERFACE_MAP()
  604. //
  605. // friend SCODE WSBAPI WsbDllGetClassObject(REFCLSID, REFIID, LPVOID*);
  606. // friend SCODE STDAPICALLTYPE DllGetClassObject(REFCLSID, REFIID, LPVOID*);
  607. // };
  608. //
  609. // // Define CWsbObjectFactoryEx for compatibility with old CDK
  610. // #define CWsbObjectFactoryEx CWsbObjectFactory
  611. //
  612. // //////////////////////////////////////////////////////////////////////////////
  613. // // CWsbTemplateServer - CWsbObjectFactory using CDocTemplates
  614. //
  615. // // This enumeration is used in WsbWsbRegisterServerClass to pick the
  616. // // correct registration entries given the application type.
  617. // enum WSB_APPTYPE
  618. // {
  619. // OAT_INPLACE_SERVER = 0, // server has full server user-interface
  620. // OAT_SERVER = 1, // server supports only embedding
  621. // OAT_CONTAINER = 2, // container supports links to embeddings
  622. // OAT_DISPATCH_OBJECT = 3, // IDispatch capable object
  623. // OAT_DOC_OBJECT_SERVER = 4, // sever supports DocObject embedding
  624. // OAT_DOC_OBJECT_CONTAINER =5,// container supports DocObject clients
  625. // };
  626. //
  627. // class CWsbTemplateServer : public CWsbObjectFactory
  628. // {
  629. // // Constructors
  630. // public:
  631. // CWsbTemplateServer();
  632. //
  633. // // Operations
  634. // void ConnectTemplate(REFCLSID clsid, CDocTemplate* pDocTemplate,
  635. // BOOL bMultiInstance);
  636. // // set doc template after creating it in InitInstance
  637. // void UpdateRegistry(WSB_APPTYPE nAppType = OAT_INPLACE_SERVER,
  638. // LPCTSTR* rglpszRegister = NULL, LPCTSTR* rglpszOverwrite = NULL);
  639. // // may want to UpdateRegistry if not run with /Embedded
  640. // BOOL Register();
  641. //
  642. // // Implementation
  643. // protected:
  644. // virtual CCmdTarget* OnCreateObject();
  645. // CDocTemplate* m_pDocTemplate;
  646. //
  647. // private:
  648. // void UpdateRegistry(LPCTSTR lpszProgID);
  649. // // hide base class version of UpdateRegistry
  650. // };
  651. //
  652. // /////////////////////////////////////////////////////////////////////////////
  653. // // System registry helpers
  654. //
  655. // // Helper to register server in case of no .REG file loaded
  656. // BOOL WSBAPI WsbWsbRegisterServerClass(
  657. // REFCLSID clsid, LPCTSTR lpszClassName,
  658. // LPCTSTR lpszShortTypeName, LPCTSTR lpszLongTypeName,
  659. // WSB_APPTYPE nAppType = OAT_SERVER,
  660. // LPCTSTR* rglpszRegister = NULL, LPCTSTR* rglpszOverwrite = NULL,
  661. // int nIconIndex = 0, LPCTSTR lpszLocalFilterName = NULL);
  662. //
  663. // // WsbWsbRegisterHelper is a worker function used by WsbWsbRegisterServerClass
  664. // // (available for advanced registry work)
  665. // BOOL WSBAPI WsbWsbRegisterHelper(LPCTSTR const* rglpszRegister,
  666. // LPCTSTR const* rglpszSymbols, int nSymbols, BOOL bReplace,
  667. // HKEY hKeyRoot = ((HKEY)0x80000000)); // HKEY_CLASSES_ROOT
  668. //
  669. // /////////////////////////////////////////////////////////////////////////////
  670. // // Connection maps
  671. //
  672. // #define BEGIN_CONNECTION_PART(theClass, localClass) \
  673. // class X##localClass : public CConnectionPoint \
  674. // { \
  675. // public: \
  676. // X##localClass() \
  677. // { m_nOffset = offsetof(theClass, m_x##localClass); }
  678. //
  679. // #define CONNECTION_IID(iid) \
  680. // REFIID GetIID() { return iid; }
  681. //
  682. // #define END_CONNECTION_PART(localClass) \
  683. // } m_x##localClass; \
  684. // friend class X##localClass;
  685. //
  686. // #ifdef _WSBDLL
  687. // #define BEGIN_CONNECTION_MAP(theClass, theBase) \
  688. // const WSB_CONNECTIONMAP* PASCAL theClass::_GetBaseConnectionMap() \
  689. // { return &theBase::connectionMap; } \
  690. // const WSB_CONNECTIONMAP* theClass::GetConnectionMap() const \
  691. // { return &theClass::connectionMap; } \
  692. // const WSB_DATADEF WSB_CONNECTIONMAP theClass::connectionMap = \
  693. // { &theClass::_GetBaseConnectionMap, &theClass::_connectionEntries[0], }; \
  694. // const WSB_DATADEF WSB_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
  695. // { \
  696. //
  697. // #else
  698. // #define BEGIN_CONNECTION_MAP(theClass, theBase) \
  699. // const WSB_CONNECTIONMAP* theClass::GetConnectionMap() const \
  700. // { return &theClass::connectionMap; } \
  701. // const WSB_DATADEF WSB_CONNECTIONMAP theClass::connectionMap = \
  702. // { &(theBase::connectionMap), &theClass::_connectionEntries[0], }; \
  703. // const WSB_DATADEF WSB_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
  704. // { \
  705. //
  706. // #endif
  707. //
  708. // #define CONNECTION_PART(theClass, iid, localClass) \
  709. // { &iid, offsetof(theClass, m_x##localClass) }, \
  710. //
  711. // #define END_CONNECTION_MAP() \
  712. // { NULL, (size_t)-1 } \
  713. // }; \
  714. //
  715. // /////////////////////////////////////////////////////////////////////////////
  716. // // CConnectionPoint
  717. //
  718. // class CConnectionPoint : public CCmdTarget
  719. // {
  720. // // Constructors
  721. // public:
  722. // CConnectionPoint();
  723. //
  724. // // Operations
  725. // POSITION GetStartPosition() const;
  726. // LPUNKNOWN GetNextConnection(POSITION& pos) const;
  727. // const CPtrArray* GetConnections(); // obsolete
  728. //
  729. // // Overridables
  730. // virtual LPCONNECTIONPOINTCONTAINER GetContainer();
  731. // virtual REFIID GetIID() = 0;
  732. // virtual void OnAdvise(BOOL bAdvise);
  733. // virtual int GetMaxConnections();
  734. // virtual LPUNKNOWN QuerySinkInterface(LPUNKNOWN pUnkSink);
  735. //
  736. // // Implementation
  737. // ~CConnectionPoint();
  738. // void CreateConnectionArray();
  739. // int GetConnectionCount();
  740. //
  741. // protected:
  742. // size_t m_nOffset;
  743. // LPUNKNOWN m_pUnkFirstConnection;
  744. // CPtrArray* m_pConnections;
  745. //
  746. // // Interface Maps
  747. // public:
  748. // BEGIN_INTERFACE_PART(ConnPt, IConnectionPoint)
  749. // INIT_INTERFACE_PART(CConnectionPoint, ConnPt)
  750. // STDMETHOD(GetConnectionInterface)(IID* pIID);
  751. // STDMETHOD(GetConnectionPointContainer)(
  752. // IConnectionPointContainer** ppCPC);
  753. // STDMETHOD(Advise)(LPUNKNOWN pUnkSink, DWORD* pdwCookie);
  754. // STDMETHOD(Unadvise)(DWORD dwCookie);
  755. // STDMETHOD(EnumConnections)(LPENUMCONNECTIONS* ppEnum);
  756. // END_INTERFACE_PART(ConnPt)
  757. // };
  758. //
  759. // /////////////////////////////////////////////////////////////////////////////
  760. // // EventSink Maps
  761. //
  762. // #ifndef _WSB_NO_OCC_SUPPORT
  763. //
  764. // #ifdef _WSBDLL
  765. // #define BEGIN_EVENTSINK_MAP(theClass, baseClass) \
  766. // const WSB_EVENTSINKMAP* PASCAL theClass::_GetBaseEventSinkMap() \
  767. // { return &baseClass::eventsinkMap; } \
  768. // const WSB_EVENTSINKMAP* theClass::GetEventSinkMap() const \
  769. // { return &theClass::eventsinkMap; } \
  770. // const WSB_EVENTSINKMAP theClass::eventsinkMap = \
  771. // { &theClass::_GetBaseEventSinkMap, &theClass::_eventsinkEntries[0], \
  772. // &theClass::_eventsinkEntryCount }; \
  773. // UINT theClass::_eventsinkEntryCount = (UINT)-1; \
  774. // const WSB_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
  775. // { \
  776. //
  777. // #else
  778. // #define BEGIN_EVENTSINK_MAP(theClass, baseClass) \
  779. // const WSB_EVENTSINKMAP* theClass::GetEventSinkMap() const \
  780. // { return &theClass::eventsinkMap; } \
  781. // const WSB_EVENTSINKMAP theClass::eventsinkMap = \
  782. // { &baseClass::eventsinkMap, &theClass::_eventsinkEntries[0], \
  783. // &theClass::_eventsinkEntryCount }; \
  784. // UINT theClass::_eventsinkEntryCount = (UINT)-1; \
  785. // const WSB_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
  786. // { \
  787. //
  788. // #endif
  789. //
  790. // #define END_EVENTSINK_MAP() \
  791. // { VTS_NONE, DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  792. // (WSB_PMSG)NULL, (WSB_PMSG)NULL, (size_t)-1, afxDispCustom, \
  793. // (UINT)-1, 0 } }; \
  794. //
  795. // #define ON_EVENT(theClass, id, dispid, pfnHandler, vtsParams) \
  796. // { _T(""), dispid, vtsParams, VT_BOOL, \
  797. // (WSB_PMSG)(void (theClass::*)(void))&pfnHandler, (WSB_PMSG)0, 0, \
  798. // afxDispCustom, id, (UINT)-1 }, \
  799. //
  800. // #define ON_EVENT_RANGE(theClass, idFirst, idLast, dispid, pfnHandler, vtsParams) \
  801. // { _T(""), dispid, vtsParams, VT_BOOL, \
  802. // (WSB_PMSG)(void (theClass::*)(void))&pfnHandler, (WSB_PMSG)0, 0, \
  803. // afxDispCustom, idFirst, idLast }, \
  804. //
  805. // #define ON_PROPNOTIFY(theClass, id, dispid, pfnRequest, pfnChanged) \
  806. // { _T(""), dispid, VTS_NONE, VT_VOID, \
  807. // (WSB_PMSG)(BOOL (CCmdTarget::*)(BOOL*))&pfnRequest, \
  808. // (WSB_PMSG)(BOOL (CCmdTarget::*)(void))&pfnChanged, \
  809. // 1, afxDispCustom, id, (UINT)-1 }, \
  810. //
  811. // #define ON_PROPNOTIFY_RANGE(theClass, idFirst, idLast, dispid, pfnRequest, pfnChanged) \
  812. // { _T(""), dispid, VTS_NONE, VT_VOID, \
  813. // (WSB_PMSG)(BOOL (CCmdTarget::*)(UINT, BOOL*))&pfnRequest, \
  814. // (WSB_PMSG)(BOOL (CCmdTarget::*)(UINT))&pfnChanged, \
  815. // 1, afxDispCustom, idFirst, idLast }, \
  816. //
  817. // #define ON_DSCNOTIFY(theClass, id, pfnNotify) \
  818. // { _T(""), DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  819. // (WSB_PMSG)(BOOL (CCmdTarget::*)(DSCSTATE, DSCREASON, BOOL*))&pfnNotify, (WSB_PMSG)0, \
  820. // 1, afxDispCustom, id, (UINT)-1 }, \
  821. //
  822. // #define ON_DSCNOTIFY_RANGE(theClass, idFirst, idLast, pfnNotify) \
  823. // { _T(""), DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  824. // (WSB_PMSG)(BOOL (CCmdTarget::*)(UINT, DSCSTATE, DSCREASON, BOOL*))&pfnNotify, (WSB_PMSG)0, \
  825. // 1, afxDispCustom, idFirst, idLast }, \
  826. //
  827. // #define ON_EVENT_REFLECT(theClass, dispid, pfnHandler, vtsParams) \
  828. // { _T(""), dispid, vtsParams, VT_BOOL, \
  829. // (WSB_PMSG)(void (theClass::*)(void))&pfnHandler, (WSB_PMSG)0, 0, \
  830. // afxDispCustom, (UINT)-1, (UINT)-1 }, \
  831. //
  832. // #define ON_PROPNOTIFY_REFLECT(theClass, dispid, pfnRequest, pfnChanged) \
  833. // { _T(""), dispid, VTS_NONE, VT_VOID, \
  834. // (WSB_PMSG)(BOOL (CCmdTarget::*)(BOOL*))&pfnRequest, \
  835. // (WSB_PMSG)(BOOL (CCmdTarget::*)(void))&pfnChanged, \
  836. // 1, afxDispCustom, (UINT)-1, (UINT)-1 }, \
  837. //
  838. // #endif // !_WSB_NO_OCC_SUPPORT
  839. //
  840. // /////////////////////////////////////////////////////////////////////////////
  841. // // Macros for type library information
  842. //
  843. // CTypeLibCache* WSBAPI WsbGetTypeLibCache(const GUID* pTypeLibID);
  844. //
  845. // #define DECLARE_WSBTYPELIB(class_name) \
  846. // protected: \
  847. // virtual UINT GetTypeInfoCount(); \
  848. // virtual HRESULT GetTypeLib(LCID, LPTYPELIB*); \
  849. // virtual CTypeLibCache* GetTypeLibCache(); \
  850. //
  851. // #define IMPLEMENT_WSBTYPELIB(class_name, tlid, wVerMajor, wVerMinor) \
  852. // UINT class_name::GetTypeInfoCount() \
  853. // { return 1; } \
  854. // HRESULT class_name::GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib) \
  855. // { return ::LoadRegTypeLib(tlid, wVerMajor, wVerMinor, lcid, ppTypeLib); } \
  856. // CTypeLibCache* class_name::GetTypeLibCache() \
  857. // { WSB_MANAGE_STATE(m_pModuleState); return WsbGetTypeLibCache(&tlid); } \
  858. //
  859. // /////////////////////////////////////////////////////////////////////////////
  860. // // Init & Term helpers
  861. //
  862. // BOOL WSBAPI WsbWsbInit();
  863. // void WSBAPI WsbWsbTerm(BOOL bJustRevoke = FALSE);
  864. // void WSBAPI WsbWsbTermOrFreeLib(BOOL bTerm = TRUE, BOOL bJustRevoke = FALSE);
  865. //
  866. // /////////////////////////////////////////////////////////////////////////////
  867. // // Memory management helpers (for WSB task allocator memory)
  868. //
  869. // #define WsbAllocTaskMem(nSize) CoTaskMemAlloc(nSize)
  870. // #define WsbFreeTaskMem(p) CoTaskMemFree(p)
  871. //
  872. // LPWSTR WSBAPI WsbAllocTaskWideString(LPCWSTR lpszString);
  873. // LPWSTR WSBAPI WsbAllocTaskWideString(LPCSTR lpszString);
  874. // LPSTR WSBAPI WsbAllocTaskAnsiString(LPCWSTR lpszString);
  875. // LPSTR WSBAPI WsbAllocTaskAnsiString(LPCSTR lpszString);
  876. //
  877. // #ifdef _UNICODE
  878. // #define WsbAllocTaskString(x) WsbAllocTaskWideString(x)
  879. // #else
  880. // #define WsbAllocTaskString(x) WsbAllocTaskAnsiString(x)
  881. // #endif
  882. //
  883. // #ifdef WSB2ANSI
  884. // #define WsbAllocTaskWsbString(x) WsbAllocTaskAnsiString(x)
  885. // #else
  886. // #define WsbAllocTaskWsbString(x) WsbAllocTaskWideString(x)
  887. // #endif
  888. //
  889. // HRESULT WSBAPI WsbGetClassIDFromString(LPCTSTR lpsz, LPCLSID lpClsID);
  890. //
  891. // /////////////////////////////////////////////////////////////////////////////
  892. // // Special in-proc server APIs
  893. //
  894. // SCODE WSBAPI WsbDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
  895. // SCODE WSBAPI WsbDllCanUnloadNow(void);
  896. /////////////////////////////////////////////////////////////////////////////
  897. // CWsbDVariant class helpers
  898. #define WSB_TRUE (-1)
  899. #define WSB_FALSE 0
  900. class CLongBinary; // forward reference (see afxdb_.h)
  901. /////////////////////////////////////////////////////////////////////////////
  902. // CWsbDVariant class - wraps VARIANT types
  903. typedef const VARIANT* LPCVARIANT;
  904. class CWsbDVariant : public tagVARIANT
  905. {
  906. // Constructors
  907. public:
  908. CWsbDVariant();
  909. CWsbDVariant(const VARIANT& varSrc);
  910. CWsbDVariant(LPCVARIANT pSrc);
  911. CWsbDVariant(const CWsbDVariant& varSrc);
  912. CWsbDVariant(LPCTSTR lpszSrc);
  913. CWsbDVariant(LPCTSTR lpszSrc, VARTYPE vtSrc); // used to set to ANSI string
  914. // CWsbDVariant(CString& strSrc);
  915. CWsbDVariant(BYTE nSrc);
  916. CWsbDVariant(short nSrc, VARTYPE vtSrc = VT_I2);
  917. CWsbDVariant(long lSrc, VARTYPE vtSrc = VT_I4);
  918. // CWsbDVariant(const CWsbCurrency& curSrc);
  919. CWsbDVariant(float fltSrc);
  920. CWsbDVariant(double dblSrc);
  921. CWsbDVariant(const CWsbDateTime& timeSrc);
  922. // CWsbDVariant(const CByteArray& arrSrc);
  923. // CWsbDVariant(const CLongBinary& lbSrc);
  924. // Operations
  925. public:
  926. void Clear();
  927. void ChangeType(VARTYPE vartype, LPVARIANT pSrc = NULL);
  928. void Attach(VARIANT& varSrc);
  929. VARIANT Detach();
  930. BOOL operator==(const VARIANT& varSrc) const;
  931. BOOL operator==(LPCVARIANT pSrc) const;
  932. const CWsbDVariant& operator=(const VARIANT& varSrc);
  933. const CWsbDVariant& operator=(LPCVARIANT pSrc);
  934. const CWsbDVariant& operator=(const CWsbDVariant& varSrc);
  935. const CWsbDVariant& operator=(const LPCTSTR lpszSrc);
  936. // const CWsbDVariant& operator=(const CString& strSrc);
  937. const CWsbDVariant& operator=(BYTE nSrc);
  938. const CWsbDVariant& operator=(short nSrc);
  939. const CWsbDVariant& operator=(long lSrc);
  940. // const CWsbDVariant& operator=(const CWsbCurrency& curSrc);
  941. const CWsbDVariant& operator=(float fltSrc);
  942. const CWsbDVariant& operator=(double dblSrc);
  943. const CWsbDVariant& operator=(const CWsbDateTime& dateSrc);
  944. // const CWsbDVariant& operator=(const CByteArray& arrSrc);
  945. // const CWsbDVariant& operator=(const CLongBinary& lbSrc);
  946. void SetString(LPCTSTR lpszSrc, VARTYPE vtSrc); // used to set ANSI string
  947. operator LPVARIANT();
  948. operator LPCVARIANT() const;
  949. // // Implementation
  950. public:
  951. ~CWsbDVariant();
  952. };
  953. // CWsbDVariant diagnostics and serialization
  954. // #ifdef _DEBUG
  955. // CDumpContext& WSBAPI operator<<(CDumpContext& dc, CWsbDVariant varSrc);
  956. // #endif
  957. // CArchive& WSBAPI operator<<(CArchive& ar, CWsbDVariant varSrc);
  958. // CArchive& WSBAPI operator>>(CArchive& ar, CWsbDVariant& varSrc);
  959. // Helper for initializing VARIANT structures
  960. void WSBAPI WsbDVariantInit(LPVARIANT pVar);
  961. // /////////////////////////////////////////////////////////////////////////////
  962. // // CWsbCurrency class
  963. //
  964. // class CWsbCurrency
  965. // {
  966. // // Constructors
  967. // public:
  968. // CWsbCurrency();
  969. //
  970. // CWsbCurrency(CURRENCY cySrc);
  971. // CWsbCurrency(const CWsbCurrency& curSrc);
  972. // CWsbCurrency(const VARIANT& varSrc);
  973. // CWsbCurrency(long nUnits, long nFractionalUnits);
  974. //
  975. // // Attributes
  976. // public:
  977. // enum CurrencyStatus
  978. // {
  979. // valid = 0,
  980. // invalid = 1, // Invalid currency (overflow, div 0, etc.)
  981. // null = 2, // Literally has no value
  982. // };
  983. //
  984. // CURRENCY m_cur;
  985. // CurrencyStatus m_status;
  986. //
  987. // void SetStatus(CurrencyStatus status);
  988. // CurrencyStatus etStatus() const;
  989. //
  990. // // Operations
  991. // public:
  992. // const CWsbCurrency& operator=(CURRENCY cySrc);
  993. // const CWsbCurrency& operator=(const CWsbCurrency& curSrc);
  994. // const CWsbCurrency& operator=(const VARIANT& varSrc);
  995. //
  996. // BOOL operator==(const CWsbCurrency& cur) const;
  997. // BOOL operator!=(const CWsbCurrency& cur) const;
  998. // BOOL operator<(const CWsbCurrency& cur) const;
  999. // BOOL operator>(const CWsbCurrency& cur) const;
  1000. // BOOL operator<=(const CWsbCurrency& cur) const;
  1001. // BOOL operator>=(const CWsbCurrency& cur) const;
  1002. //
  1003. // // Currency math
  1004. // CWsbCurrency operator+(const CWsbCurrency& cur) const;
  1005. // CWsbCurrency operator-(const CWsbCurrency& cur) const;
  1006. // const CWsbCurrency& operator+=(const CWsbCurrency& cur);
  1007. // const CWsbCurrency& operator-=(const CWsbCurrency& cur);
  1008. // CWsbCurrency operator-() const;
  1009. //
  1010. // CWsbCurrency operator*(long nOperand) const;
  1011. // CWsbCurrency operator/(long nOperand) const;
  1012. // const CWsbCurrency& operator*=(long nOperand);
  1013. // const CWsbCurrency& operator/=(long nOperand);
  1014. //
  1015. // operator CURRENCY() const;
  1016. //
  1017. // // Currency definition
  1018. // void SetCurrency(long nUnits, long nFractionalUnits);
  1019. // BOOL ParseCurrency(LPCTSTR lpszCurrency, DWORD dwFlags = 0,
  1020. // LCID = LANG_USER_DEFAULT);
  1021. //
  1022. // // formatting
  1023. // CString Format(DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT) const;
  1024. // };
  1025. //
  1026. // // CWsbCurrency diagnostics and serialization
  1027. // #ifdef _DEBUG
  1028. // CDumpContext& WSBAPI operator<<(CDumpContext& dc, CWsbCurrency curSrc);
  1029. // #endif
  1030. // CArchive& WSBAPI operator<<(CArchive& ar, CWsbCurrency curSrc);
  1031. // CArchive& WSBAPI operator>>(CArchive& ar, CWsbCurrency& curSrc);
  1032. /////////////////////////////////////////////////////////////////////////////
  1033. // CWsbDateTime class helpers
  1034. #define WSB_DATETIME_ERROR (-1)
  1035. /////////////////////////////////////////////////////////////////////////////
  1036. // CWsbDateTime class
  1037. class CWsbDateTime
  1038. {
  1039. // Constructors
  1040. public:
  1041. static CWsbDateTime PASCAL GetCurrentTime();
  1042. CWsbDateTime();
  1043. CWsbDateTime(const CWsbDateTime& dateSrc);
  1044. CWsbDateTime(const VARIANT& varSrc);
  1045. CWsbDateTime(DATE dtSrc);
  1046. CWsbDateTime(time_t timeSrc);
  1047. CWsbDateTime(const SYSTEMTIME& systimeSrc);
  1048. CWsbDateTime(const FILETIME& filetimeSrc);
  1049. CWsbDateTime(int nYear, int nMonth, int nDay,
  1050. int nHour, int nMin, int nSec);
  1051. CWsbDateTime(WORD wDosDate, WORD wDosTime);
  1052. // Attributes
  1053. public:
  1054. enum DateTimeStatus
  1055. {
  1056. valid = 0,
  1057. invalid = 1, // Invalid date (out of range, etc.)
  1058. null = 2, // Literally has no value
  1059. };
  1060. DATE m_dt;
  1061. DateTimeStatus m_status;
  1062. void SetStatus(DateTimeStatus status);
  1063. DateTimeStatus GetStatus() const;
  1064. int GetYear() const;
  1065. int GetMonth() const; // month of year (1 = Jan)
  1066. int GetDay() const; // day of month (0-31)
  1067. int GetHour() const; // hour in day (0-23)
  1068. int GetMinute() const; // minute in hour (0-59)
  1069. int GetSecond() const; // second in minute (0-59)
  1070. int GetDayOfWeek() const; // 1=Sun, 2=Mon, ..., 7=Sat
  1071. int GetDayOfYear() const; // days since start of year, Jan 1 = 1
  1072. // Operations
  1073. public:
  1074. const CWsbDateTime& operator=(const CWsbDateTime& dateSrc);
  1075. const CWsbDateTime& operator=(const VARIANT& varSrc);
  1076. const CWsbDateTime& operator=(DATE dtSrc);
  1077. const CWsbDateTime& operator=(const time_t& timeSrc);
  1078. const CWsbDateTime& operator=(const SYSTEMTIME& systimeSrc);
  1079. const CWsbDateTime& operator=(const FILETIME& filetimeSrc);
  1080. BOOL operator==(const CWsbDateTime& date) const;
  1081. BOOL operator!=(const CWsbDateTime& date) const;
  1082. BOOL operator<(const CWsbDateTime& date) const;
  1083. BOOL operator>(const CWsbDateTime& date) const;
  1084. BOOL operator<=(const CWsbDateTime& date) const;
  1085. BOOL operator>=(const CWsbDateTime& date) const;
  1086. // DateTime math
  1087. CWsbDateTime operator+(const CWsbDateTimeSpan& dateSpan) const;
  1088. CWsbDateTime operator-(const CWsbDateTimeSpan& dateSpan) const;
  1089. const CWsbDateTime& operator+=(const CWsbDateTimeSpan dateSpan);
  1090. const CWsbDateTime& operator-=(const CWsbDateTimeSpan dateSpan);
  1091. // DateTimeSpan math
  1092. CWsbDateTimeSpan operator-(const CWsbDateTime& date) const;
  1093. operator DATE() const;
  1094. BOOL SetDateTime(int nYear, int nMonth, int nDay,
  1095. int nHour, int nMin, int nSec);
  1096. BOOL SetDate(int nYear, int nMonth, int nDay);
  1097. BOOL SetTime(int nHour, int nMin, int nSec);
  1098. // BOOL ParseDateTime(LPCTSTR lpszDate, DWORD dwFlags = 0,
  1099. // LCID lcid = LANG_USER_DEFAULT);
  1100. // formatting
  1101. // CString Format(DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT) const;
  1102. // CString Format(LPCTSTR lpszFormat) const;
  1103. // CString Format(UINT nFormatID) const;
  1104. // Implementation
  1105. protected:
  1106. void CheckRange();
  1107. friend CWsbDateTimeSpan;
  1108. };
  1109. // CWsbDateTime diagnostics and serialization
  1110. // #ifdef _DEBUG
  1111. // CDumpContext& WSBAPI operator<<(CDumpContext& dc, CWsbDateTime dateSrc);
  1112. // #endif
  1113. // CArchive& WSBAPI operator<<(CArchive& ar, CWsbDateTime dateSrc);
  1114. // CArchive& WSBAPI operator>>(CArchive& ar, CWsbDateTime& dateSrc);
  1115. /////////////////////////////////////////////////////////////////////////////
  1116. // CWsbDateTimeSpan class
  1117. class CWsbDateTimeSpan
  1118. {
  1119. // Constructors
  1120. public:
  1121. CWsbDateTimeSpan();
  1122. CWsbDateTimeSpan(double dblSpanSrc);
  1123. CWsbDateTimeSpan(const CWsbDateTimeSpan& dateSpanSrc);
  1124. CWsbDateTimeSpan(long lDays, int nHours, int nMins, int nSecs);
  1125. // Attributes
  1126. public:
  1127. enum DateTimeSpanStatus
  1128. {
  1129. valid = 0,
  1130. invalid = 1, // Invalid span (out of range, etc.)
  1131. null = 2, // Literally has no value
  1132. };
  1133. double m_span;
  1134. DateTimeSpanStatus m_status;
  1135. void SetStatus(DateTimeSpanStatus status);
  1136. DateTimeSpanStatus GetStatus() const;
  1137. double GetTotalDays() const; // span in days (about -3.65e6 to 3.65e6)
  1138. double GetTotalHours() const; // span in hours (about -8.77e7 to 8.77e6)
  1139. double GetTotalMinutes() const; // span in minutes (about -5.26e9 to 5.26e9)
  1140. double GetTotalSeconds() const; // span in seconds (about -3.16e11 to 3.16e11)
  1141. long GetDays() const; // component days in span
  1142. long GetHours() const; // component hours in span (-23 to 23)
  1143. long GetMinutes() const; // component minutes in span (-59 to 59)
  1144. long GetSeconds() const; // component seconds in span (-59 to 59)
  1145. // Operations
  1146. public:
  1147. const CWsbDateTimeSpan& operator=(double dblSpanSrc);
  1148. const CWsbDateTimeSpan& operator=(const CWsbDateTimeSpan& dateSpanSrc);
  1149. BOOL operator==(const CWsbDateTimeSpan& dateSpan) const;
  1150. BOOL operator!=(const CWsbDateTimeSpan& dateSpan) const;
  1151. BOOL operator<(const CWsbDateTimeSpan& dateSpan) const;
  1152. BOOL operator>(const CWsbDateTimeSpan& dateSpan) const;
  1153. BOOL operator<=(const CWsbDateTimeSpan& dateSpan) const;
  1154. BOOL operator>=(const CWsbDateTimeSpan& dateSpan) const;
  1155. // DateTimeSpan math
  1156. CWsbDateTimeSpan operator+(const CWsbDateTimeSpan& dateSpan) const;
  1157. CWsbDateTimeSpan operator-(const CWsbDateTimeSpan& dateSpan) const;
  1158. const CWsbDateTimeSpan& operator+=(const CWsbDateTimeSpan dateSpan);
  1159. const CWsbDateTimeSpan& operator-=(const CWsbDateTimeSpan dateSpan);
  1160. CWsbDateTimeSpan operator-() const;
  1161. operator double() const;
  1162. void SetDateTimeSpan(long lDays, int nHours, int nMins, int nSecs);
  1163. // formatting
  1164. // CString Format(LPCTSTR pFormat) const;
  1165. // CString Format(UINT nID) const;
  1166. // Implementation
  1167. public:
  1168. void CheckRange();
  1169. friend CWsbDateTime;
  1170. };
  1171. // CWsbDateTimeSpan diagnostics and serialization
  1172. // #ifdef _DEBUG
  1173. // CDumpContext& WSBAPI operator<<(CDumpContext& dc,CWsbDateTimeSpan dateSpanSrc);
  1174. // #endif
  1175. // CArchive& WSBAPI operator<<(CArchive& ar, CWsbDateTimeSpan dateSpanSrc);
  1176. // CArchive& WSBAPI operator>>(CArchive& ar, CWsbDateTimeSpan& dateSpanSrc);
  1177. /////////////////////////////////////////////////////////////////////////////
  1178. // Helper for initializing CWsbSafeArray
  1179. // void WSBAPI WsbSafeArrayInit(CWsbSafeArray* psa);
  1180. // /////////////////////////////////////////////////////////////////////////////
  1181. // // CSafeArray class
  1182. //
  1183. // typedef const SAFEARRAY* LPCSAFEARRAY;
  1184. //
  1185. // class CWsbSafeArray : public tagVARIANT
  1186. // {
  1187. // //Constructors
  1188. // public:
  1189. // CWsbSafeArray();
  1190. // CWsbSafeArray(const SAFEARRAY& saSrc, VARTYPE vtSrc);
  1191. // CWsbSafeArray(LPCSAFEARRAY pSrc, VARTYPE vtSrc);
  1192. // CWsbSafeArray(const CWsbSafeArray& saSrc);
  1193. // CWsbSafeArray(const VARIANT& varSrc);
  1194. // CWsbSafeArray(LPCVARIANT pSrc);
  1195. // CWsbSafeArray(const CWsbDVariant& varSrc);
  1196. //
  1197. // // Operations
  1198. // public:
  1199. // void Clear();
  1200. // void Attach(VARIANT& varSrc);
  1201. // VARIANT Detach();
  1202. //
  1203. // CWsbSafeArray& operator=(const CWsbSafeArray& saSrc);
  1204. // CWsbSafeArray& operator=(const VARIANT& varSrc);
  1205. // CWsbSafeArray& operator=(LPCVARIANT pSrc);
  1206. // CWsbSafeArray& operator=(const CWsbDVariant& varSrc);
  1207. //
  1208. // BOOL operator==(const SAFEARRAY& saSrc) const;
  1209. // BOOL operator==(LPCSAFEARRAY pSrc) const;
  1210. // BOOL operator==(const CWsbSafeArray& saSrc) const;
  1211. // BOOL operator==(const VARIANT& varSrc) const;
  1212. // BOOL operator==(LPCVARIANT pSrc) const;
  1213. // BOOL operator==(const CWsbDVariant& varSrc) const;
  1214. //
  1215. // operator LPVARIANT();
  1216. // operator LPCVARIANT() const;
  1217. //
  1218. // // One dim array helpers
  1219. // void CreateOneDim(VARTYPE vtSrc, DWORD dwElements,
  1220. // void* pvSrcData = NULL, long nLBound = 0);
  1221. // DWORD GetOneDimSize();
  1222. // void ResizeOneDim(DWORD dwElements);
  1223. //
  1224. // // Multi dim array helpers
  1225. // void Create(VARTYPE vtSrc, DWORD dwDims, DWORD* rgElements);
  1226. //
  1227. // // SafeArray wrapper classes
  1228. // void Create(VARTYPE vtSrc, DWORD dwDims, SAFEARRAYBOUND* rgsabounds);
  1229. // void AccessData(void** ppvData);
  1230. // void UnaccessData();
  1231. // void AllocData();
  1232. // void AllocDescriptor(DWORD dwDims);
  1233. // void Copy(LPSAFEARRAY* ppsa);
  1234. // void GetLBound(DWORD dwDim, long* pLBound);
  1235. // void GetUBound(DWORD dwDim, long* pUBound);
  1236. // void GetElement(long* rgIndices, void* pvData);
  1237. // void PtrOfIndex(long* rgIndices, void** ppvData);
  1238. // void PutElement(long* rgIndices, void* pvData);
  1239. // void Redim(SAFEARRAYBOUND* psaboundNew);
  1240. // void Lock();
  1241. // void Unlock();
  1242. // DWORD GetDim();
  1243. // DWORD GetElemSize();
  1244. // void Destroy();
  1245. // void DestroyData();
  1246. // void DestroyDescriptor();
  1247. //
  1248. // //Implementation
  1249. // public:
  1250. // ~CWsbSafeArray();
  1251. //
  1252. // // Cache info to make element access (operator []) faster
  1253. // DWORD m_dwElementSize;
  1254. // DWORD m_dwDims;
  1255. // };
  1256. //
  1257. // // CWsbSafeArray diagnostics and serialization
  1258. // #ifdef _DEBUG
  1259. // CDumpContext& WSBAPI operator<<(CDumpContext& dc, CWsbSafeArray saSrc);
  1260. // #endif
  1261. // CArchive& WSBAPI operator<<(CArchive& ar, CWsbSafeArray saSrc);
  1262. // CArchive& WSBAPI operator>>(CArchive& ar, CWsbSafeArray& saSrc);
  1263. // /////////////////////////////////////////////////////////////////////////////
  1264. // // DDX_ functions for WSB controls on dialogs
  1265. //
  1266. // #ifndef _WSB_NO_OCC_SUPPORT
  1267. //
  1268. // void WSBAPI DDX_OCText(CDataExchange* pDX, int nIDC, DISPID dispid,
  1269. // CString& value);
  1270. // void WSBAPI DDX_OCTextRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1271. // CString& value);
  1272. // void WSBAPI DDX_OCBool(CDataExchange* pDX, int nIDC, DISPID dispid,
  1273. // BOOL& value);
  1274. // void WSBAPI DDX_OCBoolRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1275. // BOOL& value);
  1276. // void WSBAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  1277. // int &value);
  1278. // void WSBAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1279. // int &value);
  1280. // void WSBAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  1281. // long &value);
  1282. // void WSBAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1283. // long &value);
  1284. // void WSBAPI DDX_OCShort(CDataExchange* pDX, int nIDC, DISPID dispid,
  1285. // short& value);
  1286. // void WSBAPI DDX_OCShortRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1287. // short& value);
  1288. // void WSBAPI DDX_OCColor(CDataExchange* pDX, int nIDC, DISPID dispid,
  1289. // WSB_COLOR& value);
  1290. // void WSBAPI DDX_OCColorRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1291. // WSB_COLOR& value);
  1292. // void WSBAPI DDX_OCFloat(CDataExchange* pDX, int nIDC, DISPID dispid,
  1293. // float& value);
  1294. // void WSBAPI DDX_OCFloatRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1295. // float& value);
  1296. // void WSBAPI DDX_OCFloat(CDataExchange* pDX, int nIDC, DISPID dispid,
  1297. // double& value);
  1298. // void WSBAPI DDX_OCFloatRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1299. // double& value);
  1300. //
  1301. // #endif // !_WSB_NO_OCC_SUPPORT
  1302. //
  1303. // /////////////////////////////////////////////////////////////////////////////
  1304. // // Function to enable containment of WSB controls
  1305. //
  1306. // #ifndef _WSB_NO_OCC_SUPPORT
  1307. // void WSB_CDECL WsbEnableControlContainer(COccManager* pOccManager=NULL);
  1308. // #else
  1309. // #define WsbEnableControlContainer()
  1310. // #endif
  1311. //
  1312. // /////////////////////////////////////////////////////////////////////////////
  1313. // // Inline function declarations
  1314. //
  1315. // #ifdef _WSB_PACKING
  1316. // #pragma pack(pop)
  1317. // #endif
  1318. //
  1319. // #ifdef _WSB_ENABLE_INLINES
  1320. // #define _WSBDATE_INLINE inline
  1321. // #include <afxole.inl>
  1322. // #undef _WSBDATE_INLINE
  1323. // #endif
  1324. //
  1325. // #undef WSB_DATA
  1326. // #define WSB_DATA
  1327. //
  1328. // #ifdef _WSB_MINREBUILD
  1329. // #pragma component(minrebuild, on)
  1330. // #endif
  1331. // #ifndef _WSB_FULLTYPEINFO
  1332. // #pragma component(mintypeinfo, off)
  1333. // #endif
  1334. //
  1335. //
  1336. // Low level sanity checks for memory blocks
  1337. //
  1338. // this was copied from afx.h
  1339. BOOL WSBAPI WsbIsValidAddress(const void* lp,
  1340. UINT nBytes, BOOL bReadWrite = TRUE);
  1341. //
  1342. // Inline Functions
  1343. //
  1344. // These were copied from afxole.inl
  1345. //
  1346. #define _WSBDISP_INLINE inline
  1347. // CWsbDVariant
  1348. _WSBDISP_INLINE CWsbDVariant::CWsbDVariant()
  1349. { WsbDVariantInit(this); }
  1350. _WSBDISP_INLINE CWsbDVariant::~CWsbDVariant()
  1351. { ::VariantClear(this); }
  1352. _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(LPCTSTR lpszSrc)
  1353. { vt = VT_EMPTY; *this = lpszSrc; }
  1354. // _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(CString& strSrc)
  1355. // { vt = VT_EMPTY; *this = strSrc; }
  1356. // _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(BYTE nSrc)
  1357. // { vt = VT_UI1; bVal = nSrc; }
  1358. // _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(const CWsbCurrency& curSrc)
  1359. // { vt = VT_CY; cyVal = curSrc.m_cur; }
  1360. _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(float fltSrc)
  1361. { vt = VT_R4; fltVal = fltSrc; }
  1362. _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(double dblSrc)
  1363. { vt = VT_R8; dblVal = dblSrc; }
  1364. _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(const CWsbDateTime& dateSrc)
  1365. { vt = VT_DATE; date = dateSrc.m_dt; }
  1366. // _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(const CByteArray& arrSrc)
  1367. // { vt = VT_EMPTY; *this = arrSrc; }
  1368. // _WSBDISP_INLINE CWsbDVariant::CWsbDVariant(const CLongBinary& lbSrc)
  1369. // { vt = VT_EMPTY; *this = lbSrc; }
  1370. _WSBDISP_INLINE BOOL CWsbDVariant::operator==(LPCVARIANT pSrc) const
  1371. { return *this == *pSrc; }
  1372. _WSBDISP_INLINE CWsbDVariant::operator LPVARIANT()
  1373. { return this; }
  1374. _WSBDISP_INLINE CWsbDVariant::operator LPCVARIANT() const
  1375. { return this; }
  1376. // CWsbDateTime
  1377. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime()
  1378. { m_dt = 0; SetStatus(valid); }
  1379. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(const CWsbDateTime& dateSrc)
  1380. { m_dt = dateSrc.m_dt; m_status = dateSrc.m_status; }
  1381. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(const VARIANT& varSrc)
  1382. { *this = varSrc; }
  1383. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(DATE dtSrc)
  1384. { m_dt = dtSrc; SetStatus(valid); }
  1385. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(time_t timeSrc)
  1386. { *this = timeSrc; }
  1387. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(const SYSTEMTIME& systimeSrc)
  1388. { *this = systimeSrc; }
  1389. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(const FILETIME& filetimeSrc)
  1390. { *this = filetimeSrc; }
  1391. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(int nYear, int nMonth, int nDay,
  1392. int nHour, int nMin, int nSec)
  1393. { SetDateTime(nYear, nMonth, nDay, nHour, nMin, nSec); }
  1394. _WSBDISP_INLINE CWsbDateTime::CWsbDateTime(WORD wDosDate, WORD wDosTime)
  1395. { m_status = DosDateTimeToVariantTime(wDosDate, wDosTime, &m_dt) ?
  1396. valid : invalid; }
  1397. _WSBDISP_INLINE const CWsbDateTime& CWsbDateTime::operator=(const CWsbDateTime& dateSrc)
  1398. { m_dt = dateSrc.m_dt; m_status = dateSrc.m_status; return *this; }
  1399. _WSBDISP_INLINE CWsbDateTime::DateTimeStatus CWsbDateTime::GetStatus() const
  1400. { return m_status; }
  1401. _WSBDISP_INLINE void CWsbDateTime::SetStatus(DateTimeStatus status)
  1402. { m_status = status; }
  1403. _WSBDISP_INLINE BOOL CWsbDateTime::operator==(const CWsbDateTime& date) const
  1404. { return (m_status == date.m_status && m_dt == date.m_dt); }
  1405. _WSBDISP_INLINE BOOL CWsbDateTime::operator!=(const CWsbDateTime& date) const
  1406. { return (m_status != date.m_status || m_dt != date.m_dt); }
  1407. _WSBDISP_INLINE const CWsbDateTime& CWsbDateTime::operator+=(
  1408. const CWsbDateTimeSpan dateSpan)
  1409. { *this = *this + dateSpan; return *this; }
  1410. _WSBDISP_INLINE const CWsbDateTime& CWsbDateTime::operator-=(
  1411. const CWsbDateTimeSpan dateSpan)
  1412. { *this = *this - dateSpan; return *this; }
  1413. _WSBDISP_INLINE CWsbDateTime::operator DATE() const
  1414. { return m_dt; }
  1415. _WSBDISP_INLINE CWsbDateTime::SetDate(int nYear, int nMonth, int nDay)
  1416. { return SetDateTime(nYear, nMonth, nDay, 0, 0, 0); }
  1417. _WSBDISP_INLINE CWsbDateTime::SetTime(int nHour, int nMin, int nSec)
  1418. // Set date to zero date - 12/30/1899
  1419. { return SetDateTime(1899, 12, 30, nHour, nMin, nSec); }
  1420. // CWsbDateTimeSpan
  1421. _WSBDISP_INLINE CWsbDateTimeSpan::CWsbDateTimeSpan()
  1422. { m_span = 0; SetStatus(valid); }
  1423. _WSBDISP_INLINE CWsbDateTimeSpan::CWsbDateTimeSpan(double dblSpanSrc)
  1424. { m_span = dblSpanSrc; SetStatus(valid); }
  1425. _WSBDISP_INLINE CWsbDateTimeSpan::CWsbDateTimeSpan(
  1426. const CWsbDateTimeSpan& dateSpanSrc)
  1427. { m_span = dateSpanSrc.m_span; m_status = dateSpanSrc.m_status; }
  1428. _WSBDISP_INLINE CWsbDateTimeSpan::CWsbDateTimeSpan(
  1429. long lDays, int nHours, int nMins, int nSecs)
  1430. { SetDateTimeSpan(lDays, nHours, nMins, nSecs); }
  1431. _WSBDISP_INLINE CWsbDateTimeSpan::DateTimeSpanStatus CWsbDateTimeSpan::GetStatus() const
  1432. { return m_status; }
  1433. _WSBDISP_INLINE void CWsbDateTimeSpan::SetStatus(DateTimeSpanStatus status)
  1434. { m_status = status; }
  1435. _WSBDISP_INLINE double CWsbDateTimeSpan::GetTotalDays() const
  1436. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA); return m_span; }
  1437. _WSBDISP_INLINE double CWsbDateTimeSpan::GetTotalHours() const
  1438. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA); return m_span * 24; }
  1439. _WSBDISP_INLINE double CWsbDateTimeSpan::GetTotalMinutes() const
  1440. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA); return m_span * 24 * 60; }
  1441. _WSBDISP_INLINE double CWsbDateTimeSpan::GetTotalSeconds() const
  1442. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA); return m_span * 24 * 60 * 60; }
  1443. _WSBDISP_INLINE long CWsbDateTimeSpan::GetDays() const
  1444. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA); return (long)m_span; }
  1445. _WSBDISP_INLINE BOOL CWsbDateTimeSpan::operator==(
  1446. const CWsbDateTimeSpan& dateSpan) const
  1447. { return (m_status == dateSpan.m_status &&
  1448. m_span == dateSpan.m_span); }
  1449. _WSBDISP_INLINE BOOL CWsbDateTimeSpan::operator!=(
  1450. const CWsbDateTimeSpan& dateSpan) const
  1451. { return (m_status != dateSpan.m_status ||
  1452. m_span != dateSpan.m_span); }
  1453. _WSBDISP_INLINE BOOL CWsbDateTimeSpan::operator<(
  1454. const CWsbDateTimeSpan& dateSpan) const
  1455. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA);
  1456. WsbAssert(dateSpan.GetStatus() == valid, WSB_E_INVALID_DATA);
  1457. return m_span < dateSpan.m_span; }
  1458. _WSBDISP_INLINE BOOL CWsbDateTimeSpan::operator>(
  1459. const CWsbDateTimeSpan& dateSpan) const
  1460. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA);
  1461. WsbAssert(dateSpan.GetStatus() == valid, WSB_E_INVALID_DATA);
  1462. return m_span > dateSpan.m_span; }
  1463. _WSBDISP_INLINE BOOL CWsbDateTimeSpan::operator<=(
  1464. const CWsbDateTimeSpan& dateSpan) const
  1465. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA);
  1466. WsbAssert(dateSpan.GetStatus() == valid, WSB_E_INVALID_DATA);
  1467. return m_span <= dateSpan.m_span; }
  1468. _WSBDISP_INLINE BOOL CWsbDateTimeSpan::operator>=(
  1469. const CWsbDateTimeSpan& dateSpan) const
  1470. { WsbAssert(GetStatus() == valid, WSB_E_INVALID_DATA);
  1471. WsbAssert(dateSpan.GetStatus() == valid, WSB_E_INVALID_DATA);
  1472. return m_span >= dateSpan.m_span; }
  1473. _WSBDISP_INLINE const CWsbDateTimeSpan& CWsbDateTimeSpan::operator+=(
  1474. const CWsbDateTimeSpan dateSpan)
  1475. { *this = *this + dateSpan; return *this; }
  1476. _WSBDISP_INLINE const CWsbDateTimeSpan& CWsbDateTimeSpan::operator-=(
  1477. const CWsbDateTimeSpan dateSpan)
  1478. { *this = *this - dateSpan; return *this; }
  1479. _WSBDISP_INLINE CWsbDateTimeSpan CWsbDateTimeSpan::operator-() const
  1480. { return -this->m_span; }
  1481. _WSBDISP_INLINE CWsbDateTimeSpan::operator double() const
  1482. { return m_span; }
  1483. #undef _WSBDISP_INLINE
  1484. #endif //__WSBDATE_H__
  1485. /////////////////////////////////////////////////////////////////////////////