Add an index based on the supplied member name. Find the member in the class and from the datatype, this will determine which sort of index should be set up.

Return TypeFunction nameArguments
hzEcodehdbObjRepos::InitMbrIndex(hdbMember*,bool,)

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

Function Logic:

0:START 1:items 2:unknown 3:Return hzerr(E_NOINIT,No cache class set up) 4:unknown 5:Return hzerr(E_ARGUMENT,No member supplied) 6:unknown 7:Return hzerr(E_NOTFOUND,No such member as %s in class %s\n,pMbr->txtName(),m_pClass->txtType()) 8:unknown 9:Return hzerr(E_NOTFOUND,Member %s has no defined position within the class\n,pMbr->txtName()) 10:pIdx 11:pMbr->Basetype() 12:BASETYPE_EMADDR 13:BASETYPE_URL 14:pIdx

Function body:

hzEcode hdbObjRepos::InitMbrIndex (hdbMember* pMbr)bool bUnique, 
{
   //  Add an index based on the supplied member name. Find the member in the class and from the datatype, this will determine which sort of index
   //  should be set up.
   //  
   //  Arguments: 1) mbrName Name of member index shall apply to
   //     2) bUnique Flag if value uniqness applies
   //  
   //  Returns: E_NOINIT If the cache initialization sequence has not been started
   //     E_ARGUMENT If the member name is not supplied
   //     E_SEQUENCE If the cache initialization has been completed by InitDone()
   //     E_NOTFOUND If the named member is not found in the cache class
   //     E_TYPE  If the named member is of a type that cannot accept an index
   //     E_OK  If the index is successfully created
   _hzfunc("hdbObjRepos::InitMbrIndex") ;
   hdbIndex*   pIdx ;      //  The index to be added
   hzString    iname ;     //  Index name of the form repos::member
   hzEcode     rc = E_OK ; //  Return code
   //  Check init state
   _hdb_ck_initstate(m_Name, m_eReposInit, HDB_REPOS_INIT_PROG) ;
   if (!m_pClass)  return hzerr(E_NOINIT, "No cache class set up") ;
   if (!pMbr)      return hzerr(E_ARGUMENT, "No member supplied") ;
   if (pMbr->Class() != m_pClass)
       return hzerr(E_NOTFOUND, "No such member as %s in class %s\n", pMbr->txtName(), m_pClass->txtType()) ;
   if (pMbr->Posn() < 0|| pMbr->Posn() >&eq; m_pClass->MbrCount())
       return hzerr(E_NOTFOUND, "Member %s has no defined position within the class\n", pMbr->txtName()) ;
   //  Member's datatype will determine the type of index
   pIdx = 0;
   switch  (pMbr->Basetype())
   {
   case BASETYPE_EMADDR:
   case BASETYPE_URL:      pIdx = new hdbIndexUkey() ;
                           break ;
   case BASETYPE_STRING:
   case BASETYPE_IPADDR:
   case BASETYPE_TIME:
   case BASETYPE_SDATE:
   case BASETYPE_XDATE:
   case BASETYPE_DOUBLE:
   case BASETYPE_INT64:
   case BASETYPE_INT32:
   case BASETYPE_UINT64:
   case BASETYPE_UINT32:
   case BASETYPE_UINT16:
   case BASETYPE_UBYTE:    pIdx = new hdbIndexUkey() ;
                           break ;
   case BASETYPE_INT16:
   case BASETYPE_BYTE:
   case BASETYPE_ENUM:     pIdx = new hdbIndexEnum() ;
                           break ;
   case BASETYPE_TEXT:
   case BASETYPE_TXTDOC:   pIdx = new hdbIndexText() ;
                           break ;
   case BASETYPE_CLASS:
   case BASETYPE_BINARY:   hzerr(E_TYPE, "Invalid member type. No Index allowed") ;
                           rc = E_TYPE ;
                           break ;
   default:
       break ;
   }
   m_mapIndex.Insert(pMbr->DeltaId(), pIdx) ;
   //  m_mapIndex.Insert(pMbr->Posn(), pIdx) ;
   m_eReposInit = HDB_REPOS_INIT_PROG ;
   return rc ;
}