本文整理汇总了C++中DBObjTable::FieldNum方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTable::FieldNum方法的具体用法?C++ DBObjTable::FieldNum怎么用?C++ DBObjTable::FieldNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTable
的用法示例。
在下文中一共展示了DBObjTable::FieldNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _RGISGrpPanelDeleteCBK
static void _RGISGrpPanelDeleteCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *groupTable = dbData->Table (DBrNGroups);
DBObjTableField *group = grpPanel->Current ();
static Widget fieldSelect = (Widget) NULL;
if (fieldSelect == (Widget) NULL) fieldSelect = UISelectionCreate ((char *) "Group Selection");
if ((groupTable == (DBObjTable *) NULL) || (group == (DBObjTableField *) NULL)) return;
if (groupTable->FieldNum () == 1) grpPanel->Groups ((DBObjectLIST<DBObjTableField> *) NULL);
grpPanel->Remove (group);
groupTable->DeleteField (group);
if (groupTable->FieldNum () == 0)
{
DBObjectLIST<DBObjTable> *tables = dbData->Tables ();
tables->Remove (groupTable);
delete groupTable;
}
}
示例2: _RGISToolsExportNetworkCBK
static void _RGISToolsExportNetworkCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
FILE *outFILE;
DBInt cellID, fieldID, fieldNum = 0;
DBCoordinate coord;
DBObjRecord *cellRec,*toCellRec, *basinRec;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBNetworkIF *netIF = new DBNetworkIF (netData);
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTableField *field, **fields = (DBObjTableField **) NULL;
static Widget dirSelect = NULL;
widget = widget; workspace = workspace; callData = callData;
if (dirSelect == NULL)
{ if ((dirSelect = UIFileSelectionCreate ((char *) "Network File",NULL,(char *) "*.txt",XmFILE_REGULAR)) == NULL) return; }
if ((selection = UIFileSelection (dirSelect,False)) == NULL) return;
if ((outFILE = fopen (selection,"w")) == (FILE *) NULL)
{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }
fprintf (outFILE,"\"CellID\"\t\"XCoord\"\t\"YCoord\"\t\"BasinID\"\t\"ToCell\"\t\"CellArea\"\t\"CellLength\"");
for (fieldID = 0;fieldID < cellTable->FieldNum (); fieldID++)
{
if ((field = cellTable->Field (fieldID)) == (DBObjTableField *) NULL)
{
if (fields != (DBObjTableField **) NULL) free (fields);
CMmsgPrint (CMmsgSysError, "Invalid field in: %s %d",__FILE__,__LINE__);
return;
}
if (field->Required ()) continue;
if ((fields = (DBObjTableField **) realloc (fields,(fieldNum + 1) * sizeof (DBObjTableField *))) == (DBObjTableField **) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory allocation error in: %s %d",__FILE__,__LINE__); return; }
fields [fieldNum] = field;
fprintf (outFILE,"\t\"%s\"",field->Name ());
fieldNum++;
}
fprintf (outFILE,"\n");
for (cellID = 0;cellID < netIF->CellNum (); cellID++)
{
cellRec = netIF->Cell (cellID);
coord = netIF->Center (cellRec);
basinRec = netIF->Basin (cellRec);
toCellRec = netIF->ToCell (cellRec);
fprintf (outFILE,"%d\t%f\t%f\t%d\t%d\t%f\t%f",cellRec->RowID () + 1,
coord.X, coord.Y,
basinRec->RowID () + 1,
toCellRec == (DBObjRecord *) NULL ? DBFault : toCellRec->RowID () + 1,
netIF->CellArea (cellRec),
netIF->CellLength (cellRec));
for (fieldID = 0;fieldID < fieldNum; fieldID++)
switch (fields [fieldID]->Type ())
{
default:
case DBTableFieldString: fprintf (outFILE,"%c\"%s\"",DBASCIISeparator,fields [fieldID]->String (cellRec)); break;
case DBTableFieldInt:
if (fields [fieldID]->Int (cellRec) == fields [fieldID]->IntNoData ())
fprintf (outFILE,"%c",DBASCIISeparator);
else fprintf (outFILE,"%c%d",DBASCIISeparator,fields [fieldID]->Int (cellRec));
break;
case DBTableFieldFloat:
if (CMmathEqualValues (fields [fieldID]->Float (cellRec),fields [fieldID]->FloatNoData ()))
fprintf (outFILE,"%c",DBASCIISeparator);
else fprintf (outFILE,"%c%f",DBASCIISeparator,fields [fieldID]->Float (cellRec));
break;
case DBTableFieldDate: fprintf (outFILE,"%c\"%s\"",DBASCIISeparator,fields [fieldID]->String(cellRec)); break;
}
fprintf (outFILE,"\n");
}
fclose (outFILE);
}