Return TypeFunction nameArguments
hzEcodehdbADP::Export(void)

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

Function Logic:

0:START 1:fname bkfile 2:TestFile(*fname)==E_OK 3:open items close 4:hzChain::Printf nC 5:nC 6:hzMapS::GetObj pEnum hdbDatatype::txtType hzChain::Printf nC 7:nC 8:hzMapS::GetObj pClass hdbClass::ClassId hzMapS::Insert nC 9:nC 10:hzMapS::GetObj pClass hdbClass::DescClass 11:items hzChain::Size 12:Y.Size() 13:Y==Z 14:Return E_OK 15:Filecopy 16:ofstream::open items close 17:Return rc

Function body:

hzEcode hdbADP::Export (void)
{
   _hzfunc("hdbADP::Export") ;
   hzMapS  <uint32_t,const hdbClass*>  classesById ;
   ofstream        os ;
   ifstream        is ;
   hzChain         Z ;
   hzChain         Y ;
   const hdbEnum*  pEnum ;
   const hdbClass* pClass ;
   hzString        fname ;
   hzString        bkfile ;
   uint32_t        nC ;
   hzEcode         rc = E_OK ;
   fname = "/etc/hzDelta.d/" + m_appName + ".adp" ;
   bkfile = "/etc/hzDelta.d/" + m_appName + ".bak" ;
   threadLog("Exporting ADP to %s\n", *fname) ;
   if (TestFile(*fname) == E_OK)
   {
       is.open(*fname) ;
       Y << is ;
       is.close() ;
   }
   Z.Printf("<AppDeltaProfile app="%s">\n"  , *m_appName) ;
   for (nC = 0; nC < m_mapEnums.Count() ; nC++)
   {
       pEnum = m_mapEnums.GetObj(nC) ;
       Z.Printf("\t<enum name="%s"/>\n"  , pEnum->txtType()) ;
   }
   for (nC = 0; nC < m_mapClasses.Count() ; nC++)
   {
       pClass = m_mapClasses.GetObj(nC) ;
       classesById.Insert(pClass->ClassId(), pClass) ;
   }
   for (nC = 0; nC < classesById.Count() ; nC++)
   {
       pClass = classesById.GetObj(nC) ;
       pClass->DescClass(Z, 1);
   }
   Z << "</AppDeltaProfile>\n" ;
   if (Y.Size())
   {
       if (Y == Z)
           { threadLog("ADP is an exact match\n") ; return E_OK ; }
       threadLog("Backing up ADP\n") ;
       Filecopy(*bkfile, *fname) ;
   }
   threadLog("Exporting current ADP\n") ;
   os.open(*fname) ;
   os << Z ;
   os.close() ;
   return rc ;
}