本文整理汇总了C++中DBGridIF::GridValue方法的典型用法代码示例。如果您正苦于以下问题:C++ DBGridIF::GridValue方法的具体用法?C++ DBGridIF::GridValue怎么用?C++ DBGridIF::GridValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBGridIF
的用法示例。
在下文中一共展示了DBGridIF::GridValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Write
DBInt Write (FILE *file,DBObjData *data)
{
char *dmRecord;
DBInt layerID, docLen, dbType, intVal;
DBFloat floatVal;
DBPosition pos;
DBObjRecord *layerRec;
DBGridIF *gridIF = new DBGridIF (data);
DMLayerHeader dmLayerHeader;
dbType = gridIF->ValueType ();
switch (dbType)
{
case DBTableFieldFloat: DataType (DMFloat); break;
case DBTableFieldInt:
DataType (gridIF->ValueSize () > 1 ? DMInt : DMByte); break;
}
CellWidth (gridIF->CellWidth ());
CellHeight (gridIF->CellHeight ());
Extent (data->Extent ());
LayerNum (gridIF->LayerNum ());
RowNum (gridIF->RowNum ());
ColNum (gridIF->ColNum ());
dmRecord = (char *) calloc (RowNum () * ColNum (),DataType () != DMByte ? sizeof (int) : sizeof (char));
if (dmRecord == (char *) NULL)
{ CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
DMFileHeader::Write (file);
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
dmLayerHeader.Description (layerRec->Name ());
dmLayerHeader.Write (file);
}
docLen = strlen (data->Document (DBDocComment));
if (fwrite (&docLen,sizeof (int),1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Writing Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
if (docLen > 0)
{
if (fwrite (data->Document (DBDocComment),docLen,1,file) != 1)
{ CMmsgPrint (CMmsgSysError, "File Writing Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
}
for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
{
layerRec = gridIF->Layer (layerID);
switch (data->Type ())
{
case DBTypeGridContinuous:
layerRec = gridIF->Layer (layerID);
if (dbType == DBTableFieldFloat)
{
for (pos.Row = 0;pos.Row < RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < ColNum ();pos.Col++)
if (gridIF->Value (layerRec,pos,&floatVal))
((float *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = (float) floatVal;
else
((float *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = MissingValue ();
}
else
{
for (pos.Row = 0;pos.Row < RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < ColNum ();pos.Col++)
if (gridIF->Value (layerRec,pos,&intVal))
{
if (DataType () == DMInt)
((int *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = (int) intVal;
else
dmRecord [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = intVal;
}
else
{
if (DataType () == DMInt)
((int *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = (int) MissingValue ();
else
dmRecord [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = -99;
}
}
break;
case DBTypeGridDiscrete:
for (pos.Row = 0;pos.Row < RowNum ();pos.Row++)
for (pos.Col = 0;pos.Col < ColNum ();pos.Col++)
{
intVal = gridIF->GridValue (layerRec,pos);
if (DataType () == DMInt)
((int *) dmRecord) [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = intVal;
else
dmRecord [(RowNum () - pos.Row - 1) * ColNum () + pos.Col] = -99;
}
break;
default:
CMmsgPrint (CMmsgAppError, "Invalid Data Type in: %s %d",__FILE__,__LINE__);
free (dmRecord);
delete gridIF;
return (DBFault);
}
if ((DBInt) fwrite (dmRecord,DataType () == DMByte ? sizeof (char) : sizeof (int),DataPointNum (),file) != DataPointNum ())
{ CMmsgPrint (CMmsgSysError, "File Writing Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
}
//.........这里部分代码省略.........