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.

1468 lines
57 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. This file contains the declaration of the interface to Jet Blue.
  6. Revision History:
  7. Davide Massarenti (Dmassare) 05/16/2000
  8. created
  9. ******************************************************************************/
  10. #if !defined(__INCLUDED___HCP___JETBLUELIB_H___)
  11. #define __INCLUDED___HCP___JETBLUELIB_H___
  12. #include <esent.h>
  13. //
  14. // From HelpServiceTypeLib.idl
  15. //
  16. #include <HelpServiceTypeLib.h>
  17. #include <HCP_trace.h>
  18. #include <MPC_COM.h>
  19. #include <MPC_utils.h>
  20. #include <MPC_xml.h>
  21. #include <MPC_config.h>
  22. #include <MPC_streams.h>
  23. #include <SvcResource.h>
  24. ////////////////////////////////////////////////////////////////////////////////
  25. //
  26. // Values are 32 bit values layed out as follows:
  27. //
  28. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  29. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  30. // +---+-+-+-----------------------+-------------------------------+
  31. // |Sev|C|R| Facility | Code |
  32. // +---+-+-+-----------------------+-------------------------------+
  33. //
  34. // where
  35. //
  36. // Sev - is the severity code
  37. //
  38. // 00 - Success
  39. // 01 - Informational
  40. // 10 - Warning
  41. // 11 - Error
  42. //
  43. // C - is the Customer code flag
  44. //
  45. // R - is a reserved bit
  46. //
  47. // Facility - is the facility code
  48. //
  49. // Code - is the facility's status code
  50. //
  51. #define HRESULT_BASE_JET 0xA2000000 // C=1, Facility=0x200
  52. ////////////////////////////////////////////////////////////////////////////////
  53. #define __MPC_EXIT_IF_JET_FAILS(hr,x) __MPC_EXIT_IF_METHOD_FAILS(hr,JetBlue::JetERRToHRESULT(x))
  54. #define __MPC_JET__MTSAFE(sesid,err,x) \
  55. { \
  56. err = ::JetSetSessionContext( sesid, 0xDEAD ); \
  57. \
  58. if(err == JET_errSuccess) err = (x); \
  59. \
  60. ::JetResetSessionContext( sesid ); \
  61. }
  62. #define __MPC_JET__MTSAFE_NORESULT(sesid,x) \
  63. { \
  64. JET_ERR err; \
  65. \
  66. __MPC_JET__MTSAFE(sesid,err,x); \
  67. }
  68. #define __MPC_EXIT_IF_JET_FAILS__MTSAFE(sesid,hr,x) \
  69. { \
  70. JET_ERR err; \
  71. \
  72. __MPC_JET__MTSAFE(sesid,err,x); \
  73. \
  74. __MPC_EXIT_IF_JET_FAILS(hr,err); \
  75. }
  76. #define __MPC_JET_CHECKHANDLE(hr,x,v) { if(x == v) __MPC_SET_ERROR_AND_EXIT(hr, E_HANDLE); }
  77. ////////////////////////////////////////////////////////////////////////////////
  78. #define __MPC_JET_INIT_RETRIEVE_COL(rc,pos,colid,pvdata,cbdata) \
  79. rc[pos].columnid = colid;\
  80. rc[pos].pvData = pvdata;\
  81. rc[pos].cbData = cbdata;\
  82. rc[pos].itagSequence = 1;
  83. #define __MPC_JET_COLUMNCREATE(name,type,max,grbit) \
  84. { \
  85. sizeof(JET_COLUMNCREATE), /* unsigned long cbStruct; # size of this structure (for future expansion) */ \
  86. name , /* char *szColumnName; # column name */ \
  87. type , /* JET_COLTYP coltyp; # column type */ \
  88. max , /* unsigned long cbMax; # the maximum length of this column (only relevant for binary and text columns) */ \
  89. grbit , /* JET_GRBIT grbit; # column options */ \
  90. NULL , /* void *pvDefault # default value (NULL if none) */ \
  91. 0 , /* unsigned long cbDefault; # length of default value */ \
  92. 0 , /* unsigned long cp; # code page (for text columns only) */ \
  93. 0 , /* JET_COLUMNID columnid; # returned column id */ \
  94. JET_errSuccess /* JET_ERR err; # returned error code */ \
  95. }
  96. #define __MPC_JET_COLUMNCREATE_ANSI(name,type,max,grbit) \
  97. { \
  98. sizeof(JET_COLUMNCREATE), /* unsigned long cbStruct; # size of this structure (for future expansion) */ \
  99. name , /* char *szColumnName; # column name */ \
  100. type , /* JET_COLTYP coltyp; # column type */ \
  101. max , /* unsigned long cbMax; # the maximum length of this column (only relevant for binary and text columns) */ \
  102. grbit , /* JET_GRBIT grbit; # column options */ \
  103. NULL , /* void *pvDefault # default value (NULL if none) */ \
  104. 0 , /* unsigned long cbDefault; # length of default value */ \
  105. 1252 , /* unsigned long cp; # code page (for text columns only) */ \
  106. 0 , /* JET_COLUMNID columnid; # returned column id */ \
  107. JET_errSuccess /* JET_ERR err; # returned error code */ \
  108. }
  109. #define __MPC_JET_COLUMNCREATE_UNICODE(name,type,max,grbit) \
  110. { \
  111. sizeof(JET_COLUMNCREATE), /* unsigned long cbStruct; # size of this structure (for future expansion) */ \
  112. name , /* char *szColumnName; # column name */ \
  113. type , /* JET_COLTYP coltyp; # column type */ \
  114. max , /* unsigned long cbMax; # the maximum length of this column (only relevant for binary and text columns) */ \
  115. grbit , /* JET_GRBIT grbit; # column options */ \
  116. NULL , /* void *pvDefault # default value (NULL if none) */ \
  117. 0 , /* unsigned long cbDefault; # length of default value */ \
  118. 1200 , /* unsigned long cp; # code page (for text columns only) */ \
  119. 0 , /* JET_COLUMNID columnid; # returned column id */ \
  120. JET_errSuccess /* JET_ERR err; # returned error code */ \
  121. }
  122. #define __MPC_JET_INDEXCREATE(name,keys,grbit,density) \
  123. { \
  124. sizeof(JET_INDEXCREATE), /* unsigned long cbStruct; # size of this structure (for future expansion) */ \
  125. name , /* char *szIndexName; # index name */ \
  126. (LPSTR)keys , /* char *szKey; # index key */ \
  127. sizeof(keys) , /* unsigned long cbKey; # length of key */ \
  128. grbit , /* JET_GRBIT grbit; # index options */ \
  129. density /* unsigned long ulDensity; # index density */ \
  130. /* # */ \
  131. /* union # */ \
  132. /* { # */ \
  133. /* ULONG_PTR lcid; # lcid for the index (if JET_bitIndexUnicode NOT specified) */ \
  134. /* JET_UNICODEINDEX *pidxunicode; # pointer to JET_UNICODEINDEX struct (if JET_bitIndexUnicode specified) */ \
  135. /* }; # */ \
  136. /* # */ \
  137. /* unsigned long cbVarSegMac; # maximum length of variable length columns in index key */ \
  138. /* JET_CONDITIONALCOLUMN *rgconditionalcolumn; # pointer to conditional column structure */ \
  139. /* unsigned long cConditionalColumn; # number of conditional columns */ \
  140. /* JET_ERR err; # returned error code */ \
  141. }
  142. #define __MPC_JET_TABLECREATE(name,pages,density,cols,idxs) \
  143. { \
  144. sizeof(JET_TABLECREATE), /* unsigned long cbStruct; # size of this structure (for future expansion) */ \
  145. name , /* char *szTableName; # name of table to create. */ \
  146. NULL , /* char *szTemplateTableName; # name of table from which to inherit base DDL */ \
  147. pages , /* unsigned long ulPages; # initial pages to allocate for table. */ \
  148. density , /* unsigned long ulDensity; # table density. */ \
  149. (JET_COLUMNCREATE*)cols, /* JET_COLUMNCREATE *rgcolumncreate; # array of column creation info */ \
  150. ARRAYSIZE(cols) , /* unsigned long cColumns; # number of columns to create */ \
  151. (JET_INDEXCREATE*)idxs , /* JET_INDEXCREATE *rgindexcreate; # array of index creation info */ \
  152. ARRAYSIZE(idxs) , /* unsigned long cIndexes; # number of indexes to create */ \
  153. 0 , /* JET_GRBIT grbit; # */ \
  154. JET_tableidNil , /* JET_TABLEID tableid; # returned tableid. */ \
  155. 0 , /* unsigned long cCreated; # count of objects created (columns+table+indexes). */ \
  156. }
  157. ////////////////////////////////////////////////////////////////////////////////
  158. #define __MPC_JET_SETCTX(obj,ctx) { if(obj) { JET_SESID sesid = obj->GetSESID(); if(sesid != JET_sesidNil) ::JetSetSessionContext ( sesid, ctx ); } }
  159. #define __MPC_JET_RESETCTX(obj) { if(obj) { JET_SESID sesid = obj->GetSESID(); if(sesid != JET_sesidNil) ::JetResetSessionContext( sesid ); } }
  160. ////////////////////////////////////////////////////////////////////////////////
  161. namespace JetBlue
  162. {
  163. inline HRESULT JetERRToHRESULT( /*[in]*/ JET_ERR err ) { return (err < JET_errSuccess ? 0xA2000000 : 0) | (err & 0xFFFF); }
  164. ////////////////////////////////////////
  165. class Column;
  166. class Index;
  167. class Table;
  168. class Cursor;
  169. class Database;
  170. class Session;
  171. class SessionHandle;
  172. class SessionPool;
  173. typedef std::vector<Column> ColumnVector;
  174. typedef ColumnVector::iterator ColumnIter;
  175. typedef ColumnVector::const_iterator ColumnIterConst;
  176. typedef std::vector<Index> IndexVector;
  177. typedef IndexVector::iterator IndexIter;
  178. typedef IndexVector::const_iterator IndexIterConst;
  179. typedef std::map<MPC::string,Table*> TableMap;
  180. typedef TableMap::iterator TableIter;
  181. typedef TableMap::const_iterator TableIterConst;
  182. typedef std::map<MPC::string,Database*> DbMap;
  183. typedef DbMap::iterator DbIter;
  184. typedef DbMap::const_iterator DbIterConst;
  185. typedef std::map<MPC::wstringUC,long> Id2Node;
  186. typedef Id2Node::iterator Id2NodeIter;
  187. typedef Id2Node::const_iterator Id2NodeIterConst;
  188. typedef std::map<long,MPC::wstringUC> Node2Id;
  189. typedef Node2Id::iterator Node2IdIter;
  190. typedef Node2Id::const_iterator Node2IdIterConst;
  191. ////////////////////////////////////////
  192. class ColumnDefinition;
  193. class IndexDefinition;
  194. class TableDefinition;
  195. ////////////////////////////////////////
  196. class Column
  197. {
  198. friend class ColumnDefinition;
  199. friend class IndexDefinition;
  200. friend class TableDefinition;
  201. friend class Table;
  202. friend class Index;
  203. ////////////////////////////////////////
  204. JET_SESID m_sesid;
  205. JET_TABLEID m_tableid;
  206. MPC::string m_strName;
  207. JET_COLUMNDEF m_coldef;
  208. public:
  209. Column();
  210. ~Column();
  211. operator const MPC::string& () const { return m_strName; }
  212. operator const JET_COLUMNDEF&() const { return m_coldef ; }
  213. JET_SESID GetSESID () const { return m_sesid; }
  214. JET_TABLEID GetTABLEID () const { return m_tableid; }
  215. JET_COLUMNID GetCOLUMNID() const { return m_coldef.columnid; }
  216. ////////////////////
  217. HRESULT Get( /*[out]*/ CComVariant& vValue );
  218. HRESULT Get( /*[out]*/ MPC::CComHGLOBAL& hgValue );
  219. HRESULT Get( /*[out]*/ MPC::wstring& strValue );
  220. HRESULT Get( /*[out]*/ MPC::string& strValue );
  221. HRESULT Get( /*[out]*/ long& lValue );
  222. HRESULT Get( /*[out]*/ short& sValue );
  223. HRESULT Get( /*[out]*/ BYTE& bValue );
  224. HRESULT Put( /*[in]*/ const VARIANT& vValue, /*[in]*/ int iIdxPos = -1 );
  225. HRESULT Put( /*[in]*/ const MPC::CComHGLOBAL& hgValue );
  226. HRESULT Put( /*[in]*/ const MPC::wstring& strValue );
  227. HRESULT Put( /*[in]*/ const MPC::string& strValue );
  228. HRESULT Put( /*[in]*/ LPCWSTR szValue );
  229. HRESULT Put( /*[in]*/ LPCSTR szValue );
  230. HRESULT Put( /*[in]*/ long lValue );
  231. HRESULT Put( /*[in]*/ short sValue );
  232. HRESULT Put( /*[in]*/ BYTE bValue );
  233. };
  234. class Index
  235. {
  236. friend class IndexDefinition;
  237. friend class TableDefinition;
  238. friend class Table;
  239. ////////////////////////////////////////
  240. JET_SESID m_sesid;
  241. JET_TABLEID m_tableid;
  242. MPC::string m_strName;
  243. JET_GRBIT m_grbitIndex;
  244. LONG m_cKey;
  245. LONG m_cEntry;
  246. LONG m_cPage;
  247. ColumnVector m_vecColumns;
  248. Column m_fake; // In case the Idx passed to the operator[] is wrong...
  249. ////////////////////
  250. HRESULT GenerateKey( /*[out]*/ LPSTR& szKey, /*[out]*/ unsigned long& cKey );
  251. public:
  252. Index();
  253. ~Index();
  254. operator const MPC::string&() const { return m_strName; }
  255. JET_SESID GetSESID () const { return m_sesid; }
  256. JET_TABLEID GetTABLEID() const { return m_tableid; }
  257. ////////////////////////////////////////
  258. size_t NumOfColumns() { return m_vecColumns.size(); }
  259. int GetColPosition( LPCSTR szIdx );
  260. Column& GetCol ( LPCSTR szIdx );
  261. Column& GetCol ( int iIdx );
  262. };
  263. ////////////////////////////////////////////////////////////////////////////////
  264. class Table
  265. {
  266. friend class TableDefinition;
  267. friend class Cursor;
  268. ////////////////////////////////////////
  269. JET_SESID m_sesid;
  270. JET_DBID m_dbid;
  271. JET_TABLEID m_tableid;
  272. MPC::string m_strName;
  273. ColumnVector m_vecColumns;
  274. IndexVector m_vecIndexes;
  275. Index* m_idxSelected;
  276. Column m_fakeCol; // In case the argument passed to GetCol() is out-of-bound...
  277. Index m_fakeIdx; // In case the argument passed to GetIdx() is out-of-bound...
  278. ////////////////////////////////////////
  279. //
  280. // Methods used to create a cursor on a table.
  281. //
  282. Table();
  283. HRESULT Duplicate( /*[in]*/ Table& tbl );
  284. //
  285. ////////////////////////////////////////
  286. private: // Disable copy constructors...
  287. Table ( /*[in]*/ const Table& );
  288. Table& operator=( /*[in]*/ const Table& );
  289. public:
  290. Table( /*[in]*/ JET_SESID sesid, /*[in]*/ JET_DBID dbid, /*[in]*/ LPCSTR szName );
  291. ~Table();
  292. operator const MPC::string&() const { return m_strName; }
  293. JET_SESID GetSESID () const { return m_sesid; }
  294. JET_DBID GetDBID () const { return m_dbid; }
  295. JET_TABLEID GetTABLEID() const { return m_tableid; }
  296. ////////////////////
  297. HRESULT Refresh ( );
  298. HRESULT Close ( /*[in]*/ bool fForce = false );
  299. ////////////////////
  300. HRESULT Attach( /*[in]*/ JET_TABLEID tableid );
  301. HRESULT Open ( );
  302. HRESULT Create( );
  303. HRESULT Create( /*[in]*/ JET_TABLECREATE* pDef );
  304. HRESULT Delete( /*[in]*/ bool fForce = false );
  305. ////////////////////
  306. HRESULT DupCursor( /*[in/out]*/ Cursor& cur );
  307. HRESULT SelectIndex ( /*[in]*/ LPCSTR szIndex, /*[in]*/ JET_GRBIT grbit = JET_bitNoMove );
  308. HRESULT SetIndexRange( /*[in]*/ JET_GRBIT grbit = JET_bitRangeRemove );
  309. HRESULT PrepareInsert();
  310. HRESULT PrepareUpdate();
  311. HRESULT CancelChange ();
  312. HRESULT Move( /*[in]*/ JET_GRBIT grbit, /*[in]*/ long cRow , /*[in]*/ bool *pfFound = NULL );
  313. HRESULT Seek( /*[in]*/ JET_GRBIT grbit, /*[in]*/ VARIANT* rgKeys, /*[in]*/ int dwLen, /*[in]*/ bool *pfFound = NULL );
  314. template <typename T> HRESULT Seek( /*[in]*/ JET_GRBIT grbit, /*[in]*/ T value )
  315. {
  316. CComVariant v( value );
  317. return Seek( grbit, &v, 1 );
  318. }
  319. HRESULT Get( /*[in]*/ int iArg, /*[out]*/ CComVariant* rgArg );
  320. HRESULT Put( /*[in]*/ int iArg, /*[in] */ const CComVariant* rgArg );
  321. HRESULT UpdateRecord( /*[in]*/ bool fMove = false );
  322. HRESULT DeleteRecord( );
  323. ////////////////////////////////////////
  324. size_t NumOfColumns() { return m_vecColumns.size(); }
  325. int GetColPosition( LPCSTR szIdx );
  326. Column& GetCol ( LPCSTR szIdx );
  327. Column& GetCol ( int iIdx );
  328. ////////////////////////////////////////
  329. size_t NumOfIndexes() { return m_vecIndexes.size(); }
  330. int GetIdxPosition( LPCSTR szCol );
  331. Index& GetIdx ( LPCSTR szCol );
  332. Index& GetIdx ( int iCol );
  333. };
  334. class Cursor
  335. {
  336. friend class Table;
  337. Table m_tbl;
  338. public:
  339. Table* operator->() { return &m_tbl; }
  340. operator Table& () { return m_tbl; }
  341. };
  342. ////////////////////////////////////////////////////////////////////////////////
  343. #define JET_DECLARE_BINDING(BaseClass) \
  344. typedef BaseClass _JRBC; \
  345. static const JetBlue::RecordBindingDef _jfd[]; \
  346. private: /* Disable copy constructors... */ \
  347. BaseClass& operator=( /*[in]*/ const BaseClass& ); \
  348. public: \
  349. BaseClass( /*[in]*/ const BaseClass& rs ) : RecordBindingBase( rs, this ) \
  350. { \
  351. } \
  352. BaseClass( /*[in]*/ JetBlue::Table* tbl ) : RecordBindingBase( tbl, this, _jfd ) \
  353. { \
  354. }
  355. #define JET_BEGIN_RECORDBINDING(x) const JetBlue::RecordBindingDef x::_jfd[] = {
  356. #define JET_FIELD_BYNAME(name,type,data,flag) { name, -1 , MPC::Config::MT_##type, offsetof(_JRBC, data), offsetof(_JRBC, flag) }
  357. #define JET_FIELD_BYNAME_NOTNULL(name,type,data) { name, -1 , MPC::Config::MT_##type, offsetof(_JRBC, data), -1 }
  358. #define JET_FIELD_BYPOS(pos,type,data,flag) { NULL, pos, MPC::Config::MT_##type, offsetof(_JRBC, data), offsetof(_JRBC, flag) }
  359. #define JET_FIELD_BYPOS_NOTNULL(pos,type,data) { NULL, pos, MPC::Config::MT_##type, offsetof(_JRBC, data), -1 }
  360. #define JET_END_RECORDBINDING(x) { NULL, -1 } };
  361. #define JET_SET_FIELD(rs,field,value) \
  362. rs->field = value \
  363. #define JET_SET_FIELD_TRISTATE(rs,field,validfield,value,isvalid) \
  364. if(isvalid) \
  365. { \
  366. rs->field = value; \
  367. rs->validfield = true; \
  368. } \
  369. else \
  370. { \
  371. rs->validfield = false; \
  372. }
  373. ////////////////////////////////////////////////////////////////////////////////
  374. struct RecordBindingDef
  375. {
  376. LPCSTR szColName;
  377. int szColPos;
  378. MPC::Config::MemberTypes mtType;
  379. size_t offsetData;
  380. size_t offsetNullFlag;
  381. };
  382. class RecordBindingBase
  383. {
  384. bool m_fInitialized;
  385. Table* m_tbl;
  386. Cursor* m_cur;
  387. void* m_pvBaseOfClass;
  388. int m_dwNumOfFields;
  389. const RecordBindingDef* m_FieldsDef;
  390. int* m_rgFieldsPos;
  391. VARTYPE* m_vtFieldsType;
  392. ////////////////////
  393. HRESULT Initialize();
  394. void Cleanup ();
  395. HRESULT ReadData ();
  396. HRESULT WriteData();
  397. private: // Disable copy constructors...
  398. RecordBindingBase ( /*[in]*/ const RecordBindingBase& );
  399. RecordBindingBase& operator=( /*[in]*/ const RecordBindingBase& );
  400. protected:
  401. RecordBindingBase( /*[in]*/ const RecordBindingBase& rs , /*[in]*/ void* pvBaseOfClass );
  402. RecordBindingBase( /*[in]*/ Table* tbl, /*[in]*/ void* pvBaseOfClass, /*[in]*/ const RecordBindingDef* FieldsDef );
  403. public:
  404. ~RecordBindingBase();
  405. ////////////////////
  406. HRESULT SelectIndex ( /*[in]*/ LPCSTR szIndex, /*[in]*/ JET_GRBIT grbit = JET_bitNoMove );
  407. HRESULT SetIndexRange( /*[in]*/ JET_GRBIT grbit = JET_bitRangeRemove );
  408. HRESULT Move( /*[in]*/ JET_GRBIT grbit, /*[in]*/ long cRow , /*[in]*/ bool *pfFound = NULL );
  409. HRESULT Seek( /*[in]*/ JET_GRBIT grbit, /*[in]*/ VARIANT* rgKeys, /*[in]*/ int dwLen, /*[in]*/ bool *pfFound = NULL );
  410. template <typename T> HRESULT Seek( /*[in]*/ JET_GRBIT grbit, /*[in]*/ T value )
  411. {
  412. CComVariant v( value );
  413. return Seek( grbit, &v, 1 );
  414. }
  415. ////////////////////
  416. HRESULT Insert();
  417. HRESULT Update();
  418. HRESULT Delete();
  419. };
  420. ////////////////////////////////////////////////////////////////////////////////
  421. class Database
  422. {
  423. Session* m_parent;
  424. JET_SESID m_sesid;
  425. JET_DBID m_dbid;
  426. MPC::string m_strName;
  427. TableMap m_mapTables;
  428. private: // Disable copy constructors...
  429. Database ( /*[in]*/ const Database& );
  430. Database& operator=( /*[in]*/ const Database& );
  431. public:
  432. Database( /*[in]*/ Session* parent, /*[in]*/ JET_SESID sesid, /*[in]*/ LPCSTR szName );
  433. ~Database();
  434. operator const MPC::string&() const { return m_strName; }
  435. JET_SESID GetSESID() const { return m_sesid; }
  436. JET_DBID GetDBID () const { return m_dbid; }
  437. ////////////////////
  438. HRESULT Refresh ( );
  439. HRESULT Open ( /*[in]*/ bool fReadOnly, /*[in]*/ bool fCreate , /*[in]*/ bool fRepair );
  440. HRESULT Close ( /*[in]*/ bool fForce = false, /*[in]*/ bool fAll = true );
  441. HRESULT Delete ( /*[in]*/ bool fForce = false );
  442. ////////////////////
  443. HRESULT GetTable( /*[in]*/ LPCSTR szName, /*[out]*/ Table*& tbl, /*[in]*/ JET_TABLECREATE* pDef = NULL );
  444. HRESULT Compact();
  445. HRESULT Repair ();
  446. ////////////////////////////////////////
  447. size_t NumOfTables() { return m_mapTables.size(); }
  448. Table* GetTbl( int iPos );
  449. Table* GetTbl( LPCSTR szTbl );
  450. };
  451. ////////////////////////////////////////////////////////////////////////////////
  452. class Session
  453. {
  454. friend class SessionPool;
  455. friend class Database;
  456. SessionPool* m_parent;
  457. JET_INSTANCE m_inst;
  458. JET_SESID m_sesid;
  459. DbMap m_mapDBs;
  460. DWORD m_dwTransactionNesting;
  461. bool m_fAborted;
  462. ////////////////////
  463. bool LockDatabase ( /*[in]*/ const MPC::string& strDB, /*[in]*/ bool fReadOnly );
  464. void UnlockDatabase ( /*[in]*/ const MPC::string& strDB );
  465. HRESULT ReleaseDatabase( /*[in]*/ const MPC::string& strDB );
  466. ////////////////////
  467. HRESULT Init ( );
  468. HRESULT Close ( /*[in]*/ bool fForce = false );
  469. void Release( );
  470. private: // Disable copy constructors...
  471. Session ( /*[in]*/ const Session& );
  472. Session& operator=( /*[in]*/ const Session& );
  473. public:
  474. Session( /*[in]*/ SessionPool* parent, /*[in]*/ JET_INSTANCE inst );
  475. ~Session();
  476. JET_SESID GetSESID() const { return m_sesid; }
  477. ////////////////////
  478. HRESULT GetDatabase( /*[in]*/ LPCSTR szName, /*[out]*/ Database*& db, /*[in]*/ bool fReadOnly, /*[in]*/ bool fCreate, /*[in]*/ bool fRepair );
  479. ////////////////////
  480. HRESULT BeginTransaction ();
  481. HRESULT CommitTransaction ();
  482. HRESULT RollbackTransaction();
  483. ////////////////////////////////////////
  484. size_t NumOfDatabases() { return m_mapDBs.size(); }
  485. Database* GetDB( int iPos );
  486. Database* GetDB( LPCSTR szDB );
  487. };
  488. class TransactionHandle
  489. {
  490. Session* m_sess;
  491. private: // Disable copy constructors...
  492. TransactionHandle ( /*[in]*/ const TransactionHandle& );
  493. TransactionHandle& operator=( /*[in]*/ const TransactionHandle& );
  494. public:
  495. TransactionHandle();
  496. ~TransactionHandle();
  497. HRESULT Begin ( /*[in]*/ Session* sess );
  498. HRESULT Commit ( );
  499. HRESULT Rollback( );
  500. };
  501. class SessionHandle
  502. {
  503. friend class SessionPool;
  504. SessionPool* m_pool;
  505. Session* m_sess;
  506. void Init( /*[in]*/ SessionPool* pool, /*[in]*/ Session* sess );
  507. private: // Disable copy constructors...
  508. SessionHandle ( /*[in]*/ const SessionHandle& );
  509. SessionHandle& operator=( /*[in]*/ const SessionHandle& );
  510. public:
  511. SessionHandle();
  512. ~SessionHandle();
  513. operator Session* () const { return m_sess; }
  514. Session* operator->() const { return m_sess; }
  515. void Release();
  516. };
  517. class SessionPool : public CComObjectRootEx<MPC::CComSafeMultiThreadModel> // Just to have locking...
  518. {
  519. friend class SessionHandle;
  520. friend class Session;
  521. static const int l_MaxPoolSize = 15;
  522. static const int l_MaxFreePoolSize = 5;
  523. struct SessionState
  524. {
  525. Session* m_sess;
  526. bool m_fInUse;
  527. SessionState()
  528. {
  529. m_sess = NULL; // Session* m_sess;
  530. m_fInUse = false; // bool m_fInUse;
  531. }
  532. ~SessionState()
  533. {
  534. delete m_sess;
  535. }
  536. };
  537. struct DatabaseInUse
  538. {
  539. Session* m_sess;
  540. MPC::string m_strDB;
  541. bool m_fReadOnly;
  542. DatabaseInUse()
  543. {
  544. m_sess = NULL; // Session* m_sess;
  545. // MPC::string m_strDB;
  546. m_fReadOnly = true; // bool m_fReadOnly;
  547. }
  548. };
  549. typedef std::list<SessionState> SessionList;
  550. typedef SessionList::iterator SessionIter;
  551. typedef SessionList::const_iterator SessionIterConst;
  552. typedef std::list<DatabaseInUse> DbInUseList;
  553. typedef DbInUseList::iterator DbInUseIter;
  554. typedef DbInUseList::const_iterator DbInUseIterConst;
  555. bool m_fInitialized;
  556. JET_INSTANCE m_inst;
  557. SessionList m_lstSessions;
  558. DbInUseList m_lstDbInUse;
  559. int m_iAllocated;
  560. int m_iInUse;
  561. ////////////////////
  562. void ReleaseSession( /*[in]*/ Session* sess );
  563. bool LockDatabase ( /*[in]*/ Session* sess, /*[in]*/ const MPC::string& strDB, /*[in]*/ bool fReadOnly );
  564. void UnlockDatabase( /*[in]*/ Session* sess, /*[in]*/ const MPC::string& strDB );
  565. void Shutdown();
  566. ////////////////////
  567. private: // Disable copy constructors...
  568. SessionPool ( /*[in]*/ const SessionPool& );
  569. SessionPool& operator=( /*[in]*/ const SessionPool& );
  570. public:
  571. SessionPool();
  572. ~SessionPool();
  573. ////////////////////////////////////////////////////////////////////////////////
  574. static SessionPool* s_GLOBAL;
  575. static HRESULT InitializeSystem();
  576. static void FinalizeSystem ();
  577. ////////////////////////////////////////////////////////////////////////////////
  578. HRESULT Init ( /*[in]*/ LPCWSTR szLogs = NULL );
  579. HRESULT Close( /*[in]*/ bool fForce = false );
  580. HRESULT GetSession( /*[out]*/ SessionHandle& handle, /*[in]*/ DWORD dwTimeout = 300 );
  581. ////////////////////
  582. HRESULT ReleaseDatabase( /*[in]*/ LPCSTR szDB );
  583. };
  584. ////////////////////////////////////////////////////////////////////////////////
  585. ////////////////////////////////////////////////////////////////////////////////
  586. ////////////////////////////////////////////////////////////////////////////////
  587. class ColumnDefinition : public MPC::Config::TypeConstructor
  588. {
  589. DECLARE_CONFIG_MAP(ColumnDefinition);
  590. public:
  591. MPC::string m_strName;
  592. DWORD m_dwColTyp;
  593. DWORD m_dwGRBits;
  594. DWORD m_dwCodePage;
  595. DWORD m_dwMax;
  596. CComVariant m_vDefault;
  597. ////////////////////////////////////////
  598. //
  599. // MPC::Config::TypeConstructor
  600. //
  601. DEFINE_CONFIG_DEFAULTTAG();
  602. DECLARE_CONFIG_METHODS();
  603. //
  604. ////////////////////////////////////////
  605. ColumnDefinition();
  606. HRESULT Parse ( /*[in] */ Column& col );
  607. HRESULT Generate( /*[out]*/ JET_COLUMNCREATE& col );
  608. HRESULT Release ( /*[in] */ JET_COLUMNCREATE& col );
  609. };
  610. ////////////////////////////////////////
  611. class IndexDefinition : public MPC::Config::TypeConstructor
  612. {
  613. DECLARE_CONFIG_MAP(IndexDefinition);
  614. public:
  615. MPC::string m_strName;
  616. MPC::string m_strCols;
  617. DWORD m_dwGRBits;
  618. DWORD m_dwDensity;
  619. ////////////////////////////////////////
  620. //
  621. // MPC::Config::TypeConstructor
  622. //
  623. DEFINE_CONFIG_DEFAULTTAG();
  624. DECLARE_CONFIG_METHODS();
  625. //
  626. ////////////////////////////////////////
  627. IndexDefinition();
  628. HRESULT Parse ( /*[in] */ Index& idx );
  629. HRESULT Generate( /*[out]*/ JET_INDEXCREATE& idx );
  630. HRESULT Release ( /*[in] */ JET_INDEXCREATE& idx );
  631. };
  632. typedef std::list< ColumnDefinition > ColDefList;
  633. typedef ColDefList::iterator ColDefIter;
  634. typedef ColDefList::const_iterator ColDefIterConst;
  635. typedef std::list< IndexDefinition > IdxDefList;
  636. typedef IdxDefList::iterator IdxDefIter;
  637. typedef IdxDefList::const_iterator IdxDefIterConst;
  638. class TableDefinition : public MPC::Config::TypeConstructor
  639. {
  640. ////////////////////////////////////////
  641. DECLARE_CONFIG_MAP(TableDefinition);
  642. public:
  643. MPC::string m_strName;
  644. DWORD m_dwPages;
  645. DWORD m_dwDensity;
  646. ColDefList m_lstColumns;
  647. IdxDefList m_lstIndexes;
  648. ////////////////////////////////////////
  649. //
  650. // MPC::Config::TypeConstructor
  651. //
  652. DEFINE_CONFIG_DEFAULTTAG();
  653. DECLARE_CONFIG_METHODS();
  654. //
  655. ////////////////////////////////////////
  656. TableDefinition();
  657. HRESULT Load( /*[in]*/ LPCWSTR szFile );
  658. HRESULT Save( /*[in]*/ LPCWSTR szFile );
  659. HRESULT Parse ( /*[in] */ Table& tbl );
  660. HRESULT Generate( /*[out]*/ JET_TABLECREATE& tbl );
  661. HRESULT Release ( /*[in] */ JET_TABLECREATE& tbl );
  662. };
  663. };
  664. ////////////////////////////////////////////////////////////////////////////////
  665. ////////////////////////////////////////////////////////////////////////////////
  666. ////////////////////////////////////////////////////////////////////////////////
  667. #ifndef NOJETBLUECOM
  668. namespace JetBlueCOM
  669. {
  670. class Column;
  671. class Index;
  672. class Table;
  673. class Database;
  674. class Session;
  675. typedef MPC::CComObjectParent<Session> Session_Object;
  676. typedef MPC::CComObjectParent<Database> Database_Object;
  677. typedef MPC::CComObjectParent<Table> Table_Object;
  678. typedef CComObject <Column> Column_Object;
  679. typedef CComObject <Index> Index_Object;
  680. ////////////////////////////////////////////////////////////////////////////////
  681. template <class Parent, class Child> class BaseObjectWithChildren
  682. {
  683. public:
  684. typedef std::list<Child*> ChildList;
  685. typedef typename ChildList::iterator ChildIter;
  686. typedef typename ChildList::const_iterator ChildIterConst;
  687. private:
  688. ChildList m_children;
  689. private: // Disable copy constructors...
  690. BaseObjectWithChildren ( /*[in]*/ const BaseObjectWithChildren& );
  691. BaseObjectWithChildren& operator=( /*[in]*/ const BaseObjectWithChildren& );
  692. public:
  693. BaseObjectWithChildren()
  694. {
  695. }
  696. virtual ~BaseObjectWithChildren()
  697. {
  698. Passivate();
  699. }
  700. void GetChildren( /*[out]*/ ChildIterConst& itBegin, /*[out]*/ ChildIterConst& itEnd )
  701. {
  702. itBegin = m_children.begin();
  703. itEnd = m_children.end ();
  704. }
  705. ////////////////////////////////////////
  706. HRESULT CreateChild( Parent* pParent, Child* *pVal )
  707. {
  708. __HCP_FUNC_ENTRY( "CreateChild" );
  709. HRESULT hr;
  710. ChildIter it;
  711. CComObject<Child>* pChild = NULL;
  712. __MPC_PARAMCHECK_BEGIN(hr)
  713. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  714. __MPC_PARAMCHECK_END();
  715. __MPC_EXIT_IF_METHOD_FAILS(hr, pChild->CreateInstance( &pChild ));
  716. m_children.push_back( pChild ); pChild->AddRef();
  717. *pVal = pChild; pChild->AddRef();
  718. hr = S_OK;
  719. __HCP_FUNC_CLEANUP;
  720. __HCP_FUNC_EXIT(hr);
  721. }
  722. void Passivate()
  723. {
  724. ChildIter it;
  725. for(it = m_children.begin(); it != m_children.end(); it++)
  726. {
  727. Child* child = *it;
  728. child->Passivate();
  729. child->Release ();
  730. }
  731. m_children.clear();
  732. }
  733. HRESULT GetEnumerator( /*[in]*/ IPCHDBCollection* *pVal )
  734. {
  735. __HCP_FUNC_ENTRY( "GetEnumerator" );
  736. HRESULT hr;
  737. ChildIter it;
  738. CComObject<Collection>* pColl = NULL;
  739. __MPC_PARAMCHECK_BEGIN(hr)
  740. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  741. __MPC_PARAMCHECK_END();
  742. //
  743. // Create a new collection.
  744. //
  745. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl->CreateInstance( &pColl )); pColl->AddRef();
  746. for(it = m_children.begin(); it != m_children.end(); it++)
  747. {
  748. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl->AddItem( *it ));
  749. }
  750. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl->QueryInterface( IID_IPCHDBCollection, (void**)pVal ));
  751. hr = S_OK;
  752. __HCP_FUNC_CLEANUP;
  753. if(pColl) pColl->Release();
  754. __HCP_FUNC_EXIT(hr);
  755. }
  756. };
  757. ////////////////////////////////////////
  758. typedef MPC::CComCollection<IPCHDBCollection, &LIBID_HelpServiceTypeLib, MPC::CComSafeMultiThreadModel> BaseCollection;
  759. class ATL_NO_VTABLE Collection : // Hungarian: hcpc
  760. public BaseCollection
  761. {
  762. public:
  763. BEGIN_COM_MAP(Collection)
  764. COM_INTERFACE_ENTRY(IDispatch)
  765. COM_INTERFACE_ENTRY(IPCHDBCollection)
  766. END_COM_MAP()
  767. //
  768. // This is a trick!
  769. //
  770. // MPC::CComCollection defined a "get_Item" method that has a different signature from the
  771. // one in IPCHDBCollection, so it's not callable from scripting. Instead, this method will
  772. // be called.
  773. //
  774. STDMETHOD(get_Item)( /*[in]*/ VARIANT Index, /*[out]*/ VARIANT* pvar )
  775. {
  776. HRESULT hr = E_FAIL;
  777. //Index is 1-based
  778. if(pvar == NULL) return E_POINTER;
  779. if(Index.vt == VT_I4)
  780. {
  781. return BaseCollection::get_Item( (long)Index.iVal, pvar );
  782. }
  783. else if(Index.vt == VT_BSTR && Index.bstrVal)
  784. {
  785. std::list< VARIANT >::iterator iter;
  786. for(iter = m_coll.begin(); iter != m_coll.end(); iter++)
  787. {
  788. CComDispatchDriver disp( iter->pdispVal );
  789. CComVariant v;
  790. if(SUCCEEDED(disp.GetPropertyByName( L"Name", &v )) &&
  791. SUCCEEDED(v .ChangeType ( VT_BSTR )) )
  792. {
  793. if(v.bstrVal && !wcscmp( v.bstrVal, Index.bstrVal ))
  794. {
  795. hr = _Copy< VARIANT >::copy( pvar, &*iter );
  796. break;
  797. }
  798. }
  799. }
  800. }
  801. return hr;
  802. }
  803. };
  804. ////////////////////////////////////////////////////////////////////////////////
  805. class ATL_NO_VTABLE Column :
  806. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  807. public IDispatchImpl<IPCHDBColumn, &IID_IPCHDBColumn, &LIBID_HelpServiceTypeLib>
  808. {
  809. JetBlue::Column* m_col;
  810. public:
  811. BEGIN_COM_MAP(Column)
  812. COM_INTERFACE_ENTRY(IDispatch)
  813. COM_INTERFACE_ENTRY(IPCHDBColumn)
  814. END_COM_MAP()
  815. Column();
  816. virtual ~Column();
  817. HRESULT Initialize( /*[in]*/ JetBlue::Column& col );
  818. void Passivate ( );
  819. ////////////////////////////////////////
  820. STDMETHOD(get_Name )( /*[out, retval]*/ BSTR *pVal );
  821. STDMETHOD(get_Type )( /*[out, retval]*/ long *pVal );
  822. STDMETHOD(get_Bits )( /*[out, retval]*/ long *pVal );
  823. STDMETHOD(get_Value)( /*[out, retval]*/ VARIANT *pVal );
  824. STDMETHOD(put_Value)( /*[in] */ VARIANT newVal );
  825. };
  826. class ATL_NO_VTABLE Index :
  827. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  828. public IDispatchImpl<IPCHDBIndex, &IID_IPCHDBIndex, &LIBID_HelpServiceTypeLib>
  829. {
  830. JetBlue::Index* m_idx;
  831. BaseObjectWithChildren<Index,Column> m_Columns;
  832. public:
  833. BEGIN_COM_MAP(Index)
  834. COM_INTERFACE_ENTRY(IDispatch)
  835. COM_INTERFACE_ENTRY(IPCHDBIndex)
  836. END_COM_MAP()
  837. Index();
  838. virtual ~Index();
  839. HRESULT Initialize( /*[in]*/ JetBlue::Index& idx );
  840. void Passivate ( );
  841. ////////////////////////////////////////
  842. STDMETHOD(get_Name )( /*[out, retval]*/ BSTR *pVal );
  843. STDMETHOD(get_Columns)( /*[out, retval]*/ IPCHDBCollection* *pVal );
  844. };
  845. class ATL_NO_VTABLE Table :
  846. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  847. public IDispatchImpl<IPCHDBTable, &IID_IPCHDBTable, &LIBID_HelpServiceTypeLib>
  848. {
  849. JetBlue::Table* m_tbl;
  850. BaseObjectWithChildren<Table,Column> m_Columns;
  851. BaseObjectWithChildren<Table,Index > m_Indexes;
  852. public:
  853. BEGIN_COM_MAP(Table)
  854. COM_INTERFACE_ENTRY(IDispatch)
  855. COM_INTERFACE_ENTRY(IPCHDBTable)
  856. END_COM_MAP()
  857. Table();
  858. virtual ~Table();
  859. HRESULT Initialize( /*[in]*/ JetBlue::Table& tbl );
  860. void Passivate ( );
  861. ////////////////////////////////////////
  862. STDMETHOD(get_Name )( /*[out, retval]*/ BSTR *pVal );
  863. STDMETHOD(get_Columns)( /*[out, retval]*/ IPCHDBCollection* *pVal );
  864. STDMETHOD(get_Indexes)( /*[out, retval]*/ IPCHDBCollection* *pVal );
  865. ////////////////////
  866. STDMETHOD(SelectIndex )( /*[in]*/ BSTR bstrIndex, /*[in]*/ long grbit );
  867. STDMETHOD(SetIndexRange)( /*[in]*/ long grbit );
  868. STDMETHOD(PrepareInsert)();
  869. STDMETHOD(PrepareUpdate)();
  870. STDMETHOD(Move)( /*[in]*/ long grbit, /*[in]*/ long cRow, /*[out, retval]*/ VARIANT_BOOL *pfValid );
  871. STDMETHOD(Seek)( /*[in]*/ long grbit, /*[in]*/ VARIANT vKey, /*[out, retval]*/ VARIANT_BOOL *pfValid );
  872. STDMETHOD(UpdateRecord)();
  873. STDMETHOD(DeleteRecord)();
  874. };
  875. class ATL_NO_VTABLE Database :
  876. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  877. public IDispatchImpl<IPCHDBDatabase, &IID_IPCHDBDatabase, &LIBID_HelpServiceTypeLib>
  878. {
  879. JetBlue::Database* m_db;
  880. BaseObjectWithChildren<Database,Table> m_Tables;
  881. HRESULT Refresh();
  882. public:
  883. BEGIN_COM_MAP(Database)
  884. COM_INTERFACE_ENTRY(IDispatch)
  885. COM_INTERFACE_ENTRY(IPCHDBDatabase)
  886. END_COM_MAP()
  887. Database();
  888. virtual ~Database();
  889. HRESULT Initialize( /*[in]*/ JetBlue::Database& db );
  890. void Passivate ( );
  891. ////////////////////////////////////////
  892. STDMETHOD(get_Name )( /*[out, retval]*/ BSTR *pVal );
  893. STDMETHOD(get_Tables)( /*[out, retval]*/ IPCHDBCollection* *pVal );
  894. STDMETHOD(AttachTable)( /*[in]*/ BSTR bstrName, /*[in, optional]*/ VARIANT bstrXMLDef, /*[out,retval]*/ IPCHDBTable* *pVal );
  895. };
  896. class ATL_NO_VTABLE Session :
  897. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  898. public CComCoClass<Session, &CLSID_PCHDBSession>,
  899. public IDispatchImpl<IPCHDBSession, &IID_IPCHDBSession, &LIBID_HelpServiceTypeLib>
  900. {
  901. JetBlue::SessionHandle m_sess;
  902. BaseObjectWithChildren<Session,Database> m_DBs;
  903. HRESULT Refresh();
  904. public:
  905. DECLARE_REGISTRY_RESOURCEID(IDR_PCHDBSESSION)
  906. DECLARE_NOT_AGGREGATABLE(Session)
  907. DECLARE_PROTECT_FINAL_CONSTRUCT()
  908. BEGIN_COM_MAP(Session)
  909. COM_INTERFACE_ENTRY(IDispatch)
  910. COM_INTERFACE_ENTRY(IPCHDBSession)
  911. END_COM_MAP()
  912. Session();
  913. virtual ~Session();
  914. HRESULT FinalConstruct();
  915. void Passivate ();
  916. ////////////////////////////////////////
  917. STDMETHOD(get_Databases)( /*[out, retval]*/ IPCHDBCollection* *pVal );
  918. STDMETHOD(AttachDatabase)( /*[in]*/ BSTR bstrName, /*[in, optional]*/ VARIANT fCreate, /*[out,retval]*/ IPCHDBDatabase* *pVal );
  919. STDMETHOD(BeginTransaction )();
  920. STDMETHOD(CommitTransaction )();
  921. STDMETHOD(RollbackTransaction)();
  922. };
  923. };
  924. #endif
  925. ////////////////////////////////////////////////////////////////////////////////
  926. namespace Taxonomy
  927. {
  928. struct RS_Data_DBParameters
  929. {
  930. MPC::wstring m_strName;
  931. MPC::wstring m_strValue; bool m_fValid__Value;
  932. };
  933. class RS_DBParameters : public JetBlue::RecordBindingBase, public RS_Data_DBParameters
  934. {
  935. JET_DECLARE_BINDING(RS_DBParameters);
  936. public:
  937. HRESULT Seek_ByName( /*[in]*/ LPCWSTR szName, /*[in]*/ bool *pfFound = NULL );
  938. };
  939. ////////////////////
  940. struct RS_Data_ContentOwners
  941. {
  942. MPC::wstring m_strDN;
  943. long m_ID_owner;
  944. bool m_fIsOEM;
  945. };
  946. class RS_ContentOwners : public JetBlue::RecordBindingBase, public RS_Data_ContentOwners
  947. {
  948. JET_DECLARE_BINDING(RS_ContentOwners);
  949. public:
  950. HRESULT Seek_ByVendorID( /*[in]*/ LPCWSTR szDN, /*[in]*/ bool *pfFound = NULL );
  951. };
  952. ////////////////////
  953. struct RS_Data_SynSets
  954. {
  955. MPC::wstring m_strName;
  956. long m_ID_owner;
  957. long m_ID_synset;
  958. };
  959. class RS_SynSets : public JetBlue::RecordBindingBase, public RS_Data_SynSets
  960. {
  961. JET_DECLARE_BINDING(RS_SynSets);
  962. public:
  963. HRESULT Seek_ByPair( /*[in]*/ LPCWSTR szName, /*[in]*/ long ID_owner, /*[in]*/ bool *pfFound = NULL );
  964. };
  965. ////////////////////
  966. struct RS_Data_HelpImage
  967. {
  968. long m_ID_owner;
  969. MPC::wstring m_strFile;
  970. };
  971. class RS_HelpImage : public JetBlue::RecordBindingBase, public RS_Data_HelpImage
  972. {
  973. JET_DECLARE_BINDING(RS_HelpImage);
  974. public:
  975. HRESULT Seek_ByFile( /*[in]*/ LPCWSTR szFile, /*[in]*/ bool *pfFound = NULL );
  976. };
  977. ////////////////////
  978. struct RS_Data_Scope
  979. {
  980. long m_ID_scope ;
  981. long m_ID_owner ;
  982. MPC::wstring m_strID ;
  983. MPC::wstring m_strName ;
  984. MPC::wstring m_strCategory; bool m_fValid__Category; // Warning!! Long Text columns cannot be NOT NULL....
  985. };
  986. class RS_Scope : public JetBlue::RecordBindingBase, public RS_Data_Scope
  987. {
  988. JET_DECLARE_BINDING(RS_Scope);
  989. public:
  990. HRESULT Seek_ByID ( /*[in]*/ LPCWSTR szID , /*[in]*/ bool *pfFound = NULL );
  991. HRESULT Seek_ByScope ( /*[in]*/ long ID_scope, /*[in]*/ bool *pfFound = NULL );
  992. HRESULT Seek_OwnedScopes( /*[in]*/ long ID_owner, /*[in]*/ bool *pfFound = NULL );
  993. };
  994. ////////////////////
  995. struct RS_Data_IndexFiles
  996. {
  997. long m_ID_owner;
  998. long m_ID_scope;
  999. MPC::wstring m_strStorage; bool m_fValid__Storage;
  1000. MPC::wstring m_strFile; bool m_fValid__File;
  1001. };
  1002. class RS_IndexFiles : public JetBlue::RecordBindingBase, public RS_Data_IndexFiles
  1003. {
  1004. JET_DECLARE_BINDING(RS_IndexFiles);
  1005. public:
  1006. HRESULT Seek_ByScope( /*[in]*/ long ID_scope, /*[in]*/ bool *pfFound = NULL );
  1007. };
  1008. ////////////////////
  1009. struct RS_Data_FullTextSearch
  1010. {
  1011. long m_ID_owner;
  1012. long m_ID_scope;
  1013. MPC::wstring m_strCHM ; bool m_fValid__CHM;
  1014. MPC::wstring m_strCHQ ; bool m_fValid__CHQ;
  1015. };
  1016. class RS_FullTextSearch : public JetBlue::RecordBindingBase, public RS_Data_FullTextSearch
  1017. {
  1018. JET_DECLARE_BINDING(RS_FullTextSearch);
  1019. public:
  1020. HRESULT Seek_ByScope( /*[in]*/ long ID_scope, /*[in]*/ bool *pfFound = NULL );
  1021. };
  1022. ////////////////////
  1023. struct RS_Data_Taxonomy
  1024. {
  1025. long m_ID_node ;
  1026. long m_lPos ;
  1027. long m_ID_parent ; bool m_fValid__ID_parent ;
  1028. long m_ID_owner ;
  1029. MPC::wstring m_strEntry ;
  1030. MPC::wstring m_strTitle ; bool m_fValid__Title ; // Warning!! Long Text columns cannot be NOT NULL....
  1031. MPC::wstring m_strDescription ; bool m_fValid__Description ;
  1032. MPC::wstring m_strDescriptionURI; bool m_fValid__DescriptionURI;
  1033. MPC::wstring m_strIconURI ; bool m_fValid__IconURI ;
  1034. bool m_fVisible ;
  1035. bool m_fSubsite ;
  1036. long m_lNavModel ;
  1037. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ RS_Data_Taxonomy& val );
  1038. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const RS_Data_Taxonomy& val );
  1039. };
  1040. class RS_Taxonomy : public JetBlue::RecordBindingBase, public RS_Data_Taxonomy
  1041. {
  1042. JET_DECLARE_BINDING(RS_Taxonomy);
  1043. public:
  1044. HRESULT Seek_SubNode ( /*[in]*/ long ID_parent, /*[in]*/ LPCWSTR szEntry, /*[in]*/ bool *pfFound = NULL );
  1045. HRESULT Seek_ChildrenSorted( /*[in]*/ long ID_parent, /*[in]*/ long lPos , /*[in]*/ bool *pfFound = NULL );
  1046. HRESULT Seek_Children ( /*[in]*/ long ID_parent , /*[in]*/ bool *pfFound = NULL );
  1047. HRESULT Seek_Node ( /*[in]*/ long ID_node , /*[in]*/ bool *pfFound = NULL );
  1048. };
  1049. ////////////////////
  1050. struct RS_Data_Topics
  1051. {
  1052. long m_ID_topic ;
  1053. long m_ID_node ;
  1054. long m_ID_owner ;
  1055. long m_lPos ;
  1056. MPC::wstring m_strTitle ; bool m_fValid__Title ; // Warning!! Long Text columns cannot be NOT NULL....
  1057. MPC::wstring m_strURI ; bool m_fValid__URI ; // Warning!! Long Text columns cannot be NOT NULL....
  1058. MPC::wstring m_strDescription; bool m_fValid__Description;
  1059. MPC::wstring m_strIconURI ; bool m_fValid__IconURI ;
  1060. long m_lType ;
  1061. bool m_fVisible ;
  1062. };
  1063. class RS_Topics : public JetBlue::RecordBindingBase, public RS_Data_Topics
  1064. {
  1065. JET_DECLARE_BINDING(RS_Topics);
  1066. public:
  1067. HRESULT Seek_SingleTopic ( /*[in]*/ long ID_topic, /*[in]*/ bool *pfFound = NULL );
  1068. HRESULT Seek_TopicsUnderNode( /*[in]*/ long ID_node , /*[in]*/ bool *pfFound = NULL );
  1069. HRESULT Seek_ByURI ( /*[in]*/ LPCWSTR szURI, /*[in]*/ bool *pfFound = NULL );
  1070. };
  1071. ////////////////////
  1072. struct RS_Data_Synonyms
  1073. {
  1074. MPC::wstring m_strKeyword;
  1075. long m_ID_synset;
  1076. long m_ID_owner;
  1077. };
  1078. class RS_Synonyms : public JetBlue::RecordBindingBase, public RS_Data_Synonyms
  1079. {
  1080. JET_DECLARE_BINDING(RS_Synonyms);
  1081. public:
  1082. HRESULT Seek_ByPair( /*[in]*/ LPCWSTR szKeyword, /*[in]*/ long ID_synset, /*[in]*/ bool *pfFound = NULL );
  1083. HRESULT Seek_ByName( /*[in]*/ LPCWSTR szKeyword, /*[in]*/ bool *pfFound = NULL );
  1084. };
  1085. ////////////////////
  1086. struct RS_Data_Keywords
  1087. {
  1088. MPC::wstring m_strKeyword;
  1089. long m_ID_keyword;
  1090. };
  1091. class RS_Keywords : public JetBlue::RecordBindingBase, public RS_Data_Keywords
  1092. {
  1093. JET_DECLARE_BINDING(RS_Keywords);
  1094. public:
  1095. HRESULT Seek_ByName( /*[in]*/ LPCWSTR szKeyword, /*[in]*/ bool *pfFound = NULL );
  1096. };
  1097. ////////////////////
  1098. struct RS_Data_Matches
  1099. {
  1100. long m_ID_topic ;
  1101. long m_ID_keyword;
  1102. long m_lPriority ;
  1103. bool m_fHHK ;
  1104. };
  1105. class RS_Matches : public JetBlue::RecordBindingBase, public RS_Data_Matches
  1106. {
  1107. JET_DECLARE_BINDING(RS_Matches);
  1108. public:
  1109. HRESULT Seek_Pair ( /*[in]*/ long ID_Keyword, /*[in]*/ long ID_topic, /*[in]*/ bool *pfFound = NULL );
  1110. HRESULT Seek_ByKeyword( /*[in]*/ long ID_Keyword , /*[in]*/ bool *pfFound = NULL );
  1111. HRESULT Seek_ByTopic ( /*[in]*/ long ID_topic , /*[in]*/ bool *pfFound = NULL );
  1112. };
  1113. ////////////////////////////////////////////////////////////////////////////////
  1114. HRESULT CreateSchema( /*[in]*/ JetBlue::Database* db );
  1115. extern const int g_NumOfTables;
  1116. extern const JET_TABLECREATE* g_Tables[];
  1117. };
  1118. ////////////////////////////////////////////////////////////////////////////////
  1119. #endif // !defined(__INCLUDED___HCP___JETBLUELIB_H___)