2017年10月31日火曜日

CObArray <--> CObList

CObList の形式のデータを配列として処理したかったので,その相互変換(Sort_ind.hxx 内).

#ifdef  _MFC_VER
//*******************************************************************************
// ObList -> ObArray
// Create : 2017/10/30
//*******************************************************************************
inline bool To_ObArray (/*const*/ CObList& src,CObArray* dstAry)
{
 if (dstAry == NULL)  { return false ;  }
 dstAry->RemoveAll() ;
 {
  POSITION pos = src.GetHeadPosition();
  while (pos != NULL) {
   CObject* pObj = src.GetNext(pos);
   dstAry->Add(pObj) ;
   }
  }
 return true ;
 }

//*******************************************************************************
// ObArray -> ObList
// Create : 2017/10/30
//*******************************************************************************
inline bool To_ObList (const CObArray& src,CObList* dstLst)
{
 if (dstLst == NULL)  { return false ;  }
 dstLst->RemoveAll() ;
 {
  for (INT_PTR index=0 ; index<src.GetSize() ; index++) {
   CObject* pObj = src[index] ;
   dstLst->AddTail(pObj) ;
   }
  }
 return true ;
 }

#endif // _MFC_VER