本文整理汇总了C++中DBObjTableField::StartByte方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTableField::StartByte方法的具体用法?C++ DBObjTableField::StartByte怎么用?C++ DBObjTableField::StartByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTableField
的用法示例。
在下文中一共展示了DBObjTableField::StartByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RedefineField
void DBObjTable::RedefineField(DBObjTableField *field, DBObjTableField *newField) {
DBInt recID, fieldID;
DBObjRecord *record, *oldRecord;
DBObjTableField *tmpField;
newField->StartByte(field->StartByte());
if (field->Length() != newField->Length()) {
RecordLengthVAR += (newField->Length() - field->Length());
for (fieldID = field->RowID() + 1; fieldID < FieldNum(); ++fieldID) {
tmpField = Field(fieldID);
tmpField->StartByte(tmpField->StartByte() + newField->Length() - field->Length());
}
}
for (recID = 0; recID < ItemNum(); recID++) {
record = Item(recID);
oldRecord = new DBObjRecord(*record);
if (field->Length() != newField->Length()) {
record->Realloc(RecordLengthVAR);
if (newField->StartByte() + newField->Length() < RecordLengthVAR)
memcpy(((char *) record->Data()) + newField->StartByte() + newField->Length(),
((char *) oldRecord->Data()) + field->StartByte() + field->Length(),
RecordLengthVAR - (newField->StartByte() + newField->Length()));
}
switch (newField->Type()) {
case DBTableFieldString:
newField->String(record, field->String(oldRecord));
break;
case DBTableFieldInt:
newField->Int(record, field->Int(oldRecord));
break;
case DBTableFieldFloat:
newField->Float(record, field->Float(oldRecord));
break;
case DBTableFieldDate:
newField->Date(record, field->Date(oldRecord));
break;
case DBTableFieldCoord:
newField->Coordinate(record, field->Coordinate(oldRecord));
break;
case DBTableFieldRegion:
newField->Region(record, field->Region(oldRecord));
break;
case DBTableFieldPosition:
newField->Position(record, field->Position(oldRecord));
break;
case DBTableFieldTableRec:
case DBTableFieldDataRec:
newField->Record(record, field->Record(oldRecord));
break;
}
delete oldRecord;
}
if (strcmp(field->Name(), newField->Name()) != 0) field->Name(newField->Name());
if (field->Type() != newField->Type()) field->Type(newField->Type());
if (field->FormatWidth() != newField->FormatWidth()) field->FormatWidth(newField->FormatWidth());
if ((field->Type() == DBTableFieldFloat) && (field->FormatDecimals() != field->FormatDecimals()))
field->FormatDecimals(newField->FormatDecimals());
if (field->Length() != newField->Length()) field->Length(newField->Length());
}
示例2: DeleteField
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;
}