当前位置: 首页>>代码示例>>C++>>正文


C++ DBObjTableField::Date方法代码示例

本文整理汇总了C++中DBObjTableField::Date方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTableField::Date方法的具体用法?C++ DBObjTableField::Date怎么用?C++ DBObjTableField::Date使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObjTableField的用法示例。


在下文中一共展示了DBObjTableField::Date方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _DBObjTableListSort

static int _DBObjTableListSort(const DBObjRecord **obj0, const DBObjRecord **obj1) {
    DBInt ret = 0;
    DBObjTableField *field;
    DBDate date0, date1;

    for (field = _DBObjTableSortFields->First();
         field != (DBObjTableField *) NULL;
         field = _DBObjTableSortFields->Next()) {
        switch (field->Type()) {
            case DBTableFieldString:
                ret = strcmp(field->String(*obj0), field->String(*obj1));
                break;
            case DBTableFieldInt:
                ret = field->Int(*obj0) - field->Int(*obj1);
                break;
            case DBTableFieldFloat:
                if (field->Float(*obj0) - field->Float(*obj1) > 0.0) ret = 1;
                else if (field->Float(*obj0) - field->Float(*obj1) < 0.0) ret = -1;
                else ret = 0;
                break;
            case DBTableFieldDate:
                date0 = field->Date(*obj0);
                date1 = field->Date(*obj1);
                if (date0 > date1) ret = 1;
                else if (date0 < date1) ret = -1;
                else ret = 0;
                break;
            case DBTableFieldTableRec:
                ret = strcmp((*obj0)->Name(), (*obj1)->Name());
                break;
            case DBTableFieldDataRec:
                ret = (*obj0)->RowID() - (*obj1)->RowID();
                break;
        }
        if ((field->Flags() & DBObjectFlagSortReversed) == DBObjectFlagSortReversed) ret *= -1;
        if (ret != 0) return (ret);
    }
    if (ret == 0) ret = (*obj0)->ListPos() - (*obj1)->ListPos();
    return (ret);
}
开发者ID:ztessler,项目名称:RGIS,代码行数:40,代码来源:DBObjTables.C

示例2: main

int main (int argc,char *argv [])

	{
	int argPos, argNum = argc, ret, verbose = false;
	DBInt recID;
	bool padding = false;
	char *tableName = (char *) NULL;
	char *fieldName = (char *) NULL;
	char *yearFieldName = (char *) NULL;
	char *monthFieldName = (char *) NULL;
	char *dayFieldName = (char *) NULL;
	char *hourFieldName = (char *) NULL;
	char *minFieldName = (char *) NULL;
	char *tmp = (char *) NULL;
	DBObjData *data;
	DBObjTable *table;
	DBObjTableField *srcField;
	DBObjTableField *yearField	= (DBObjTableField *) NULL;
	DBObjTableField *monthField= (DBObjTableField *) NULL;
	DBObjTableField *dayField	= (DBObjTableField *) NULL;
	DBObjTableField *hourField	= (DBObjTableField *) NULL;
	DBObjTableField *minField	= (DBObjTableField *) NULL;
	DBInt dbInputType = DBTableFieldInt;
	DBInt dbInputSize = sizeof(DBShort);
	DBDate date;
	DBObjRecord *record;

	for (argPos = 1;argPos < argNum; )
		{
		if (CMargTest (argv [argPos],"-a","--table"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing table name!"); return (CMfailed); }
			tableName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-f","--field"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing field name!"); return (CMfailed); }
			fieldName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-y","--year"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing year field name!"); return (CMfailed); }
			yearFieldName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-m","--month"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing month field name!"); return (CMfailed); }
			monthFieldName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-d","--day"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing day field name!"); return (CMfailed); }
			dayFieldName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-o","--hour"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing hour field name!"); return (CMfailed); }
			hourFieldName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-i","--minute"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing minute field name!"); return (CMfailed); }
			minFieldName = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-p","--padding"))
			{
			padding = true;
			dbInputType = DBTableFieldString;
			dbInputSize = sizeof(DBByte) * 3;
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-V","--verbose"))
			{
			verbose = true;
			if ((argNum = CMargShiftLeft (argPos,argv,argNum)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-h","--help"))
//.........这里部分代码省略.........
开发者ID:bandi13,项目名称:RGIS,代码行数:101,代码来源:CMDtblSplitDate.C

示例3: RGlibPointInterStationTS

DBInt RGlibPointInterStationTS(DBObjData *pntData, DBObjData *tsData, char *relateFldName, char *joinFldName) {
    DBInt first = true, tsIndex, tsRowNum = 0;
    DBObjTable *pntTBL = pntData->Table(DBrNItems), *tsTBL;
    DBObjectLIST<DBObjTableField> *fields;
    DBObjTableField *pntNextFLD = pntTBL->Field(RGlibNextStation);
    DBObjTableField *pntAreaFLD = pntTBL->Field(RGlibArea);
    DBObjTableField *pntInterStnFLD = pntTBL->Field(RGlibInterStation);
    DBObjTableField *pntRelateFLD;
    DBObjTableField *pntNewNextFLD;
    DBObjTableField *pntNewInterStnFLD;
    DBObjTableField *tsTimeFLD;
    DBObjTableField *tsJoinFLD;
    DBObjTableField *tsNextStnFLD, *tsInterStnFLD;
    DBObjRecord *pntRec, *nextPntRec, *tsRec, *tsIndexRec;
    DBDate curDate, date;

    if (pntNextFLD == (DBObjTableField *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing Next Station Field!");
        return (DBFault);
    }
    if (pntAreaFLD == (DBObjTableField *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing STN Area Field!");
        return (DBFault);
    }
    if (pntInterStnFLD == (DBObjTableField *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing Interfluvial Area Field!");
        return (DBFault);
    }

    tsTBL = tsData->Table(DBrNItems);
    tsNextStnFLD = new DBObjTableField(RGlibNextStation, DBTableFieldInt, "%8d", sizeof(DBInt));
    tsTBL->AddField(tsNextStnFLD);
    tsInterStnFLD = new DBObjTableField(RGlibInterStation, DBTableFieldFloat, "%9.1f", sizeof(DBFloat4));
    tsTBL->AddField(tsInterStnFLD);
    fields = tsTBL->Fields();
    for (tsTimeFLD = fields->First(); tsTimeFLD != (DBObjTableField *) NULL; tsTimeFLD = fields->Next())
        if (tsTimeFLD->Type() == DBTableFieldDate) break;
    if (tsTimeFLD == (DBObjTableField *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing Date Field!");
        return (DBFault);
    }
    if ((tsJoinFLD = tsTBL->Field(joinFldName)) == (DBObjTableField *) NULL) {
        CMmsgPrint(CMmsgUsrError, "Missing Join Field!");
        return (DBFault);
    }
    fields = new DBObjectLIST<DBObjTableField>("Field List");
    fields->Add(new DBObjTableField(*tsTimeFLD));
    fields->Add(new DBObjTableField(*tsJoinFLD));
    tsTBL->ListSort(fields);
    delete fields;

    pntTBL = new DBObjTable(*pntTBL);
    pntNextFLD = pntTBL->Field(RGlibNextStation);
    pntAreaFLD = pntTBL->Field(RGlibArea);
    pntInterStnFLD = pntTBL->Field(RGlibInterStation);
    pntNewNextFLD = new DBObjTableField("NextStnTS", pntNextFLD->Type(), pntNextFLD->Format(), pntNextFLD->Length());
    pntNewInterStnFLD = new DBObjTableField("InterFluTS", pntInterStnFLD->Type(), pntInterStnFLD->Format(),
                                            pntInterStnFLD->Length());
    pntRelateFLD = pntTBL->Field(relateFldName);
    pntTBL->AddField(pntNewNextFLD);
    pntTBL->AddField(pntNewInterStnFLD);
    pntTBL->ListSort(pntRelateFLD);

    tsIndexRec = tsTBL->First(&tsIndex);
    for (tsRec = tsTBL->First(); tsRec != (DBObjRecord *) NULL; tsRec = tsTBL->Next()) {
        DBPause(tsRowNum++ * 100 / tsTBL->ItemNum());
        date = tsTimeFLD->Date(tsRec);
        if (date != curDate) {
            if (first) first = false;
            else {
                for (pntRec = pntTBL->First(); pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next()) {
                    if ((pntRec->Flags() & DBObjectFlagLocked) != DBObjectFlagLocked) continue;
                    for (nextPntRec = pntTBL->Item(pntNextFLD->Int(pntRec) - 1);
                         (nextPntRec != (DBObjRecord *) NULL) &&
                         ((nextPntRec->Flags() & DBObjectFlagLocked) != DBObjectFlagLocked);
                         nextPntRec = pntTBL->Item(pntNextFLD->Int(nextPntRec) - 1));
                    if (nextPntRec != (DBObjRecord *) NULL) {
                        pntNewNextFLD->Int(pntRec, nextPntRec->RowID() + 1);
                        pntNewInterStnFLD->Float(nextPntRec,
                                                 pntNewInterStnFLD->Float(nextPntRec) - pntAreaFLD->Float(pntRec));
                    }
                }
                pntRec = pntTBL->First();
                for (; tsIndexRec != (DBObjRecord *) NULL; tsIndexRec = tsTBL->Next(&tsIndex)) {
                    if (tsRec == tsIndexRec) break;
                    for (; pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next())
                        if (pntRelateFLD->Int(pntRec) == tsJoinFLD->Int(tsIndexRec)) {
                            tsNextStnFLD->Int(tsIndexRec, pntNewNextFLD->Int(pntRec));
                            tsInterStnFLD->Float(tsIndexRec, pntNewInterStnFLD->Float(pntRec));
                            break;
                        }
                    if (pntRec == (DBObjRecord *) NULL) pntRec = pntTBL->First();
                }
            }
            for (pntRec = pntTBL->First(); pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next()) {
                pntNewNextFLD->Int(pntRec, 0);
                pntNewInterStnFLD->Float(pntRec, pntAreaFLD->Float(pntRec));
                pntRec->Flags(DBObjectFlagLocked, DBClear);
            }
            curDate = date;
//.........这里部分代码省略.........
开发者ID:bmfekete,项目名称:RGIS,代码行数:101,代码来源:RGlibPoint.C


注:本文中的DBObjTableField::Date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。