Populate the hdbObject with the supplied hzChain content, which must be an EDO. This function is strictly for the purposes of LOADING from a hdbObjRepos cache. Please note the following:- a) In the case of STRING and string-like datum, the string space address is copied from the EDO but then the member core space is cast to the applicable class in order to keep proper track of the string space copy count. b) For BINARY and TXTDOC members, the binary datum address appears in the EDO and is copied to the aux, rather than the core space. The core space only comes into play when the binary is fetched, at which point the core space is cast to a hzChain (in order to keep track of the copy count). c) For single selection ENUM members, the core space is 1 byte. For multiple selection ENUM members, the core space is however many bytes are needed to hold the bitmap covering the entire ENUM population. In the latter case, the EDO entry for the member will have a length indicator (1 byte), followed by an idset encoding. d) For subclass members, the EDO will either contain the address of the subclass objects or a list of EDOs representing the actual subclass objects - depending on the repository configuration. By default repositories do not store data objects, be those of the host native data class, or of any subclass.

Return TypeFunction nameArguments
hzEcodehdbObject::ImportEDO(hzChain&,)

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

Function Logic:

0:START 1:unknown 2:items 3:unknown 4:m_pRoot m_pRoot 5:pLitmus zi rc 6:unknown 7:Return hzerr(rc,Could not process EDO length) 8:items items zend zend rc 9:unknown 10:Return hzerr(rc,Could not process EDO Object Id) 11:bitMask 12:unknown 13:unknown 14:items pLitmus 15:bitMask 16:unknown 17:bitMask items 18:unknown 19:items 20:unknown 21:pMbr 22:unknown 23:unknown 24:m_pRoot 25:pMCS 26:unknown 27:unknown 28:pMCS 29:pEnum 30:unknown 31:unknown 32:unknown 33:pMCS 34:m_pRoot 35:pMCS 36:unknown 37:pMCS 38:unknown 39:items 40:unknown 41:pStr 42:unknown 43:items 44:unknown 45:pDom 46:unknown 47:items 48:unknown 49:pEma 50:unknown 51:items 52:unknown 53:pUrl 54:unknown 55:items 56:unknown 57:rc 58:unknown 59:items 60:Return rc

Function body:

hzEcode hdbObject::ImportEDO (hzChain& Z)
{
   //  Populate the hdbObject with the supplied hzChain content, which must be an EDO. This function is strictly for the purposes of LOADING from a hdbObjRepos cache. Please note
   //  the following:-
   //  
   //   a) In the case of STRING and string-like datum, the string space address is copied from the EDO but then the member core space is cast to the applicable class in order
   //    to keep proper track of the string space copy count.
   //  
   //   b) For BINARY and TXTDOC members, the binary datum address appears in the EDO and is copied to the aux, rather than the core space. The core space only comes into play
   //    when the binary is fetched, at which point the core space is cast to a hzChain (in order to keep track of the copy count).
   //  
   //   c) For single selection ENUM members, the core space is 1 byte. For multiple selection ENUM members, the core space is however many bytes are needed to hold the bitmap
   //    covering the entire ENUM population. In the latter case, the EDO entry for the member will have a length indicator (1 byte), followed by an idset encoding.
   //  
   //   d) For subclass members, the EDO will either contain the address of the subclass objects or a list of EDOs representing the actual subclass objects - depending on the
   //    repository configuration. By default repositories do not store data objects, be those of the host native data class, or of any subclass.
   //  
   //  Argument: Z The input serialize object
   //  
   //  Returns: E_FORMAT If the supplied chain does not comply with the expected format
   //     E_OK  If the operation is successful
   _hzfunc("hdbObject::ImportEDO") ;
   const hdbMember*    pMbr ;          //  This class member
   hzMD5               digest ;        //  MD5
   chIter              zi ;            //  Input iterator
   chIter              zend ;          //  Input iterator (expected end)
   _atomval            av ;            //  For 64 and 32 bit values
   const hdbEnum*      pEnum ;         //  ENUM data type (if applicable)
   uchar*              pLitmus ;       //  Litmus bits
   uchar*              pMCS ;          //  Pointer to member core space
   hzString*           pStr ;          //  Cast to string
   hzDomain*           pDom ;          //  Cast to domain
   hzEmaddr*           pEma ;          //  Cast to emaddr
   hzUrl*              pUrl ;          //  Cast to URL
   hzString            S ;             //  Temp string
   uint32_t            mbrNo ;         //  Member number (position within class)
   uint32_t            nLenEDO ;       //  EDO tail length
   uint32_t            nObjId ;        //  Object id
   uint32_t            nC ;            //  Counter
   uint32_t            bitMask ;       //  Litmus bit mask
   hzEcode             rc ;            //  Return code
   //  Object has class?
   if (!m_pClass)
       hzexit(E_NOINIT, "Object has no class") ;
   if (!m_pRoot)
       m_pRoot = _obj_data::GetInstance(m_pClass) ;
   pLitmus = m_pRoot->m_Core + m_pClass->CoreLen() ;
   //  Obtain the EDO length and object id
   zi = Z ;
   rc = ReadSerialUINT32(nLenEDO, zi) ;
   if (rc != E_OK)
       return hzerr(rc, "Could not process EDO length") ;
   memset(m_pRoot->m_Core, 0,m_pClass->CoreLen()) ;
   memset(pLitmus, 0,m_pClass->MbrCount()) ;
   zend = zi ;
   zend += nLenEDO ;
   rc = ReadSerialUINT32(nObjId, zi) ;
   if (rc != E_OK)
       return hzerr(rc, "Could not process EDO Object Id") ;
   //  threadLog("Reading EDO %u of %u bytes\n", nObjId, nLenEDO) ;
   //  Grab the litmus bits
   bitMask = 128;
   for (mbrNo = nC = 0; mbrNo < m_pClass->MbrCount() ; mbrNo++)
   {
       if (*zi & bitMask)
           { nC++ ; pLitmus[mbrNo] = LITMUS_SET ; }
       bitMask /= 2;
       if (bitMask == 0)
           { bitMask = 128;zi++; }
   }
   if (bitMask < 128)
       zi++ ;
   //  Count up how many entries the fixed part will have
   for (mbrNo = 0; rc == E_OK && mbrNo < m_pClass->MbrCount() ; mbrNo++)
   {
       pMbr = m_pClass->GetMember(mbrNo) ;
       if (pLitmus[mbrNo] == 0)
           continue ;
       if (pMbr->Basetype() == BASETYPE_BOOL || pMbr->Basetype() == BASETYPE_TBOOL)
           continue ;
       //  Set pointer to member core space
       pMCS = m_pRoot->m_Core + pMbr->OsetStd() ;
       if (pMbr->Basetype() == BASETYPE_ENUM)
       {
           if (pMbr->Singular())
           {
               //  Single selection, only 1 byte
               pMCS[0]= *zi++ ;
               continue ;
           }
           //  Multiple selections allowed, so treat the EDO entry as an idset-encoded bitmap
           pEnum = dynamic_cast<const hdbEnum*>(pMbr->Datatype()) ;
           if (pEnum->Count() < 31)
           {
               //  In this case the length is 4 bytes
           }
           continue ;
       }
       if (pMbr->Basetype() == BASETYPE_BINARY || pMbr->Basetype() == BASETYPE_TXTDOC)
       {
           //  The EDO will only contain the address (uint32_t), which must go in the member AUX area
           for (nC = 0; !zi.eof() && nC < 4; nC++, zi++)
           {
               pMCS[nC] = *zi ;
           }
           continue ;
       }
       pMCS = m_pRoot->m_Core + pMbr->OsetStd() ;
       for (nC = 0; !zi.eof() && nC < pMbr->SizeDatum() ; nC++, zi++)
       {
           pMCS[nC] = *zi ;
       }
       if (nC < pMbr->SizeDatum())
       {
           threadLog("Incomplete read of member %s\n", pMbr->txtName()) ;
           break ;
       }
       if (pMbr->Basetype() == BASETYPE_STRING || pMbr->Basetype() == BASETYPE_APPDEF)
       {
           pStr = (hzString*) pMCS ;
           if (pStr)
               pStr->_inc_copy() ;
       }
       if (pMbr->Basetype() == BASETYPE_DOMAIN)
       {
           pDom = (hzDomain*) pMCS ;
           if (*pDom)
               pDom->_inc_copy() ;
       }
       if (pMbr->Basetype() == BASETYPE_EMADDR)
       {
           pEma = (hzEmaddr*) pMCS ;
           if (*pEma)
               pEma->_inc_copy() ;
       }
       if (pMbr->Basetype() == BASETYPE_URL)
       {
           pUrl = (hzUrl*) pMCS ;
           if (*pUrl)
               pUrl->_inc_copy() ;
       }
   }
   if (zi != zend)
   {
       rc = hzerr(E_CORRUPT, "Object Id %u: Not at EDO end\n", nObjId) ;
       for (zi = Z, nC = 0; !zi.eof() && nC <&eq; nLenEDO ; nC++, zi++)
       {
           threadLog("%u: char is %02x\n", nC, (uchar) *zi) ;
       }
   }
   return rc ;
}