Arreglos y añadidos varios en columnas dbf
parent
2b48c1f27f
commit
1711c3a826
|
|
@ -249,7 +249,9 @@ void GdataTable::removeColm(int i)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
colm.remove(i);
|
||||||
|
buf.remove(i);
|
||||||
|
colmName.borra(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
@ -389,6 +391,13 @@ char* GdataTable::getName( int icol )
|
||||||
return colmName.get(icol);
|
return colmName.get(icol);
|
||||||
}
|
}
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
bool GdataTable::rename(int icol, char *nomb)
|
||||||
|
{
|
||||||
|
if (icol<0 || icol>colm.n)
|
||||||
|
return 0;
|
||||||
|
return colmName.replace(icol,nomb);
|
||||||
|
}
|
||||||
|
//***************************************************************************
|
||||||
bool GdataTable::addMemRow( int nrow )
|
bool GdataTable::addMemRow( int nrow )
|
||||||
{
|
{
|
||||||
for(int i =0; i<buf.n; i++)
|
for(int i =0; i<buf.n; i++)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public:
|
||||||
int getSizeASCII(int icol);
|
int getSizeASCII(int icol);
|
||||||
|
|
||||||
char* getName(int icol);
|
char* getName(int icol);
|
||||||
|
bool rename(int icol, char* nomb);
|
||||||
int* getI(int row, int colm);
|
int* getI(int row, int colm);
|
||||||
__int64* getI64(int row, int colm);
|
__int64* getI64(int row, int colm);
|
||||||
double* getD(int row, int colm);
|
double* getD(int row, int colm);
|
||||||
|
|
|
||||||
|
|
@ -22,31 +22,78 @@ bool ManagerDbfGdataTable::DbfSet( int nrow, int ncolm )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
bool ManagerDbfGdataTable::DelCol(char* path, char* name)
|
||||||
|
{
|
||||||
|
GdataTable tb;
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
if (!LeeDbf(path, &tb))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_dt = &tb;
|
||||||
|
}
|
||||||
|
else if (!_dt)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ic = _dt->getInd(name);
|
||||||
|
|
||||||
|
if (ic < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dt->removeColm(ic);
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
if (!grabaDbf(path, _dt))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//***************************************************************************
|
||||||
bool ManagerDbfGdataTable::AddCol( char* path, char* name, BYTE type,IAddColDbf *dt, int size)
|
bool ManagerDbfGdataTable::AddCol( char* path, char* name, BYTE type,IAddColDbf *dt, int size)
|
||||||
{
|
{
|
||||||
GdataTable tb;
|
GdataTable tb;
|
||||||
|
|
||||||
if(!LeeDbf(path, &tb))
|
if (path)
|
||||||
|
{
|
||||||
|
if (!LeeDbf(path, &tb))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_dt = &tb;
|
||||||
|
}
|
||||||
|
else if(!_dt)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
int ic=tb.getInd(name);
|
}
|
||||||
|
|
||||||
|
int ic= _dt->getInd(name);
|
||||||
|
|
||||||
if(ic<0)
|
if(ic<0)
|
||||||
{
|
{
|
||||||
//la crea
|
//la crea
|
||||||
if(!tb.addColm(name,type,size))
|
if(!_dt->addColm(name,type,size))
|
||||||
return false;
|
return false;
|
||||||
ic=tb.nColm()-1;
|
ic= _dt->nColm()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dt->size = tb.getSize(ic);
|
dt->size = _dt->getSize(ic);
|
||||||
|
|
||||||
for(int i=0;i<tb.nRow();i++)
|
for(int i=0;i< _dt->nRow();i++)
|
||||||
{
|
{
|
||||||
dt->setData(i, tb.get(i,ic));
|
dt->setData(i, _dt->get(i,ic));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!grabaDbf(path,&tb))
|
if (path)
|
||||||
return false;
|
{
|
||||||
|
if (!grabaDbf(path, _dt))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class UTILES_EXPORT ManagerDbfGdataTable: public ListenerDbf_W, public ListenerD
|
||||||
bool LeeDbf(char* path, GdataTable *dt);
|
bool LeeDbf(char* path, GdataTable *dt);
|
||||||
bool grabaDbf(char* path, GdataTable *dt);
|
bool grabaDbf(char* path, GdataTable *dt);
|
||||||
bool AddCol( char* path, char* name, BYTE type,IAddColDbf *dt, int size=0);
|
bool AddCol( char* path, char* name, BYTE type,IAddColDbf *dt, int size=0);
|
||||||
|
bool DelCol(char* path, char* name);
|
||||||
|
|
||||||
//funciones de herencia----------------------------------------
|
//funciones de herencia----------------------------------------
|
||||||
//LisenerDbf_R-------------------------------------------------
|
//LisenerDbf_R-------------------------------------------------
|
||||||
|
|
|
||||||
55
StrArray.cpp
55
StrArray.cpp
|
|
@ -164,4 +164,59 @@ StrArray* StrArray::filtra( StrArray*buf, char *filter )
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
//***********************************************************************
|
||||||
|
BOOL StrArray::replace(int i, char* cadena)
|
||||||
|
{
|
||||||
|
if (i < 0 || i >= n_i)
|
||||||
|
return FALSE;
|
||||||
|
int dif = strlen(cadena) - strlen(get(i));
|
||||||
|
int aux = 1024;
|
||||||
|
int ult;
|
||||||
|
int i_i;
|
||||||
|
if (dif > 0)
|
||||||
|
{
|
||||||
|
//comprueba memo-------------------
|
||||||
|
if (n_str + dif >= m_str)
|
||||||
|
{
|
||||||
|
if (aux < dif)
|
||||||
|
aux += dif;
|
||||||
|
//pedir-----------------------
|
||||||
|
m_str = m_str + aux;
|
||||||
|
str = (char*)realloc(str, m_str);
|
||||||
|
memset(&str[m_str - aux], 0, aux);
|
||||||
|
}
|
||||||
|
//desplazar-----------------------
|
||||||
|
//ult=(*ind)[n_i-1]+strlen(dame_str(n_i-1))+1;
|
||||||
|
ult = n_str - 1;
|
||||||
|
if (i + 1 < n_i)
|
||||||
|
i_i = (*ind)[i + 1] - 1;
|
||||||
|
else
|
||||||
|
i_i = ult;
|
||||||
|
//i_i=(*ind)[i]+strlen(dame_str(i))+1;
|
||||||
|
//ult=strlen(&str[ult])+1;
|
||||||
|
for (int k = ult; k >= i_i; k--)
|
||||||
|
str[k + dif] = str[k];
|
||||||
|
//copiamos-----------------------
|
||||||
|
strcpy(get(i), cadena);
|
||||||
|
//aumentamos indices-------------
|
||||||
|
for (int k = i + 1; k < n_i; k++)
|
||||||
|
(*ind)[k] += dif;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(get(i), cadena);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//***********************************************************************
|
||||||
|
int StrArray::find(char* st)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n_i; i++)
|
||||||
|
{
|
||||||
|
if (!strcmp(&str[(*ind)[i]], st))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ public:
|
||||||
void borra();//borra todo
|
void borra();//borra todo
|
||||||
void compacta();//reduce al minimo la memoria necesaria para comtener la informacion
|
void compacta();//reduce al minimo la memoria necesaria para comtener la informacion
|
||||||
StrArray* filtra(StrArray*buf, char *filter);
|
StrArray* filtra(StrArray*buf, char *filter);
|
||||||
|
BOOL replace(int i, char* cadena);
|
||||||
|
int find(char* st);
|
||||||
//funciones aux-------------------------
|
//funciones aux-------------------------
|
||||||
private:
|
private:
|
||||||
void cuida_memoria(int n,int ni=1);//asegura tener memoria para un str mas
|
void cuida_memoria(int n,int ni=1);//asegura tener memoria para un str mas
|
||||||
|
|
|
||||||
20
utiles.rc
20
utiles.rc
|
|
@ -16,13 +16,11 @@
|
||||||
#undef APSTUDIO_READONLY_SYMBOLS
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// English (U.S.) resources
|
// Inglés (Estados Unidos) resources
|
||||||
|
|
||||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
#ifdef _WIN32
|
|
||||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
#pragma code_page(1252)
|
#pragma code_page(1252)
|
||||||
#endif //_WIN32
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
@ -30,8 +28,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,0,0,8
|
FILEVERSION 1,0,0,9
|
||||||
PRODUCTVERSION 1,0,0,8
|
PRODUCTVERSION 1,0,0,9
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
|
@ -48,11 +46,11 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Narvaling"
|
VALUE "CompanyName", "Narvaling"
|
||||||
VALUE "FileDescription", "Librería de utilidades"
|
VALUE "FileDescription", "Librería de utilidades"
|
||||||
VALUE "FileVersion", "1.0.0.8"
|
VALUE "FileVersion", "1.0.0.9"
|
||||||
VALUE "InternalName", "utiles.dll"
|
VALUE "InternalName", "utiles.dll"
|
||||||
VALUE "OriginalFilename", "utiles.dll"
|
VALUE "OriginalFilename", "utiles.dll"
|
||||||
VALUE "ProductName", "Utiles"
|
VALUE "ProductName", "Utiles"
|
||||||
VALUE "ProductVersion", "1.0.0.8"
|
VALUE "ProductVersion", "1.0.0.9"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
@ -61,18 +59,16 @@ BEGIN
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
#endif // English (U.S.) resources
|
#endif // Inglés (Estados Unidos) resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Spanish resources
|
// Español (España, alfabetización internacional) resources
|
||||||
|
|
||||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN)
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN)
|
||||||
#ifdef _WIN32
|
|
||||||
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN
|
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN
|
||||||
#pragma code_page(1252)
|
#pragma code_page(1252)
|
||||||
#endif //_WIN32
|
|
||||||
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -112,7 +108,7 @@ END
|
||||||
|
|
||||||
#endif // APSTUDIO_INVOKED
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
#endif // Spanish resources
|
#endif // Español (España, alfabetización internacional) resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue