
#ifndef  __JBXL_CPP_EXTEND_TOOLSPP_H_
#define  __JBXL_CPP_EXTEND_TOOLSPP_H_



#include "tools++.h"
#include "tlist.h"
#include "xtools.h"


//
namespace jbxl {




/////////////////////////////////////////////////////////////////////////////////////////////
// by tList
//

template <typename T> tList* add_tList_object(tList* lt, T obj)
{
	T* pp = new T();
	*pp = obj;
	lt  = add_tList_node_bystr(lt, 0, 0, NULL, NULL, (void*)pp, sizeof(T));

	return lt;
}





template <typename T> void   del_tList_object(tList** lp)
{
	tList* lt = *lp;

	while(lt!=NULL) {
		T* pp = (T*)lt->ldat.ptr;
		pp->free();
		delete(pp);
		lt->ldat.ptr = NULL;
		lt->ldat.sz  = 0;
		lt = lt->next;
	}
	del_tList(lp);
}




}		// namespace



#endif
