InsertColm

master
Gerardo 2020-06-03 22:34:02 +02:00
parent 62033526b6
commit f655918b99
3 changed files with 98 additions and 0 deletions

View File

@ -160,6 +160,84 @@ bool GdataTable::addColm(char* name, int type, int size)
return false;
return true;
}
//***************************************************************************
bool GdataTable::InsertColm(int icol, char* name, int type, int size)
{
return false;
/*if(icol <colmName.n_i)
colmName.a*/
colmName.add(name);
GdataTableColum inf;
void* c = NULL;
inf.flags = 0;
inf.nb = size;
inf.type = type;
int nn = nRow();
switch (type)
{
case(Tbool):
c = new Cgarray<bool>();
if (!inf.nb)
inf.nb = sizeof(bool);
if (nn > 0)
{
if (!((*(Cgarray<bool>*)c) += nn))
return false;
((Cgarray<bool>*)c)->n = nn;
}
break;
case(Tint):
c = new Cgarray<int>();
inf.nb = sizeof(long);
if (nn > 0)
{
if (!((*(Cgarray<int>*)c) += nn))
return false;
((Cgarray<int>*)c)->n = nn;
}
break;
case(Tdouble):
c = new Cgarray<double>();
inf.nb = sizeof(double);
if (nn > 0)
{
if (!((*(Cgarray<double>*)c) += nn))
return false;
((Cgarray<double>*)c)->n = nn;
}
break;
case(Tint64):
c = new Cgarray<__int64>();
inf.nb = sizeof(__int64);
if (nn > 0)
{
if (!((*(Cgarray<__int64>*)c) += nn))
return false;
((Cgarray<__int64>*)c)->n = nn;
}
break;
case(Tstring):
case(Tbin):
c = new Cgarray<char>();
if (nn > 0)
{
if (!((*(Cgarray<char>*)c) += (nn*inf.nb)))
return false;
((Cgarray<char>*)c)->n = (nn*inf.nb);
}
break;
default:
return false;
}
if (!c)
return false;
if (!(buf + c))
return false;
if (!(colm + inf))
return false;
return true;
}
//***************************************************************************
void GdataTable::delAll()
{

View File

@ -56,6 +56,8 @@ public:
//adicionar-----------------------------
bool addColm(char* name, int type, int size=0);
bool InsertColm(int icol, char* name, int type, int size = 0);
bool addRow(int nrow);
bool addMemRow(int nrow);
//borrado-------------------------------

View File

@ -199,6 +199,24 @@ public:
return TRUE ;
};*/
//**************************************************************
inline BOOL insert(int pos, T *e, int ne = 1) //inserta apartir de la posicion pos los elementos de la lista, desplaza los existentes para alante
{
if (pos >= n)
return add(e, ne);
int inc = n + ne - m;
if (!e || ne <= 0)
return FALSE;
if (!operator+=(inc))
return false;
//adelanta los elementos necesarios
for (int i = n - 1; i >= pos; i--)
ptr[i + ne] = ptr[i];
memcpy(&ptr[pos], e, ne * sizeof(T));
n += ne;
return TRUE;
};
//**************************************************************
inline BOOL add(T *e, int ne) //añade una lista de elementos
{
int inc=n+ne-m;