Source code of Windows XP (NT5)
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.

921 lines
20 KiB

  1. // property.h : Declaration of the CMetaPropertySet
  2. #ifndef __PROPERTY_H_
  3. #define __PROPERTY_H_
  4. #define IID_ANY_BSTR 0
  5. #include "resource.h" // main symbols
  6. #include "guidedb.h"
  7. class CMetaPropertySet;
  8. class CMetaPropertySets;
  9. class CMetaPropertyType;
  10. class CMetaPropertyTypes;
  11. class CMetaProperty;
  12. class CMetaProperties;
  13. class CMetaPropertyCond;
  14. class CMetaPropertyCond1Cond;
  15. class CMetaPropertyCond2Cond;
  16. class CMetaPropertyCondLT;
  17. class CMetaPropertyCondLE;
  18. class CMetaPropertyCondEQ;
  19. class CMetaPropertyCondGE;
  20. class CMetaPropertyCondGT;
  21. #include "stdprop.h"
  22. HRESULT SeekPropsRS(ADODB::_RecordsetPtr prs, boolean fSQLServer, long idObj, long idPropType, boolean fAnyProvider, long idProvider, long idLang);
  23. enum PersistFormat { Format_IPersistStream = 0, Format_IPersistPropertyBag };
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CMetaPropertySet
  26. class ATL_NO_VTABLE CMetaPropertySet :
  27. public CComObjectRootEx<CComObjectThreadModel>,
  28. public CComCoClass<CMetaPropertySet, &CLSID_MetaPropertySet>,
  29. public IDispatchImpl<IMetaPropertySet, &IID_IMetaPropertySet, &LIBID_GUIDESTORELib>
  30. {
  31. public:
  32. CMetaPropertySet()
  33. {
  34. #if defined(_ATL_FREE_THREADED)
  35. m_pUnkMarshaler = NULL;
  36. #endif
  37. m_pproptypes = NULL;
  38. }
  39. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTYSET)
  40. DECLARE_GET_CONTROLLING_UNKNOWN()
  41. #if defined(_ATL_FREE_THREADED)
  42. DECLARE_PROTECT_FINAL_CONSTRUCT()
  43. #endif
  44. BEGIN_COM_MAP(CMetaPropertySet)
  45. COM_INTERFACE_ENTRY(IMetaPropertySet)
  46. COM_INTERFACE_ENTRY(IDispatch)
  47. #if defined(_ATL_FREE_THREADED)
  48. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  49. #endif
  50. END_COM_MAP()
  51. #if defined(_ATL_FREE_THREADED)
  52. HRESULT FinalConstruct()
  53. {
  54. return CoCreateFreeThreadedMarshaler(
  55. GetControllingUnknown(), &m_pUnkMarshaler.p);
  56. }
  57. void FinalRelease()
  58. {
  59. m_pUnkMarshaler.Release();
  60. }
  61. CComPtr<IUnknown> m_pUnkMarshaler;
  62. #endif
  63. bool CreatePropTypes();
  64. void Init(CGuideDB *pdb, long id, BSTR bstrName)
  65. {
  66. m_pdb = pdb;
  67. m_id = id;
  68. m_bstrName = bstrName;
  69. }
  70. HRESULT Load();
  71. // IMetaPropertySet
  72. public:
  73. STDMETHOD(get_MetaPropertyTypes)(/*[out, retval]*/ IMetaPropertyTypes* *ppproptypes);
  74. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pbstrName);
  75. long GetID()
  76. {
  77. return m_id;
  78. }
  79. protected:
  80. CComPtr<CGuideDB> m_pdb;
  81. long m_id;
  82. _bstr_t m_bstrName;
  83. CComPtr<CMetaPropertyTypes> m_pproptypes;
  84. };
  85. // property.h : Declaration of the CMetaPropertySets
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CMetaPropertySets
  88. class ATL_NO_VTABLE CMetaPropertySets :
  89. public CComObjectRootEx<CComObjectThreadModel>,
  90. public CComCoClass<CMetaPropertySets, &CLSID_MetaPropertySets>,
  91. public IDispatchImpl<IMetaPropertySets, &IID_IMetaPropertySets, &LIBID_GUIDESTORELib>
  92. {
  93. public:
  94. CMetaPropertySets()
  95. {
  96. #if defined(_ATL_FREE_THREADED)
  97. m_pUnkMarshaler = NULL;
  98. #endif
  99. }
  100. HRESULT Init(CGuideDB *pdb)
  101. {
  102. m_pdb = pdb;
  103. return S_OK;
  104. }
  105. HRESULT Load();
  106. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTYSETS)
  107. DECLARE_GET_CONTROLLING_UNKNOWN()
  108. DECLARE_PROTECT_FINAL_CONSTRUCT()
  109. BEGIN_COM_MAP(CMetaPropertySets)
  110. COM_INTERFACE_ENTRY(IMetaPropertySets)
  111. COM_INTERFACE_ENTRY(IDispatch)
  112. #if defined(_ATL_FREE_THREADED)
  113. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  114. #endif
  115. END_COM_MAP()
  116. #if defined(_ATL_FREE_THREADED)
  117. HRESULT FinalConstruct()
  118. {
  119. return CoCreateFreeThreadedMarshaler(
  120. GetControllingUnknown(), &m_pUnkMarshaler.p);
  121. }
  122. void FinalRelease()
  123. {
  124. m_pUnkMarshaler.Release();
  125. }
  126. CComPtr<IUnknown> m_pUnkMarshaler;
  127. #endif
  128. HRESULT Cache(long id, BSTR bstrName, CMetaPropertySet **pppropset);
  129. public:
  130. // IMetaPropertySets
  131. STDMETHOD(get_Lookup)(BSTR bstrName, IMetaPropertyType **ppproptype);
  132. STDMETHOD(get_AddNew)(BSTR bstrName, /*[out, retval]*/ IMetaPropertySet **pppropset);
  133. STDMETHOD(get_ItemWithName)(BSTR bstrName, /*[out, retval]*/ IMetaPropertySet* *ppropset);
  134. STDMETHOD(get_Item)(VARIANT index, /*[out, retval]*/ IMetaPropertySet* *ppropset);
  135. STDMETHOD(get_Count)(/*[out, retval]*/ long *plCount);
  136. #ifdef IMPLEMENT_NewEnum
  137. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  138. {
  139. ENTER_API
  140. {
  141. ValidateOutPtr<IUnknown>(ppunk);
  142. return E_NOTIMPL;
  143. }
  144. LEAVE_API
  145. }
  146. #endif
  147. protected:
  148. CComPtr<CGuideDB> m_pdb;
  149. typedef map<BSTR, CMetaPropertySet *, BSTRCmpLess> t_map;
  150. t_map m_map;
  151. };
  152. // property.h : Declaration of the CMetaPropertyType
  153. /////////////////////////////////////////////////////////////////////////////
  154. // CMetaPropertyType
  155. class DECLSPEC_UUID("67CA8AB9-0A0E-43A8-B9B5-D4D10889A9E6") ATL_NO_VTABLE CMetaPropertyType :
  156. public CComObjectRootEx<CComObjectThreadModel>,
  157. public CComCoClass<CMetaPropertyType, &CLSID_MetaPropertyType>,
  158. public IDispatchImpl<IMetaPropertyType, &IID_IMetaPropertyType, &LIBID_GUIDESTORELib>
  159. {
  160. public:
  161. CMetaPropertyType()
  162. {
  163. #if defined(_ATL_FREE_THREADED)
  164. m_pUnkMarshaler = NULL;
  165. #endif
  166. }
  167. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTYTYPE)
  168. DECLARE_GET_CONTROLLING_UNKNOWN()
  169. #if defined(_ATL_FREE_THREADED)
  170. DECLARE_PROTECT_FINAL_CONSTRUCT()
  171. #endif
  172. BEGIN_COM_MAP(CMetaPropertyType)
  173. COM_INTERFACE_ENTRY(IMetaPropertyType)
  174. COM_INTERFACE_ENTRY(CMetaPropertyType)
  175. COM_INTERFACE_ENTRY(IDispatch)
  176. #if defined(_ATL_FREE_THREADED)
  177. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  178. #endif
  179. END_COM_MAP()
  180. #if defined(_ATL_FREE_THREADED)
  181. HRESULT FinalConstruct()
  182. {
  183. return CoCreateFreeThreadedMarshaler(
  184. GetControllingUnknown(), &m_pUnkMarshaler.p);
  185. }
  186. void FinalRelease()
  187. {
  188. m_pUnkMarshaler.Release();
  189. }
  190. CComPtr<IUnknown> m_pUnkMarshaler;
  191. #endif
  192. void Init(CGuideDB *pdb, CMetaPropertySet *ppropset, long id, long idPropType,
  193. BSTR bstrName)
  194. {
  195. m_pdb = pdb;
  196. m_ppropset = ppropset;
  197. m_id = id;
  198. m_idPropType = idPropType;
  199. m_bstrName = bstrName;
  200. }
  201. public:
  202. long GetID()
  203. {
  204. return m_id;
  205. }
  206. STDMETHOD(GetNew)(long idProvider, long lang, VARIANT val, /*[out, retval]*/ IMetaProperty* *ppprop);
  207. // IMetaPropertyType
  208. STDMETHOD(get_Cond)(BSTR bstrCond, long lang, VARIANT varValue, /*[out, retval]*/ IMetaPropertyCondition* *ppropcond);
  209. STDMETHOD(get_New)(long lang, VARIANT val, /*[out, retval]*/ IMetaProperty* *ppprop)
  210. {
  211. return GetNew(m_pdb->GetIDGuideDataProvider(), lang, val, ppprop);
  212. }
  213. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
  214. STDMETHOD(get_ID)(/*[out, retval]*/ long *pVal);
  215. STDMETHOD(get_MetaPropertySet)(/*[out, retval]*/ IMetaPropertySet* *ppropset);
  216. //UNDONE: shouldn't be public.
  217. CComPtr<CGuideDB> m_pdb;
  218. protected:
  219. CComPtr<CMetaPropertySet> m_ppropset;
  220. long m_id;
  221. long m_idPropType;
  222. _bstr_t m_bstrName;
  223. };
  224. // property.h : Declaration of the CMetaPropertyTypes
  225. /////////////////////////////////////////////////////////////////////////////
  226. // CMetaPropertyTypes
  227. class ATL_NO_VTABLE CMetaPropertyTypes :
  228. public CComObjectRootEx<CComObjectThreadModel>,
  229. public CComCoClass<CMetaPropertyTypes, &CLSID_MetaPropertyTypes>,
  230. public IDispatchImpl<IMetaPropertyTypes, &IID_IMetaPropertyTypes, &LIBID_GUIDESTORELib>
  231. {
  232. public:
  233. CMetaPropertyTypes()
  234. {
  235. #if defined(_ATL_FREE_THREADED)
  236. m_pUnkMarshaler = NULL;
  237. #endif
  238. }
  239. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTYTYPES)
  240. DECLARE_GET_CONTROLLING_UNKNOWN()
  241. #if defined(_ATL_FREE_THREADED)
  242. DECLARE_PROTECT_FINAL_CONSTRUCT()
  243. #endif
  244. BEGIN_COM_MAP(CMetaPropertyTypes)
  245. COM_INTERFACE_ENTRY(IMetaPropertyTypes)
  246. COM_INTERFACE_ENTRY(IDispatch)
  247. #if defined(_ATL_FREE_THREADED)
  248. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  249. #endif
  250. END_COM_MAP()
  251. #if defined(_ATL_FREE_THREADED)
  252. HRESULT FinalConstruct()
  253. {
  254. return CoCreateFreeThreadedMarshaler(
  255. GetControllingUnknown(), &m_pUnkMarshaler.p);
  256. }
  257. void FinalRelease()
  258. {
  259. m_pUnkMarshaler.Release();
  260. }
  261. CComPtr<IUnknown> m_pUnkMarshaler;
  262. #endif
  263. void Init(CGuideDB *pdb, CMetaPropertySet *ppropset)
  264. {
  265. m_pdb = pdb;
  266. m_ppropset = ppropset;
  267. }
  268. HRESULT Cache(long id, long idPropType, BSTR bstName, CMetaPropertyType **ppproptype);
  269. // IMetaPropertyTypes
  270. public:
  271. STDMETHOD(get_MetaPropertySet)(/*[out, retval]*/ IMetaPropertySet * *pVal);
  272. STDMETHOD(get_AddNew)(long id, BSTR bstrName, /*[out, retval]*/ IMetaPropertyType * *pVal);
  273. STDMETHOD(get_ItemWithName)(BSTR bstrName, /*[out, retval]*/ IMetaPropertyType* *pproptype);
  274. STDMETHOD(get_ItemWithID)(long id, /*[out, retval]*/ IMetaPropertyType* *pproptype);
  275. STDMETHOD(get_Item)(VARIANT index, /*[out, retval]*/ IMetaPropertyType* *pproptype);
  276. STDMETHOD(get_Count)(/*[out, retval]*/ long *pVal);
  277. #ifdef IMPLEMENT_NewEnum
  278. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  279. {
  280. ENTER_API
  281. {
  282. ValidateOutPtr<IUnknown>(ppunk);
  283. return E_NOTIMPL;
  284. }
  285. LEAVE_API
  286. }
  287. #endif
  288. protected:
  289. CComPtr<CGuideDB> m_pdb;
  290. CComPtr<CMetaPropertySet> m_ppropset;
  291. typedef map<BSTR, CMetaPropertyType *, BSTRCmpLess> t_map;
  292. t_map m_map;
  293. };
  294. /////////////////////////////////////////////////////////////////////////////
  295. // CMetaProperty
  296. class DECLSPEC_UUID("f23d3b6d-c2a2-4a23-8f54-64cf97c4b6d5") ATL_NO_VTABLE CMetaProperty :
  297. public CComObjectRootEx<CComObjectThreadModel>,
  298. public CComCoClass<CMetaProperty, &CLSID_MetaProperty>,
  299. public IDispatchImpl<IMetaProperty, &IID_IMetaProperty, &LIBID_GUIDESTORELib>
  300. {
  301. public:
  302. CMetaProperty()
  303. {
  304. #if defined(_ATL_FREE_THREADED)
  305. m_pUnkMarshaler = NULL;
  306. #endif
  307. m_idObj = 0;
  308. m_idProvider = 0;
  309. m_idPropType = 0;
  310. m_idLang = 0;
  311. }
  312. void Init(CGuideDB *pdb, long idPropType, long idProvider, long idLang, VARIANT varValue)
  313. {
  314. m_pdb = pdb;
  315. m_idPropType = idPropType;
  316. m_idProvider = idProvider;
  317. m_idLang = idLang;
  318. m_varValue = varValue;
  319. }
  320. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTY)
  321. DECLARE_GET_CONTROLLING_UNKNOWN()
  322. DECLARE_PROTECT_FINAL_CONSTRUCT()
  323. BEGIN_COM_MAP(CMetaProperty)
  324. COM_INTERFACE_ENTRY(IMetaProperty)
  325. COM_INTERFACE_ENTRY(CMetaProperty)
  326. COM_INTERFACE_ENTRY(IDispatch)
  327. COM_INTERFACE_ENTRY_IID(CLSID_MetaProperty, CMetaProperty)
  328. #if defined(_ATL_FREE_THREADED)
  329. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  330. #endif
  331. END_COM_MAP()
  332. #if defined(_ATL_FREE_THREADED)
  333. HRESULT FinalConstruct()
  334. {
  335. return CoCreateFreeThreadedMarshaler(
  336. GetControllingUnknown(), &m_pUnkMarshaler.p);
  337. }
  338. void FinalRelease()
  339. {
  340. m_pUnkMarshaler.Release();
  341. }
  342. CComPtr<IUnknown> m_pUnkMarshaler;
  343. #endif
  344. HRESULT AddNew(ADODB::_RecordsetPtr prs);
  345. HRESULT SaveValue(ADODB::_RecordsetPtr prs);
  346. HRESULT LoadValue(ADODB::_RecordsetPtr prs);
  347. long GetObjectID()
  348. {
  349. return m_idObj;
  350. }
  351. HRESULT SetObjectID(long idObj)
  352. {
  353. if (m_idObj != 0)
  354. return E_INVALIDARG;
  355. m_idObj = idObj;
  356. return S_OK;
  357. }
  358. STDMETHOD(PutValue)(/*[in]*/ VARIANT varValue);
  359. public:
  360. STDMETHOD(get_QueryClause)(long &i, TCHAR *szOp, _bstr_t *pbstr);
  361. // IMetaProperty
  362. STDMETHOD(get_Cond)(BSTR bstrCond, /*[out, retval]*/ IMetaPropertyCondition* *ppropcond);
  363. STDMETHOD(get_Value)(/*[out, retval]*/ VARIANT *pvarValue);
  364. STDMETHOD(put_Value)(/*[in]*/ VARIANT varValue);
  365. STDMETHOD(putref_Value)(/*[in]*/ IUnknown *punk)
  366. {
  367. VARIANT var;
  368. var.vt = VT_UNKNOWN | VT_BYREF;
  369. var.ppunkVal = &punk;
  370. return put_Value(var);
  371. }
  372. STDMETHOD(get_GuideDataProvider)(/*[out, retval]*/ IGuideDataProvider **ppprovider)
  373. {
  374. ENTER_API
  375. {
  376. ValidateOutPtr<IGuideDataProvider>(ppprovider, NULL);
  377. HRESULT hr;
  378. if (m_idProvider == NULL)
  379. return S_OK;
  380. CComPtr<IObjects> pobjs;
  381. hr = m_pdb->get_ObjectsWithType(__uuidof(GuideDataProvider), &pobjs);
  382. if (FAILED(hr))
  383. return hr;
  384. CComPtr<IUnknown> punk;
  385. hr = pobjs->get_ItemWithID(m_idProvider, &punk);
  386. if (FAILED(hr))
  387. return hr;
  388. return punk->QueryInterface(__uuidof(IGuideDataProvider), (void **) ppprovider);
  389. }
  390. LEAVE_API
  391. }
  392. STDMETHOD(get_Language)(/*[out, retval]*/ long *pidLang);
  393. STDMETHOD(get_MetaPropertyType)(/*[out, retval]*/ IMetaPropertyType* *pproptype);
  394. protected:
  395. CComPtr<CGuideDB> m_pdb;
  396. long m_idObj;
  397. long m_idPropType;
  398. long m_idProvider;
  399. long m_idLang;
  400. _variant_t m_varValue;
  401. };
  402. /////////////////////////////////////////////////////////////////////////////
  403. // CMetaProperties
  404. class ATL_NO_VTABLE DECLSPEC_UUID("ec6b3b45-5f2c-4c2e-891e-bb1f504b481e") CMetaProperties :
  405. public CComObjectRootEx<CComObjectThreadModel>,
  406. public CComCoClass<CMetaProperties, &CLSID_MetaProperties>,
  407. public IDispatchImpl<IMetaProperties, &IID_IMetaProperties, &LIBID_GUIDESTORELib>
  408. {
  409. public:
  410. CMetaProperties()
  411. {
  412. #if defined(_ATL_FREE_THREADED)
  413. m_pUnkMarshaler = NULL;
  414. #endif
  415. }
  416. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTIES)
  417. DECLARE_GET_CONTROLLING_UNKNOWN()
  418. #if defined(_ATL_FREE_THREADED)
  419. DECLARE_PROTECT_FINAL_CONSTRUCT()
  420. #endif
  421. BEGIN_COM_MAP(CMetaProperties)
  422. COM_INTERFACE_ENTRY(IMetaProperties)
  423. COM_INTERFACE_ENTRY(CMetaProperties)
  424. COM_INTERFACE_ENTRY(IDispatch)
  425. #if defined(_ATL_FREE_THREADED)
  426. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  427. #endif
  428. END_COM_MAP()
  429. #if defined(_ATL_FREE_THREADED)
  430. HRESULT FinalConstruct()
  431. {
  432. return CoCreateFreeThreadedMarshaler(
  433. GetControllingUnknown(), &m_pUnkMarshaler.p);
  434. }
  435. void FinalRelease()
  436. {
  437. m_pUnkMarshaler.Release();
  438. }
  439. CComPtr<IUnknown> m_pUnkMarshaler;
  440. #endif
  441. HRESULT Init(long idObj, long idPropType, CGuideDB *pdb)
  442. {
  443. m_idObj = idObj;
  444. m_idPropType = idPropType;
  445. m_pdb = pdb;
  446. return S_OK;
  447. }
  448. HRESULT Load(long idPropType, ADODB::_RecordsetPtr prs, IMetaProperty **ppprop);
  449. HRESULT get_AddNew(IMetaPropertyType *pproptype, IGuideDataProvider *pprovider,
  450. long lang, VARIANT varValue, /*[out, retval]*/ IMetaProperty * *pVal);
  451. HRESULT get_ItemWithTypeProviderLang(IMetaPropertyType *ptype,
  452. boolean fAnyProvider, long idProvider, long lang,
  453. /*[out, retval]*/ IMetaProperty* *pprop);
  454. // IMetaProperties
  455. public:
  456. STDMETHOD(Add)(IMetaProperty *pprop);
  457. STDMETHOD(get_AddNew)(IMetaPropertyType *pproptype, long lang, VARIANT varValue, /*[out, retval]*/ IMetaProperty * *pVal);
  458. STDMETHOD(get_ItemsWithMetaPropertyType)(IMetaPropertyType *ptype, /*[out, retval]*/ IMetaProperties* *pprops);
  459. STDMETHOD(get_ItemWith)(IMetaPropertyType *ptype, long lang, /*[out, retval]*/ IMetaProperty* *pprop);
  460. STDMETHOD(get_ItemWithTypeProviderLang)(IMetaPropertyType *ptype, IGuideDataProvider *pprovider, long lang, /*[out, retval]*/ IMetaProperty* *pprop);
  461. STDMETHOD(get_Item)(VARIANT index, /*[out, retval]*/ IMetaProperty* *pprop);
  462. STDMETHOD(get_Count)(/*[out, retval]*/ long *pVal);
  463. #ifdef IMPLEMENT_NewEnum
  464. STDMETHOD(get__NewEnum)(IUnknown **ppunk)
  465. {
  466. ENTER_API
  467. {
  468. ValidateOutPtr<IUnknown>(ppunk);
  469. return E_NOTIMPL;
  470. }
  471. LEAVE_API
  472. }
  473. #endif
  474. protected:
  475. CComPtr<CGuideDB> m_pdb;
  476. long m_idObj;
  477. long m_idPropType;
  478. };
  479. /////////////////////////////////////////////////////////////////////////////
  480. // CMetaPropertyCondition
  481. class ATL_NO_VTABLE DECLSPEC_UUID("ec5b84b5-eee5-45a2-88d1-415d21fe7aca") CMetaPropertyCondition :
  482. public CComObjectRootEx<CComObjectThreadModel>,
  483. public CComCoClass<CMetaPropertyCondition, &CLSID_MetaPropertyCondition>,
  484. public IDispatchImpl<IMetaPropertyCondition, &IID_IMetaPropertyCondition, &LIBID_GUIDESTORELib>
  485. {
  486. public:
  487. CMetaPropertyCondition()
  488. {
  489. #if defined(_ATL_FREE_THREADED)
  490. m_pUnkMarshaler = NULL;
  491. #endif
  492. }
  493. DECLARE_REGISTRY_RESOURCEID(IDR_PROPERTYCONDITION)
  494. DECLARE_GET_CONTROLLING_UNKNOWN()
  495. #if defined(_ATL_FREE_THREADED)
  496. DECLARE_PROTECT_FINAL_CONSTRUCT()
  497. #endif
  498. BEGIN_COM_MAP(CMetaPropertyCondition)
  499. COM_INTERFACE_ENTRY(IMetaPropertyCondition)
  500. COM_INTERFACE_ENTRY(CMetaPropertyCondition)
  501. COM_INTERFACE_ENTRY(IDispatch)
  502. #if defined(_ATL_FREE_THREADED)
  503. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  504. #endif
  505. END_COM_MAP()
  506. #if defined(_ATL_FREE_THREADED)
  507. HRESULT FinalConstruct()
  508. {
  509. return CoCreateFreeThreadedMarshaler(
  510. GetControllingUnknown(), &m_pUnkMarshaler.p);
  511. }
  512. void FinalRelease()
  513. {
  514. m_pUnkMarshaler.Release();
  515. }
  516. CComPtr<IUnknown> m_pUnkMarshaler;
  517. #endif
  518. STDMETHOD(get_QueryClause)(long &i, _bstr_t *pbstr)
  519. {
  520. return E_FAIL;
  521. }
  522. // IMetaPropertyCondition
  523. public:
  524. #if 0
  525. STDMETHOD(get_Not)(/*[out, retval]*/ IMetaPropertyCondition* *ppropcond);
  526. #endif
  527. STDMETHOD(get_Or)(IMetaPropertyCondition *pcond2, /*[out, retval]*/ IMetaPropertyCondition* *ppropcond);
  528. STDMETHOD(get_And)(IMetaPropertyCondition *pcond2, /*[out, retval]*/ IMetaPropertyCondition* *ppropcond);
  529. };
  530. class CMetaPropertyCondition1Cond : public CMetaPropertyCondition
  531. {
  532. public:
  533. CMetaPropertyCondition1Cond()
  534. {
  535. m_szOp = _T("");
  536. }
  537. ~CMetaPropertyCondition1Cond()
  538. {
  539. if (m_ppropcond1 != NULL)
  540. m_ppropcond1->Release();
  541. }
  542. void Init(IMetaPropertyCondition *ppropcond1)
  543. {
  544. m_ppropcond1 = ppropcond1;
  545. if (m_ppropcond1 != NULL)
  546. m_ppropcond1->AddRef();
  547. }
  548. protected:
  549. STDMETHOD(get_QueryClause)(long &i, _bstr_t *pbstr)
  550. {
  551. _bstr_t bstr1;
  552. CComQIPtr<CMetaPropertyCondition> ppropcond1(m_ppropcond1);
  553. ppropcond1->get_QueryClause(i, &bstr1);
  554. *pbstr = m_szOp + (_T("(") + bstr1 + _T(")"));
  555. return S_OK;
  556. }
  557. protected:
  558. IMetaPropertyCondition *m_ppropcond1;
  559. TCHAR *m_szOp;
  560. };
  561. class CMetaPropertyCondition2Cond : public CMetaPropertyCondition1Cond
  562. {
  563. public:
  564. ~CMetaPropertyCondition2Cond()
  565. {
  566. if (m_ppropcond2 != NULL)
  567. m_ppropcond2->Release();
  568. }
  569. void Init(IMetaPropertyCondition *ppropcond1, IMetaPropertyCondition *ppropcond2)
  570. {
  571. CMetaPropertyCondition1Cond::Init(ppropcond1);
  572. m_ppropcond2 = ppropcond2;
  573. if (m_ppropcond2 != NULL)
  574. m_ppropcond2->AddRef();
  575. }
  576. protected:
  577. STDMETHOD(get_QueryClause)(long &i, _bstr_t *pbstr)
  578. {
  579. _bstr_t bstr1;
  580. CComQIPtr<CMetaPropertyCondition> ppropcond1(m_ppropcond1);
  581. ppropcond1->get_QueryClause(i, &bstr1);
  582. _bstr_t bstr2;
  583. CComQIPtr<CMetaPropertyCondition> ppropcond2(m_ppropcond2);
  584. ppropcond2->get_QueryClause(i, &bstr2);
  585. *pbstr = (_T("(") + bstr1 + _T(")")) + m_szOp + (_T("(") + bstr2 + _T(")"));
  586. return S_OK;
  587. }
  588. protected:
  589. IMetaPropertyCondition *m_ppropcond2;
  590. };
  591. class CMetaPropertyConditionAnd : public CMetaPropertyCondition2Cond
  592. {
  593. public:
  594. CMetaPropertyConditionAnd()
  595. {
  596. m_szOp = _T(" AND ");
  597. }
  598. };
  599. class CMetaPropertyConditionOr : public CMetaPropertyCondition2Cond
  600. {
  601. public:
  602. CMetaPropertyConditionOr()
  603. {
  604. m_szOp = _T(" OR ");
  605. }
  606. };
  607. #if 0
  608. class CMetaPropertyConditionNot : public CMetaPropertyCondition1Cond
  609. {
  610. public:
  611. CMetaPropertyConditionNot()
  612. {
  613. m_szOp = _T("NOT ");
  614. }
  615. };
  616. #endif
  617. class CMetaPropertyCondition1Prop : public CMetaPropertyCondition
  618. {
  619. public:
  620. ~CMetaPropertyCondition1Prop()
  621. {
  622. if (m_pprop != NULL)
  623. m_pprop->Release();
  624. }
  625. void Init(IMetaProperty *pprop)
  626. {
  627. m_pprop = pprop;
  628. if (m_pprop != NULL)
  629. m_pprop->AddRef();
  630. }
  631. STDMETHOD(get_QueryClause)(long &i, _bstr_t *pbstr)
  632. {
  633. _bstr_t bstr1;
  634. CComQIPtr<CMetaProperty> pprop(m_pprop);
  635. return pprop->get_QueryClause(i, m_szOp, pbstr);
  636. }
  637. virtual BOOL FCompare(VARIANT var1, VARIANT var2) = 0;
  638. protected:
  639. TCHAR * m_szOp;
  640. IMetaProperty *m_pprop;
  641. };
  642. inline int VariantCompare(VARIANT & var1, VARIANT & var2)
  643. {
  644. switch(VarCmp(&var1, &var2, LOCALE_USER_DEFAULT, 0))
  645. {
  646. case VARCMP_EQ:
  647. return 0;
  648. case VARCMP_LT:
  649. return -1;
  650. case VARCMP_GT:
  651. return 1;
  652. case VARCMP_NULL:
  653. return -1;
  654. }
  655. return -1;
  656. }
  657. class CMetaPropertyConditionEQ : public CMetaPropertyCondition1Prop
  658. {
  659. public:
  660. CMetaPropertyConditionEQ()
  661. {
  662. m_szOp = _T(" = ");
  663. }
  664. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  665. {
  666. return (VariantCompare(var1, var2) == 0);
  667. }
  668. };
  669. class CMetaPropertyConditionNE : public CMetaPropertyCondition1Prop
  670. {
  671. public:
  672. CMetaPropertyConditionNE()
  673. {
  674. m_szOp = _T(" <> ");
  675. }
  676. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  677. {
  678. return (VariantCompare(var1, var2) != 0);
  679. }
  680. };
  681. class CMetaPropertyConditionLike : public CMetaPropertyCondition1Prop
  682. {
  683. public:
  684. CMetaPropertyConditionLike()
  685. {
  686. m_szOp = _T(" LIKE ");
  687. }
  688. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  689. {
  690. return FALSE; //UNDONE
  691. }
  692. };
  693. class CMetaPropertyConditionNotLike : public CMetaPropertyCondition1Prop
  694. {
  695. public:
  696. CMetaPropertyConditionNotLike()
  697. {
  698. m_szOp = _T(" NOT LIKE ");
  699. }
  700. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  701. {
  702. return FALSE; //UNDONE
  703. }
  704. };
  705. class CMetaPropertyConditionLT : public CMetaPropertyCondition1Prop
  706. {
  707. public:
  708. CMetaPropertyConditionLT()
  709. {
  710. m_szOp = _T(" < ");
  711. }
  712. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  713. {
  714. return (VariantCompare(var1, var2) > 0);
  715. }
  716. };
  717. class CMetaPropertyConditionLE : public CMetaPropertyCondition1Prop
  718. {
  719. public:
  720. CMetaPropertyConditionLE()
  721. {
  722. m_szOp = _T(" <= ");
  723. }
  724. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  725. {
  726. return (VariantCompare(var1, var2) <= 0);
  727. }
  728. };
  729. class CMetaPropertyConditionGT : public CMetaPropertyCondition1Prop
  730. {
  731. public:
  732. CMetaPropertyConditionGT()
  733. {
  734. m_szOp = _T(" > ");
  735. }
  736. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  737. {
  738. return (VariantCompare(var1, var2) > 0);
  739. }
  740. };
  741. class CMetaPropertyConditionGE : public CMetaPropertyCondition1Prop
  742. {
  743. public:
  744. CMetaPropertyConditionGE()
  745. {
  746. m_szOp = _T(" >= ");
  747. }
  748. virtual BOOL FCompare(VARIANT var1, VARIANT var2)
  749. {
  750. return (VariantCompare(var1, var2) >= 0);
  751. }
  752. };
  753. #endif //__PROPERTY_H_