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.

374 lines
12 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 2000 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: Properties.H
  6. //
  7. // Project: Windows 2000 IAS
  8. //
  9. // Description: Declaration of the CProperties class
  10. //
  11. // Author: tperraut
  12. //
  13. // Revision 02/24/2000 created
  14. //
  15. /////////////////////////////////////////////////////////////////////////////
  16. #ifndef _PROPERTIES_H_8FACED96_87C8_4f68_BFFB_92669BA5E835
  17. #define _PROPERTIES_H_8FACED96_87C8_4f68_BFFB_92669BA5E835
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif // _MSC_VER > 1000
  21. #include "nocopy.h"
  22. #include "basecommand.h"
  23. class CProperties : private NonCopyable
  24. {
  25. public:
  26. //////////////
  27. //Constructor
  28. //////////////
  29. explicit CProperties(CSession& SessionParam);
  30. //////////////
  31. // Destructor
  32. //////////////
  33. virtual ~CProperties() throw();
  34. ///////////////
  35. // GetProperty
  36. ///////////////
  37. HRESULT GetProperty(
  38. LONG Bag,
  39. _bstr_t& Name,
  40. LONG& Type,
  41. _bstr_t& StrVal
  42. );
  43. ///////////////////
  44. // GetNextProperty
  45. ///////////////////
  46. HRESULT GetNextProperty(
  47. LONG Bag,
  48. _bstr_t& Name,
  49. LONG& Type,
  50. _bstr_t& StrVal,
  51. LONG Index
  52. );
  53. /////////////////////
  54. // GetPropertyByName
  55. /////////////////////
  56. HRESULT GetPropertyByName(
  57. LONG Bag,
  58. const _bstr_t& Name,
  59. LONG& Type,
  60. _bstr_t& StrVal
  61. );
  62. //////////////////
  63. // InsertProperty
  64. //////////////////
  65. void InsertProperty(
  66. LONG Bag,
  67. const _bstr_t& Name,
  68. LONG Type,
  69. const _bstr_t& StrVal
  70. );
  71. //////////////////
  72. // DeleteProperty
  73. //////////////////
  74. void DeleteProperty(
  75. LONG Bag,
  76. const _bstr_t& Name
  77. );
  78. ////////////////////
  79. // DeleteProperties
  80. ////////////////////
  81. void DeletePropertiesExcept(
  82. LONG Bag,
  83. const _bstr_t& Exception
  84. );
  85. //////////////////
  86. // UpdateProperty
  87. //////////////////
  88. void UpdateProperty(
  89. LONG Bag,
  90. const _bstr_t& Name,
  91. LONG Type,
  92. const _bstr_t& StrVal
  93. );
  94. private:
  95. /////////////////////////////////////////////////////////////////////////////
  96. // START of the Properties Commands classes
  97. /////////////////////////////////////////////////////////////////////////////
  98. struct CBasePropertiesConst
  99. {
  100. static const int NAME_SIZE = 256;
  101. // 64 KB = the size of a memo field ?
  102. // Here even 1024 would be enough
  103. static const int STRVAL_SIZE = 65536;
  104. static const int SIZE_EXCEPTION_MAX = 256;
  105. };
  106. //////////////////////////////////////////////////////////////////////////
  107. // class CSelectPropertiesAcc
  108. //////////////////////////////////////////////////////////////////////////
  109. class CSelectPropertiesAcc : public CBasePropertiesConst
  110. {
  111. protected:
  112. LONG m_Bag;
  113. WCHAR m_Name[NAME_SIZE];
  114. WCHAR m_StrVal[STRVAL_SIZE];
  115. LONG m_Type;
  116. BEGIN_COLUMN_MAP(CSelectPropertiesAcc)
  117. COLUMN_ENTRY(1, m_Bag)
  118. COLUMN_ENTRY(2, m_Name)
  119. COLUMN_ENTRY(3, m_Type)
  120. COLUMN_ENTRY(4, m_StrVal)
  121. END_COLUMN_MAP()
  122. LONG m_BagParam;
  123. BEGIN_PARAM_MAP(CSelectPropertiesAcc)
  124. COLUMN_ENTRY(1, m_BagParam)
  125. END_PARAM_MAP()
  126. DEFINE_COMMAND(CSelectPropertiesAcc, L" \
  127. SELECT \
  128. Bag, \
  129. Name, \
  130. Type, \
  131. StrVal \
  132. FROM Properties \
  133. WHERE Bag = ?");
  134. };
  135. //////////////////////////////////////////////////////////////////////////
  136. // class CPropertiesCommandGet
  137. //////////////////////////////////////////////////////////////////////////
  138. class CPropertiesCommandGet:
  139. public CBaseCommand<CAccessor<CSelectPropertiesAcc> >
  140. {
  141. public:
  142. explicit CPropertiesCommandGet(CSession& CurrentSession);
  143. ///////////////
  144. // GetProperty
  145. ///////////////
  146. HRESULT GetProperty(
  147. LONG Bag,
  148. _bstr_t& Name,
  149. LONG& Type,
  150. _bstr_t& StrVal
  151. );
  152. //////////////////////////
  153. // GetProperty overloaded
  154. //////////////////////////
  155. HRESULT GetProperty(
  156. LONG Bag,
  157. _bstr_t& Name,
  158. LONG& Type,
  159. _bstr_t& StrVal,
  160. LONG Index
  161. );
  162. };
  163. //////////////////////////////////////////////////////////////////////////
  164. // class CSelectPropertiesAcc
  165. //////////////////////////////////////////////////////////////////////////
  166. class CSelectPropertiesByNameAcc : public CBasePropertiesConst
  167. {
  168. protected:
  169. LONG m_Bag;
  170. WCHAR m_Name[NAME_SIZE];
  171. WCHAR m_StrVal[STRVAL_SIZE];
  172. LONG m_Type;
  173. BEGIN_COLUMN_MAP(CSelectPropertiesByNameAcc)
  174. COLUMN_ENTRY(1, m_Bag)
  175. COLUMN_ENTRY(2, m_Name)
  176. COLUMN_ENTRY(3, m_Type)
  177. COLUMN_ENTRY(4, m_StrVal)
  178. END_COLUMN_MAP()
  179. LONG m_BagParam;
  180. WCHAR m_NameParam[NAME_SIZE];
  181. BEGIN_PARAM_MAP(CSelectPropertiesByNameAcc)
  182. COLUMN_ENTRY(1, m_BagParam)
  183. COLUMN_ENTRY(2, m_NameParam)
  184. END_PARAM_MAP()
  185. DEFINE_COMMAND(CSelectPropertiesByNameAcc, L" \
  186. SELECT \
  187. Bag, \
  188. Name, \
  189. Type, \
  190. StrVal \
  191. FROM Properties \
  192. WHERE ((Bag = ?) AND (Name = ?))");
  193. };
  194. //////////////////////////////////////////////////////////////////////////
  195. // class CPropertiesCommandGetByName
  196. //////////////////////////////////////////////////////////////////////////
  197. class CPropertiesCommandGetByName:
  198. public CBaseCommand<CAccessor<CSelectPropertiesByNameAcc> >
  199. {
  200. public:
  201. explicit CPropertiesCommandGetByName(CSession& CurrentSession);
  202. ///////////////
  203. // GetPropertyByName
  204. ///////////////
  205. HRESULT GetPropertyByName(
  206. LONG Bag,
  207. const _bstr_t& Name,
  208. LONG& Type,
  209. _bstr_t& StrVal
  210. );
  211. };
  212. //////////////////////////////////////////////////////////////////////////
  213. // class CInsertPropertyAcc
  214. //////////////////////////////////////////////////////////////////////////
  215. class CInsertPropertyAcc : public CBasePropertiesConst
  216. {
  217. protected:
  218. WCHAR m_NameParam[NAME_SIZE];
  219. LONG m_TypeParam;
  220. WCHAR m_StrValParam[STRVAL_SIZE];
  221. LONG m_BagParam;
  222. BEGIN_PARAM_MAP(CInsertPropertyAcc)
  223. COLUMN_ENTRY(1, m_BagParam)
  224. COLUMN_ENTRY(2, m_NameParam)
  225. COLUMN_ENTRY(3, m_TypeParam)
  226. COLUMN_ENTRY(4, m_StrValParam)
  227. END_PARAM_MAP()
  228. DEFINE_COMMAND(CInsertPropertyAcc, L" \
  229. INSERT INTO Properties \
  230. (Bag, Name, Type, StrVal) \
  231. VALUES (?, ?, ?, ?)")
  232. // You may wish to call this function if you are inserting a record
  233. // and wish to initialize all the fields, if you are not going to
  234. // explicitly set all of them.
  235. void ClearRecord()
  236. {
  237. memset(this, 0, sizeof(*this));
  238. }
  239. };
  240. //////////////////////////////////
  241. // class CPropertiesCommandInsert
  242. //////////////////////////////////
  243. class CPropertiesCommandInsert:
  244. public CBaseCommand<CAccessor<CInsertPropertyAcc> >
  245. {
  246. public:
  247. explicit CPropertiesCommandInsert(CSession& CurrentSession);
  248. void InsertProperty(
  249. LONG Bag,
  250. const _bstr_t& Name,
  251. LONG Type,
  252. const _bstr_t& StrVal
  253. );
  254. };
  255. //////////////////////////////////////////////////////////////////////////
  256. // class CDeletePropertyAcc
  257. //////////////////////////////////////////////////////////////////////////
  258. class CDeletePropertyAcc : public CBasePropertiesConst
  259. {
  260. protected:
  261. WCHAR m_NameParam[NAME_SIZE];
  262. LONG m_BagParam;
  263. BEGIN_PARAM_MAP(CDeletePropertyAcc)
  264. COLUMN_ENTRY(1, m_BagParam)
  265. COLUMN_ENTRY(2, m_NameParam)
  266. END_PARAM_MAP()
  267. DEFINE_COMMAND(CDeletePropertyAcc, L" \
  268. DELETE * \
  269. FROM Properties \
  270. WHERE ((Bag = ?) AND (Name = ?))")
  271. };
  272. //////////////////////////////////
  273. // class CPropertiesCommandDelete
  274. //////////////////////////////////
  275. class CPropertiesCommandDelete:
  276. public CBaseCommand<CAccessor<CDeletePropertyAcc> >
  277. {
  278. public:
  279. explicit CPropertiesCommandDelete(CSession& CurrentSession);
  280. void DeleteProperty(
  281. LONG Bag,
  282. const _bstr_t& Name
  283. );
  284. };
  285. //////////////////////////////////////////////////////////////////////////
  286. // class CDeletePropertiesAcc
  287. //////////////////////////////////////////////////////////////////////////
  288. class CDeletePropertiesAcc : public CBasePropertiesConst
  289. {
  290. protected:
  291. LONG m_BagParam;
  292. WCHAR m_ExceptionParam[SIZE_EXCEPTION_MAX];
  293. BEGIN_PARAM_MAP(CDeletePropertiesAcc)
  294. COLUMN_ENTRY(1, m_BagParam)
  295. COLUMN_ENTRY(2, m_ExceptionParam)
  296. END_PARAM_MAP()
  297. DEFINE_COMMAND(CDeletePropertiesAcc, L" \
  298. DELETE * \
  299. FROM Properties \
  300. WHERE ( (Bag = ?) AND (Name <> ?))")
  301. };
  302. //////////////////////////////////
  303. // class CPropertiesCommandDelete
  304. //////////////////////////////////
  305. class CPropertiesCommandDeleteMultiple:
  306. public CBaseCommand<CAccessor<CDeletePropertiesAcc> >
  307. {
  308. public:
  309. explicit CPropertiesCommandDeleteMultiple(CSession& CurrentSession);
  310. void DeletePropertiesExcept(LONG Bag, const _bstr_t& Exception);
  311. };
  312. CPropertiesCommandGet m_PropertiesCommandGet;
  313. CPropertiesCommandGetByName m_PropertiesCommandGetByName;
  314. CPropertiesCommandInsert m_PropertiesCommandInsert;
  315. CPropertiesCommandDelete m_PropertiesCommandDelete;
  316. CPropertiesCommandDeleteMultiple m_PropertiesCommandDeleteMultiple;
  317. };
  318. #endif // _PROPERTIES_H_8FACED96_87C8_4f68_BFFB_92669BA5E835