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.

718 lines
22 KiB

  1. #include "header.h"
  2. #include "system.h"
  3. #include "..\hhctrl\Csubset.h"
  4. #include "..\hhctrl\CInfoTyp.h"
  5. //#pragma warning(disable:4554) // check operator precedence
  6. // Implememtaion file for CInfoTyp class; Information Type and Categories class
  7. // Constructor
  8. CInfoType::CInfoType(void)
  9. {
  10. m_itTables.m_ptblInfoTypes = new CTable(16 * 1024);
  11. m_itTables.m_ptblInfoTypeDescriptions = new CTable(64 * 1024);
  12. m_itTables.m_ptblCategories = new CTable(16 * 1024);
  13. m_itTables.m_ptblCatDescription = new CTable(64 * 1024);
  14. m_itTables.m_max_categories = MAX_CATEGORIES;
  15. m_itTables.m_aCategories = (CATEGORY_TYPE*) lcCalloc(MAX_CATEGORIES*sizeof(CATEGORY_TYPE) );
  16. m_itTables.m_cTypes = 0;
  17. m_itTables.m_cITSize = 1; // Iniaially allocate one DWORD to hold info type bits.
  18. #ifdef _DEBUG
  19. int cInfoTypeSize = InfoTypeSize();
  20. #endif
  21. for(int i=0; i< MAX_CATEGORIES; i++)
  22. m_itTables.m_aCategories[i].pInfoType = (INFOTYPE*)lcCalloc(InfoTypeSize());
  23. // Allocate the exclusive information types.
  24. m_itTables.m_pExclusive = (INFOTYPE*)lcCalloc(InfoTypeSize());
  25. // Allocate the hidden information types
  26. m_itTables.m_pHidden = (INFOTYPE*)lcCalloc(InfoTypeSize());
  27. // Allocate the user selection of info types
  28. m_pInfoTypes = (INFOTYPE*)lcCalloc(InfoTypeSize());
  29. memset(m_pInfoTypes, 0xFFFF, InfoTypeSize() ); // by default all bits on
  30. // allocate the Typical Info Types
  31. m_pTypicalInfoTypes = (INFOTYPE *)lcCalloc(InfoTypeSize());
  32. m_fTypeCopy = TRUE;
  33. m_fInitialized = TRUE;
  34. }
  35. // Destructor
  36. CInfoType::~CInfoType()
  37. {
  38. if ( m_itTables.m_ptblInfoTypes )
  39. delete m_itTables.m_ptblInfoTypes;
  40. if ( m_itTables.m_ptblInfoTypeDescriptions )
  41. delete m_itTables.m_ptblInfoTypeDescriptions;
  42. if ( m_itTables.m_ptblCategories )
  43. delete m_itTables.m_ptblCategories;
  44. if ( m_itTables.m_ptblCatDescription )
  45. delete m_itTables.m_ptblCatDescription;
  46. lcFree(m_pInfoTypes);
  47. lcFree(m_pTypicalInfoTypes);
  48. lcFree(m_itTables.m_pHidden);
  49. lcFree(m_itTables.m_pExclusive);
  50. if ( m_itTables.m_aCategories[0].pInfoType )
  51. {
  52. for (int i=0; i<m_itTables.m_max_categories; i++)
  53. lcFree( m_itTables.m_aCategories[i].pInfoType );
  54. }
  55. lcFree( m_itTables.m_aCategories );
  56. }
  57. // copy constructors
  58. const CInfoType& CInfoType::operator=(const CInfoType& ITSrc)
  59. {
  60. if ( this == NULL )
  61. return *this;
  62. if ( this == &ITSrc )
  63. return *this;
  64. m_itTables.m_cTypes = ITSrc.m_itTables.m_cTypes; // the number of ITs
  65. m_itTables.m_cITSize = ITSrc.m_itTables.m_cITSize; // the number of DWORDS allocated to hold ITs
  66. CopyTable( &ITSrc.m_itTables );
  67. CopyCat( &ITSrc.m_itTables );
  68. // copy the member variables
  69. if (m_itTables.m_pExclusive)
  70. lcFree(m_itTables.m_pExclusive);
  71. m_itTables.m_pExclusive = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  72. memcpy(m_itTables.m_pExclusive,
  73. ITSrc.m_itTables.m_pExclusive,
  74. InfoTypeSize());
  75. if (m_itTables.m_pHidden)
  76. lcFree(m_itTables.m_pHidden);
  77. m_itTables.m_pHidden = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  78. memcpy(m_itTables.m_pHidden,
  79. ITSrc.m_itTables.m_pHidden,
  80. InfoTypeSize());
  81. // user-specified Information Types
  82. if ( m_pInfoTypes )
  83. lcFree(m_pInfoTypes);
  84. m_pInfoTypes = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  85. memcpy(m_pInfoTypes, ITSrc.m_pInfoTypes, InfoTypeSize());
  86. // typical information types
  87. if ( m_pTypicalInfoTypes )
  88. lcFree(m_pTypicalInfoTypes);
  89. m_pTypicalInfoTypes = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  90. memcpy(m_pTypicalInfoTypes, ITSrc.m_pTypicalInfoTypes, InfoTypeSize());
  91. m_fTypeCopy = TRUE; // TRUE if the tables are coppied
  92. return *this;
  93. }
  94. const CInfoType& CInfoType::operator=(const CSiteMap& ITSrc)
  95. {
  96. if ( this == NULL )
  97. return *this;
  98. m_itTables.m_cTypes = ITSrc.m_itTables.m_cTypes;
  99. m_itTables.m_cITSize = ITSrc.m_itTables.m_cITSize;
  100. CopyTable( &ITSrc.m_itTables );
  101. CopyCat( &ITSrc.m_itTables );
  102. // copy the member variables
  103. if (m_itTables.m_pExclusive)
  104. lcFree(m_itTables.m_pExclusive);
  105. m_itTables.m_pExclusive = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  106. memcpy(m_itTables.m_pExclusive,
  107. ITSrc.m_itTables.m_pExclusive,
  108. InfoTypeSize() );
  109. if (m_itTables.m_pHidden)
  110. lcFree(m_itTables.m_pHidden);
  111. m_itTables.m_pHidden = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  112. memcpy(m_itTables.m_pHidden,
  113. ITSrc.m_itTables.m_pHidden,
  114. InfoTypeSize() );
  115. if ( m_pInfoTypes )
  116. lcFree(m_pInfoTypes);
  117. m_pInfoTypes = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  118. memcpy(m_pInfoTypes, ITSrc.m_pInfoTypes, InfoTypeSize() );
  119. if ( m_pTypicalInfoTypes )
  120. lcFree(m_pTypicalInfoTypes);
  121. m_pTypicalInfoTypes = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  122. memcpy(m_pTypicalInfoTypes, ITSrc.m_pTypicalInfoTypes, InfoTypeSize() );
  123. m_fTypeCopy = TRUE; // TRUE if the tables are coppied
  124. return *this;
  125. }
  126. void CInfoType::CopyTable( const INFOTYPE_TABLES *Src_itTables)
  127. {
  128. #ifdef HHCTRL
  129. int count;
  130. // copy the Category and Information Type definitions and descriptions.
  131. if ( m_itTables.m_ptblInfoTypes != Src_itTables->m_ptblInfoTypes && Src_itTables->m_ptblInfoTypes)
  132. for (int pos = 1; pos<= Src_itTables->m_cTypes; pos++ )
  133. {
  134. m_itTables.m_ptblInfoTypes->AddString( Src_itTables->m_ptblInfoTypes->GetPointer(pos) );
  135. m_itTables.m_ptblInfoTypeDescriptions->AddString( Src_itTables->m_ptblInfoTypeDescriptions->GetPointer(pos) );
  136. }
  137. count = Src_itTables->m_ptblCategories?Src_itTables->m_ptblCategories->CountStrings():0;
  138. if ( m_itTables.m_ptblCategories != Src_itTables->m_ptblCategories && Src_itTables->m_ptblCategories)
  139. for ( int pos = 1; pos <= count; pos++ )
  140. {
  141. m_itTables.m_ptblCategories->AddString(Src_itTables->m_ptblCategories->GetPointer(pos));
  142. m_itTables.m_ptblCatDescription->AddString(Src_itTables->m_ptblCatDescription->GetPointer(pos) );
  143. }
  144. #else
  145. if ( m_itTables.m_ptblInfoTypes != Src_itTables->m_ptblInfoTypes && Src_itTables->m_ptblInfoTypes)
  146. {
  147. m_itTables.m_ptblInfoTypes->Empty();
  148. m_itTables.m_ptblInfoTypes->CopyTable( Src_itTables->m_ptblInfoTypes );
  149. m_itTables.m_ptblInfoTypeDescriptions->Empty();
  150. m_itTables.m_ptblInfoTypeDescriptions->CopyTable( Src_itTables->m_ptblInfoTypeDescriptions );
  151. }
  152. if ( m_itTables.m_ptblCategories != Src_itTables->m_ptblCategories && Src_itTables->m_ptblCategories && Src_itTables->m_ptblCategories)
  153. {
  154. m_itTables.m_ptblCategories->Empty();
  155. m_itTables.m_ptblCategories->CopyTable( Src_itTables->m_ptblCategories);
  156. m_itTables.m_ptblCatDescription->Empty();
  157. m_itTables.m_ptblCatDescription->CopyTable( Src_itTables->m_ptblCatDescription );
  158. }
  159. #endif
  160. }
  161. void CInfoType::CopyCat(const INFOTYPE_TABLES * Src_itTables)
  162. {
  163. // copy the categories table
  164. m_itTables.m_max_categories = Src_itTables->m_max_categories;
  165. if ( m_itTables.m_max_categories > MAX_CATEGORIES )
  166. m_itTables.m_aCategories = (CATEGORY_TYPE *)lcReAlloc(m_itTables.m_aCategories,
  167. m_itTables.m_max_categories * sizeof(CATEGORY_TYPE) );
  168. for(int i=0; i<m_itTables.m_max_categories; i++)
  169. {
  170. if ( m_itTables.m_aCategories[i].pInfoType )
  171. lcFree(m_itTables.m_aCategories[i].pInfoType);
  172. m_itTables.m_aCategories[i].pInfoType = (INFOTYPE*) lcCalloc( InfoTypeSize() );
  173. if ( Src_itTables->m_aCategories[i].c_Types > 0 )
  174. {
  175. memcpy(m_itTables.m_aCategories[i].pInfoType,
  176. Src_itTables->m_aCategories[i].pInfoType,
  177. InfoTypeSize() );
  178. m_itTables.m_aCategories[i].c_Types = Src_itTables->m_aCategories[i].c_Types;
  179. }
  180. else
  181. {
  182. m_itTables.m_aCategories[i].c_Types = 0;
  183. }
  184. }
  185. }
  186. #ifdef HHCTRL
  187. void CInfoType::CopyTo( CHmData * const phmData)
  188. {
  189. CStr csz;
  190. int CatPos=0, CatDescPos=0;
  191. int TypePos=0,TypeDescPos=0;
  192. if ( !phmData || !phmData->m_pdInfoTypes )
  193. return;
  194. m_itTables.m_cTypes = 0;
  195. m_itTables.m_cITSize = 1;
  196. for(int i=0;
  197. (phmData->m_pdInfoTypes[i].type>=IT_INCLUSICE_TYPE) &&
  198. (phmData->m_pdInfoTypes[i].type<=IT_CAT_DESCRIPTION); i++)
  199. {
  200. if ( phmData->m_pdInfoTypes[i].dwString == -1 )
  201. continue;
  202. // BUGBUG: The code below is wrong. See CHmData::GetString() for reason.
  203. csz = phmData->GetString( phmData->m_pdInfoTypes[i].dwString );
  204. switch( phmData->m_pdInfoTypes[i].type )
  205. {
  206. case IT_INCLUSICE_TYPE:
  207. if ( CatPos > 0 )
  208. {
  209. TypePos = GetInfoType( csz.psz );
  210. if ( TypePos > 0 )
  211. AddITtoCategory(CatPos-1, TypePos);
  212. break;
  213. }
  214. if ( (m_itTables.m_cTypes > 0) && ((m_itTables.m_cTypes+1) % 32 == 0) )
  215. ReSizeIT(); // increase by one DWORD
  216. TypePos = m_itTables.m_ptblInfoTypes->AddString( csz.psz );
  217. m_itTables.m_cTypes++;
  218. break;
  219. case IT_EXCLUSIVE_TYPE:
  220. if ( CatPos > 0 )
  221. {
  222. TypePos = GetInfoType( csz.psz );
  223. if ( TypePos > 0 )
  224. AddITtoCategory(CatPos-1, TypePos);
  225. break;
  226. }
  227. if ( (m_itTables.m_cTypes > 0) && ((m_itTables.m_cTypes+1) % 32 == 0) )
  228. ReSizeIT(); // increase by one DWORD
  229. TypePos = m_itTables.m_ptblInfoTypes->AddString( csz.psz );
  230. AddExclusiveIT(TypePos);
  231. m_itTables.m_cTypes++;
  232. break;
  233. case IT_HIDDEN_TYPE:
  234. if ( CatPos > 0 )
  235. {
  236. TypePos = GetInfoType( csz.psz );
  237. if ( TypePos > 0 )
  238. AddITtoCategory(CatPos-1, TypePos);
  239. break;
  240. }
  241. if ( (m_itTables.m_cTypes > 0) && ((m_itTables.m_cTypes+1) % 32 == 0) )
  242. ReSizeIT(); // increase by one DWORD
  243. TypePos = m_itTables.m_ptblInfoTypes->AddString( csz.psz );
  244. AddHiddenIT(TypePos);
  245. m_itTables.m_cTypes++;
  246. break;
  247. case IT_DESCRIPTION:
  248. while( TypePos > TypeDescPos+1 )
  249. TypeDescPos = m_itTables.m_ptblInfoTypeDescriptions->AddString( " ");
  250. TypeDescPos = m_itTables.m_ptblInfoTypeDescriptions->AddString( csz.psz );
  251. break;
  252. case IT_CATEGORY:
  253. CatPos = m_itTables.m_ptblCategories->AddString( csz.psz );
  254. break;
  255. case IT_CAT_DESCRIPTION:
  256. while( CatPos > CatDescPos+1 )
  257. CatDescPos = m_itTables.m_ptblCatDescription->AddString( " " );
  258. CatDescPos = m_itTables.m_ptblCatDescription->AddString( csz.psz );
  259. break;
  260. }
  261. }
  262. }
  263. #endif
  264. void CInfoType::ReSizeIT(int Size)
  265. {
  266. int oldSize = InfoTypeSize();
  267. if ( Size == 0 )
  268. m_itTables.m_cITSize++; // increase by one
  269. else
  270. m_itTables.m_cITSize = Size;
  271. // Increase each category
  272. INFOTYPE * pIT;
  273. for(int i=0; i<m_itTables.m_max_categories; i++)
  274. {
  275. pIT = (INFOTYPE *) lcCalloc( InfoTypeSize() );
  276. memcpy(pIT, m_itTables.m_aCategories[i].pInfoType, oldSize);
  277. lcFree(m_itTables.m_aCategories[i].pInfoType);
  278. m_itTables.m_aCategories[i].pInfoType = pIT;
  279. }
  280. pIT = (INFOTYPE *) lcCalloc( InfoTypeSize() );
  281. memcpy(pIT, m_itTables.m_pExclusive, oldSize);
  282. lcFree(m_itTables.m_pExclusive);
  283. m_itTables.m_pExclusive = pIT;
  284. pIT = (INFOTYPE *) lcCalloc( InfoTypeSize() );
  285. memcpy(pIT, m_itTables.m_pHidden, oldSize);
  286. lcFree(m_itTables.m_pHidden);
  287. m_itTables.m_pHidden = pIT;
  288. pIT = (INFOTYPE *) lcCalloc( InfoTypeSize() );
  289. memcpy(pIT, m_pInfoTypes, oldSize);
  290. lcFree(m_pInfoTypes);
  291. m_pInfoTypes = pIT;
  292. pIT = (INFOTYPE *) lcCalloc( InfoTypeSize() );
  293. memcpy(pIT, m_pTypicalInfoTypes, oldSize);
  294. lcFree(m_pTypicalInfoTypes);
  295. m_pTypicalInfoTypes = pIT;
  296. }
  297. BOOL CInfoType::AnyInfoTypes(const INFOTYPE *pIT) const
  298. {
  299. INFOTYPE *pInfoType;
  300. BOOL bRet;
  301. pInfoType = (INFOTYPE*)lcCalloc( InfoTypeSize() );
  302. bRet = (memcmp( pIT, pInfoType, InfoTypeSize()) == 0)?FALSE:TRUE;
  303. lcFree ( pInfoType );
  304. return bRet;
  305. }
  306. // Check all the categories to see if this type is a member of any of them, return TRUE on first occurrence
  307. BOOL CInfoType::IsInACategory( int type ) const
  308. {
  309. for (int i=0; i<HowManyCategories(); i++ )
  310. {
  311. int offset;
  312. INFOTYPE *pIT;
  313. offset = type / 32;
  314. ASSERT ( m_itTables.m_aCategories[i].pInfoType );
  315. pIT = m_itTables.m_aCategories[i].pInfoType + offset;
  316. if ( *pIT & (1<<(type-(offset*32))) )
  317. return TRUE;
  318. }
  319. return FALSE;
  320. }
  321. #if 0 // enable for subset filtering
  322. BOOL CInfoType::IsEntryInCurTypeList(SITEMAP_ENTRY* pSiteMapEntry, CSubSets *pSSs) const
  323. {
  324. return (BOOL) AreTheseInfoTypesDefined(pSiteMapEntry, pSSs);
  325. }
  326. SITE_ENTRY_URL* CInfoType::AreTheseInfoTypesDefined(SITEMAP_ENTRY* pSiteMapEntry,
  327. CSubSets *pSSs) const
  328. {
  329. SITE_ENTRY_URL* pUrl = pSiteMapEntry->pUrls;
  330. if (!pUrl)
  331. return NULL;
  332. for (int iUrl = 0; iUrl < pSiteMapEntry->cUrls; iUrl++)
  333. {
  334. if ( !pSSs || pSSs->fTOCFilter( (pUrl+iUrl)->ainfoTypes ) )
  335. return pUrl;
  336. }
  337. return NULL;
  338. }
  339. #else
  340. BOOL CInfoType::IsEntryInCurTypeList(SITEMAP_ENTRY* pSiteMapEntry) const
  341. {
  342. int cTypes = m_itTables.m_ptblInfoTypes->CountStrings();
  343. if (cTypes < 32) {
  344. return AreTheseInfoTypesDefined(pSiteMapEntry, m_pInfoTypes[0], 0) != NULL;
  345. }
  346. else {
  347. for (int i = 0; cTypes > 32; i++) {
  348. if (AreTheseInfoTypesDefined(pSiteMapEntry, m_pInfoTypes[i], i))
  349. return TRUE;
  350. cTypes -= 32;
  351. }
  352. return AreTheseInfoTypesDefined(pSiteMapEntry, m_pInfoTypes[i], i) != NULL;
  353. }
  354. }
  355. SITE_ENTRY_URL* CInfoType::AreTheseInfoTypesDefined(SITEMAP_ENTRY* pSiteMapEntry,
  356. UINT types, int offset) const
  357. {
  358. ASSERT((UINT) offset <= m_itTables.m_cTypes / sizeof(UINT));
  359. SITE_ENTRY_URL* pUrl = pSiteMapEntry->pUrls;
  360. if (!pUrl)
  361. return NULL;
  362. for (int iUrl = 0; iUrl < pSiteMapEntry->cUrls; iUrl++) {
  363. if (pUrl->ainfoTypes[offset] & types)
  364. return pUrl;
  365. pUrl = NextUrlEntry(pUrl);
  366. }
  367. return NULL;
  368. }
  369. #endif
  370. int CInfoType::GetInfoType(PCSTR pszTypeName) const
  371. {
  372. int type;
  373. CStr cszCat = pszTypeName;
  374. ASSERT(!IsEmptyString(pszTypeName));
  375. /*
  376. A category and type is specified as:
  377. category::type name
  378. */
  379. PSTR pszCat = strstr(cszCat.psz, "::");
  380. if ( !pszCat )
  381. {
  382. pszCat = StrChr(cszCat.psz, ':');
  383. if(pszCat != NULL)
  384. {
  385. *pszCat = '\0';
  386. pszCat++;
  387. }
  388. }
  389. else
  390. {
  391. *pszCat='\0';
  392. pszCat+=2;
  393. }
  394. if ( pszCat == NULL )
  395. return GetITIndex(pszTypeName); // there is not category.
  396. else
  397. {
  398. int cat = GetCatPosition( cszCat.psz );
  399. if (cat <= 0)
  400. return -1;
  401. type = GetFirstCategoryType( cat-1 );
  402. while( type != -1 )
  403. {
  404. if ( lstrcmpi( pszCat, GetInfoTypeName(type) ) == 0 )
  405. return type;
  406. type = GetNextITinCategory();
  407. }
  408. }
  409. return -1;
  410. }
  411. // Static Data
  412. // ******************
  413. static INFOTYPE curr_bit; // used for getting the next IT in a category
  414. static int curr_cat;
  415. static int curr_offset; // There are 32 info type bits per offset.
  416. // ********************************************************
  417. //
  418. // Methods to operate on CInfoType Categories of Information Types
  419. //
  420. // ********************************************************
  421. void CInfoType::AddITtoCategory(int cat, int type)
  422. {
  423. int offset;
  424. INFOTYPE *pInfoType;
  425. m_itTables.m_aCategories[cat].c_Types++;
  426. offset = type / 32;
  427. pInfoType = m_itTables.m_aCategories[cat].pInfoType + offset;
  428. *pInfoType |= 1<<type;
  429. if ( m_itTables.m_max_categories == (cat+1) )
  430. {
  431. m_itTables.m_aCategories = (CATEGORY_TYPE*) lcReAlloc( m_itTables.m_aCategories, (m_itTables.m_max_categories+5) * sizeof(CATEGORY_TYPE) );
  432. for(int i=m_itTables.m_max_categories; i < m_itTables.m_max_categories+5; i++)
  433. m_itTables.m_aCategories[i].pInfoType = (INFOTYPE*)lcCalloc(InfoTypeSize());
  434. m_itTables.m_max_categories += 5;
  435. }
  436. }
  437. void CInfoType::DeleteITfromCat(int cat, int type)
  438. {
  439. int offset;
  440. INFOTYPE *pInfoType;
  441. if ( cat < 0 )
  442. return;
  443. m_itTables.m_aCategories[cat].c_Types--;
  444. offset = type / 32;
  445. pInfoType = m_itTables.m_aCategories[cat].pInfoType + offset;
  446. *pInfoType &= ~(1<<type);
  447. }
  448. int CInfoType::GetFirstCategoryType( int pos ) const
  449. {
  450. curr_offset = -1; // gets incermented to 0 before first IT comparison.
  451. curr_cat = pos; // keep the position of the category for calls to GetNextITinCagetory.
  452. curr_bit =1; // bit zero of offset zero is reserved. But check it any way.
  453. if ( pos < 0 )
  454. return -1;
  455. int bitpos = GetITfromCat(&curr_offset,
  456. &curr_bit,
  457. m_itTables.m_aCategories[curr_cat].pInfoType,
  458. InfoTypeSize()*8);
  459. if( (bitpos!=-1) && (IsDeleted(bitpos)) )
  460. return GetNextITinCategory();
  461. return bitpos;
  462. }
  463. int CInfoType::GetNextITinCategory( void ) const
  464. {
  465. if ( curr_cat < 0 )
  466. return -1; // must call GetFirstCategoryType() before calling this fn.
  467. int pos = GetITfromCat(&curr_offset,
  468. &curr_bit,
  469. m_itTables.m_aCategories[curr_cat].pInfoType,
  470. InfoTypeSize()*8);
  471. while ((pos!=-1) && (IsDeleted(pos)) )
  472. pos = GetITfromCat(&curr_offset,
  473. &curr_bit,
  474. m_itTables.m_aCategories[curr_cat].pInfoType,
  475. InfoTypeSize()*8);
  476. return pos;
  477. }
  478. int CInfoType::GetLastCategoryType(int pos) const
  479. { int cat;
  480. int offset;
  481. INFOTYPE bit;
  482. cat = pos; // The category
  483. if ( cat < 0 )
  484. return -1;
  485. offset = -1;
  486. bit = 1;
  487. for (int i=0; i<m_itTables.m_aCategories[cat].c_Types-1; i++)
  488. if ( GetITfromCat(&offset,
  489. &bit,
  490. m_itTables.m_aCategories[cat].pInfoType,
  491. InfoTypeSize()*8 ) == -1 )
  492. return -1;
  493. return GetITfromCat(&offset,
  494. &bit,
  495. m_itTables.m_aCategories[cat].pInfoType,
  496. InfoTypeSize() * 8 );
  497. }
  498. // ******************************************************
  499. //
  500. // Methods to operate on CInfoType Exclusive Information Types
  501. //
  502. // ******************************************************
  503. static int ExclusiveOffset = -1; // Gets incermented to zero before search begins
  504. static INFOTYPE ExclusiveBit = 1; // check bit 0 even though it is reserved.
  505. int CInfoType::GetFirstExclusive(int offset, INFOTYPE bit) const
  506. {
  507. ExclusiveOffset = offset;
  508. ExclusiveBit = bit;
  509. int pos = GetITBitfromIT(m_itTables.m_pExclusive,
  510. &ExclusiveOffset,
  511. &ExclusiveBit,
  512. InfoTypeSize()*8 );
  513. if ( pos!=-1 && IsDeleted(pos) )
  514. return GetNextExclusive();
  515. return pos;
  516. }
  517. int CInfoType::GetNextExclusive(void) const
  518. {
  519. if ( ExclusiveOffset < -1 || ExclusiveBit < 1 )
  520. return -1;
  521. int pos = GetITBitfromIT(m_itTables.m_pExclusive,
  522. &ExclusiveOffset,
  523. &ExclusiveBit,
  524. InfoTypeSize()*8 );
  525. while( (pos!=-1) && (IsDeleted(pos)) )
  526. pos = GetITBitfromIT(m_itTables.m_pExclusive,
  527. &ExclusiveOffset,
  528. &ExclusiveBit,
  529. InfoTypeSize()*8 );
  530. return pos;
  531. }
  532. int CInfoType::GetLastExclusive(void) const
  533. {
  534. int i;
  535. int iLastExclusive=-1, temp;
  536. int offset=-1;
  537. INFOTYPE bit=1;
  538. for (i=0; i< HowManyInfoTypes(); i++)
  539. if ( (temp = GetITBitfromIT(m_itTables.m_pExclusive, &offset, &bit, InfoTypeSize()*8)) == -1 )
  540. return iLastExclusive;
  541. else
  542. iLastExclusive = temp;
  543. return -1;
  544. }
  545. // ******************************************************
  546. //
  547. // Methods to operate on CInfoType Hidden Information Types
  548. //
  549. // ******************************************************
  550. static int HiddenOffset=-1;
  551. static INFOTYPE HiddenBit=1;
  552. int CInfoType::GetFirstHidden(int offset, INFOTYPE bit) const
  553. {
  554. HiddenOffset = offset;
  555. HiddenBit = bit;
  556. int pos = GetITBitfromIT(m_itTables.m_pHidden,
  557. &HiddenOffset,
  558. &HiddenBit,
  559. InfoTypeSize()*8 );
  560. if ( (pos!=-1) && (IsDeleted(pos)) )
  561. return GetNextHidden();
  562. return pos;
  563. }
  564. int CInfoType::GetNextHidden(void) const
  565. {
  566. if ( HiddenOffset < -1 || HiddenBit < 1 )
  567. return -1;
  568. int pos = GetITBitfromIT(m_itTables.m_pHidden,
  569. &HiddenOffset,
  570. &HiddenBit,
  571. InfoTypeSize()*8 );
  572. while ( (pos!=-1) && (IsDeleted(pos)) )
  573. pos = GetITBitfromIT(m_itTables.m_pHidden,
  574. &HiddenOffset,
  575. &HiddenBit,
  576. InfoTypeSize()*8 );
  577. return pos;
  578. }
  579. int CInfoType::GetLastHidden(void) const
  580. {
  581. int i;
  582. int iLastHidden=-1, temp;
  583. int offset=-1;
  584. INFOTYPE bit=1;
  585. for (i=0; i<HowManyInfoTypes(); i++)
  586. if ( (temp = GetITBitfromIT(m_itTables.m_pHidden, &offset, &bit, InfoTypeSize()*8)) == -1)
  587. return iLastHidden;
  588. else
  589. iLastHidden = temp;
  590. return -1;
  591. }