#include "header.h" #include "sitemap.h" // Static Data // ****************** static INFOTYPE curr_bit; // used for getting the next IT in a category static int curr_cat; static int curr_offset; // There are 32 info type bits per offset. // ******************************************************** // // Methods to operate on CSitemap Categories of Information Types // // ******************************************************** void CSiteMap::AddITtoCategory(int cat, int type) { int offset; INFOTYPE *pInfoType; if ( cat < 0 ) return; m_itTables.m_aCategories[cat].c_Types++; offset = type / 32; pInfoType = m_itTables.m_aCategories[cat].pInfoType + offset; *pInfoType |= 1< The category to work on int* offset The offset into the infotype bits, an offset is 4 bytes long must be -1 for the first offset, 0 for second offset ... int* bit The first bit position to test. Return Value The decimal number of the bit position. ie. bit position 5 returns 5. */ int GetITfromCat(int* offset, INFOTYPE* bit, INFOTYPE* pInfoType, int cTypes) { INFOTYPE InfoType; if ( *offset < 0 ) *offset = 0; memcpy(&InfoType, pInfoType + *offset, sizeof(INFOTYPE) ); for(int i=BitToDec(*bit)+(*offset*32); i < cTypes; i++) { // offset: 0 1 2 if ( i % 32 == 0 )// 0-31, 32-63, 64-95 ... { (*offset)++; *bit = 1; // bit 0, 32, 64 ... depending on the offset. memcpy(&InfoType, pInfoType + *offset, sizeof(INFOTYPE) ); } if ( *bit & InfoType ) { int ret = (int)((*offset*32)+(BitToDec(*bit))); // return the decimal value of the bit position. *bit = *bit << 1; return ret; } else *bit = *bit << 1; } return -1; // There are no infotypes in this category. } // ****************************************************** // // Methods to operate on CSiteMap Exclusive Information Types // // ****************************************************** static int ExclusiveOffset = -1; // Gets incermented to zero before search begins static INFOTYPE ExclusiveBit = 1; // check bit 0 even though it is reserved. int CSiteMap::GetFirstExclusive(int offset, INFOTYPE bit) const { ExclusiveOffset = offset; ExclusiveBit = bit; int pos = GetITBitfromIT(m_itTables.m_pExclusive, &ExclusiveOffset, &ExclusiveBit, InfoTypeSize()*8 ); if( (pos!=-1) && (IsDeleted(pos)) ) pos = GetNextExclusive(); return pos; } int CSiteMap::GetNextExclusive(void) const { if ( ExclusiveOffset < -1 || ExclusiveBit < 1 ) return -1; int pos = GetITBitfromIT(m_itTables.m_pExclusive, &ExclusiveOffset, &ExclusiveBit, InfoTypeSize()*8 ); while ((pos!=-1) && (IsDeleted(pos))) pos = GetITBitfromIT(m_itTables.m_pExclusive, &ExclusiveOffset, &ExclusiveBit, InfoTypeSize()*8 ); return pos; } int CSiteMap::GetLastExclusive(void) const { int i; int iLastExclusive=-1, temp; int offset=-1; INFOTYPE bit=1; for (i=0; i< HowManyInfoTypes(); i++) if ( (temp = GetITBitfromIT(m_itTables.m_pExclusive, &offset, &bit, InfoTypeSize()*8)) == -1 ) return iLastExclusive; else iLastExclusive = temp; return -1; } // ****************************************************** // // Methods to operate on CSiteMap Hidden Information Types // // ****************************************************** static int HiddenOffset=-1; static INFOTYPE HiddenBit=1; int CSiteMap::GetFirstHidden(int offset, INFOTYPE bit) const { HiddenOffset = offset; HiddenBit = bit; int pos = GetITBitfromIT(m_itTables.m_pHidden, &HiddenOffset, &HiddenBit, InfoTypeSize()*8 ); if( (pos != -1) && (IsDeleted(pos)) ) pos = GetNextHidden(); return pos; } int CSiteMap::GetNextHidden(void) const { if ( HiddenOffset < -1 || HiddenBit < 1 ) return -1; int pos = GetITBitfromIT(m_itTables.m_pHidden, &HiddenOffset, &HiddenBit, InfoTypeSize()*8 ); while((pos!=-1) &&(IsDeleted(pos)) ) pos = GetITBitfromIT(m_itTables.m_pHidden, &HiddenOffset, &HiddenBit, InfoTypeSize()*8 ); return pos; } int CSiteMap::GetLastHidden(void) const { int i; int iLastHidden=-1, temp; int offset=-1; INFOTYPE bit=1; for (i=0; i