void DBObjTable::AddField(DBObjTableField *field) { DBInt recID; DBObjRecord *record; field->StartByte(RecordLengthVAR); FieldPTR->Add(field); RecordLengthVAR += field->Length(); for (recID = 0; recID < ItemNum(); recID++) { record = Item(recID); record->Realloc(RecordLengthVAR); switch (field->Type()) { case DBTableFieldString: field->String(record, ""); break; case DBTableFieldInt: field->Int(record, field->IntNoData()); break; case DBTableFieldFloat: field->Float(record, field->FloatNoData()); break; case DBTableFieldDate: field->Date(record, field->DateNoData()); break; } } }
void DBObjTable::DeleteAllFields() { DBObjRecord *record; FieldPTR->DeleteAll(); RecordLengthVAR = 0; for (record = First(); record != (DBObjRecord *) NULL; record = Next()) record->Realloc(RecordLengthVAR); }
void DBObjTable::DeleteField(DBObjTableField *delField) { DBInt i, recID, fieldID; DBObjRecord *record; DBObjTableField *field; unsigned char *data; for (fieldID = 0; fieldID < FieldPTR->ItemNum(); ++fieldID) { field = FieldPTR->Item(fieldID); if (field->StartByte() > delField->StartByte()) field->StartByte(field->StartByte() - delField->Length()); } for (recID = 0; recID < ItemNum(); ++recID) { record = Item(recID); data = (unsigned char *) record->Data() + delField->StartByte(); for (i = 0; i < RecordLengthVAR - delField->StartByte() - delField->Length(); ++i) data[i] = data[i + delField->Length()]; record->Realloc(RecordLengthVAR - delField->Length()); } FieldPTR->Remove(delField); RecordLengthVAR -= delField->Length(); delete delField; }
void DBVLineIF::Vertexes (DBObjRecord *lineRec,DBCoordinate *coord,DBInt vertexNum) { DBInt vertex; DBFloat length = 0; DBCoordinate *vertexes, prevCoord; DBObjRecord *dataRec = (DBObjRecord *) NULL; DBObjectLIST<DBObjRecord> *dataArrays = Data ()->Arrays (); DBRegion lineExtent, dataExtent = Data ()->Extent (); DBMathDistanceFunction distFunc = DBMathGetDistanceFunction (Data ()); prevCoord = NodeCoordFLD->Coordinate (FromNodeFLD->Record (lineRec)); lineExtent.Expand (prevCoord); if (vertexNum > 0) { if ((dataRec = dataArrays->Item (lineRec->RowID ())) == (DBObjRecord *) NULL) { if ((dataRec = new DBObjRecord (lineRec->Name (),((size_t) vertexNum) * sizeof (DBCoordinate),sizeof (DBFloat))) == (DBObjRecord *) NULL) return; dataArrays->Add (dataRec); } else dataRec->Realloc (vertexNum * sizeof (DBCoordinate)); if ((vertexes = (DBCoordinate *) dataRec->Data ()) == NULL) { CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return; } for (vertex = 0;vertex < vertexNum;vertex++) { lineExtent.Expand (vertexes [vertex] = coord [vertex]); length += DBMathCoordinateDistance (distFunc,prevCoord,coord [vertex]); prevCoord = coord [vertex]; } } VertexesFLD->Record (lineRec,dataRec); VertexNumFLD->Int (lineRec,vertexNum); length += DBMathCoordinateDistance (distFunc,prevCoord,NodeCoordFLD->Coordinate (ToNodeFLD->Record (lineRec))); PerimeterFLD->Float (lineRec,length); lineExtent.Expand (NodeCoordFLD->Coordinate (ToNodeFLD->Record (lineRec))); ExtentFLD->Region (lineRec,lineExtent); dataExtent.Expand (lineExtent); Data ()->Extent (dataExtent); }