Return TypeFunction nameArguments
boolhdbIsamfile::Exists(const hzString&,)

Declared in file: hzDatabase.h
Defined in file : hdbIsamfile.cpp

Function Logic:

0:START 1:hzChain::Clear m_Cond hzChain::Printf 2:m_nInitState<1 3:hzwarn 4:Return false 5:m_nInitState<2 6:hzwarn 7:Return false 8:!key 9:Return false 10:!m_Index.Count() 11:Return false 12:hzMapM::Target nPos 13:nPos>=m_Index.Count() 14:hzMapM::Count nPos 15:hzMapM::GetKey strA 16:strA>key 17:items 18:nPos 19:m_Index.GetKey(nPos)>key 20:hzMapM::GetObj addr ifstream::seekg ifstream::fail 21:m_RdD.fail() 22:m_Cond hzChain::Printf 23:Return false 24:ifstream::read ifstream::fail 25:m_RdD.fail() 26:m_Cond hzChain::Printf 27:Return false 28:nC 29:m_Buf[nC]==(char)10 30:* 31:!strA 32:strA j 33:*j 34:strB 35:j 36:!strA 37:hzMapM::Insert strB strA 38:Return tmp.Exists(key)

Function body:

bool hdbIsamfile::Exists (const hzString& key)
{
   _hzfunc("hdbIsamfile::Exists") ;
   hzMapM<hzString,hzString>   tmp ;
   char*       i ;
   char*       j ;
   hzString    strA ;
   hzString    strB ;
   uint32_t    nPos ;
   uint32_t    addr ;
   uint32_t    nC ;
   m_Error.Clear() ;
   m_Cond = E_OK ;
   m_Error.Printf("%s called\n", *_fn) ;
   if (m_nInitState < 1)   { hzwarn(E_NOINIT, "ISAM file not initialized") ; return false ; }
   if (m_nInitState < 2)   { hzwarn(E_NOTOPEN, "ISAM file not open") ; return false ; }
   if (!key)
       return false ;
   if (!m_Index.Count())
       return false ;
   nPos = m_Index.Target(key) ;
   if (nPos >&eq; m_Index.Count())
       nPos = m_Index.Count() -1;
   strA = m_Index.GetKey(nPos) ;
   if (strA > key)
       nPos-- ;
   for (; nPos < m_Index.Count() ; nPos++)
   {
       if (m_Index.GetKey(nPos) > key)
           break ;
       addr = m_Index.GetObj(nPos) ;
       m_RdD.seekg(addr * m_nBlkSize) ;
       if (m_RdD.fail())
           { m_Cond = E_READFAIL ; m_Error.Printf("%s: Failed to seek to block %d (position %d) in data block\n", *_fn, addr, addr * m_nBlkSize) ; return false ; }
       m_RdD.read(m_Buf, HZ_BLOCKSIZE) ;
       if (m_RdD.fail())
           { m_Cond = E_READFAIL ; m_Error.Printf("%s: Failed to read block %d (position %d) in data block\n", *_fn, addr, addr * m_nBlkSize) ; return false ; }
       for (i = j = m_Buf, nC = 0; nC < HZ_BLOCKSIZE ; i++, nC++)
       {
           if (m_Buf[nC] == CHAR_NL)
           {
               *i = 0;
               if (!strA)
                   { strA = j ; j = i + 1; continue ; }
               if (*j)
                   strB = j ;
               j = i + 1;
               if (!strA)
                   break ;
               tmp.Insert(strA, strB) ;
               strA = strB = (char*) 0;
           }
       }
   }
   return tmp.Exists(key) ;
}