예제 #1
0
/*-------------------------------------------------------------------
 Function: findByIndex(p_node, index)
 Purpose: find device obj from table index by index
 Parameters: p_node -- [OUT], result
             index -- [IN], index
 return: 0 -- find the object
         -1 -- not find
-------------------------------------------------------------------*/
int CDevTblOperator::findByIndex(void* p_node, int index)
{
    PTB001_DEVOBJ p_devTemp = NULL;
    int iRet = -1;

    if (index >= getRecordCount())
        return -1;

    m_DevTblLock.lock();

    list <PTB001_DEVOBJ>::iterator pos = m_listDev.begin();
    list <PTB001_DEVOBJ>::iterator last = m_listDev.end();
    int iPos = 0;

    while (pos != last) {
        if (iPos == index) {
            p_devTemp = *pos;
            memcpy(p_node, p_devTemp, sizeof(TB001_DEVOBJ));
            iRet = 0;
            break;
        }

        pos++;
        iPos++;
    }

    m_DevTblLock.unlock();

    return iRet;
}
예제 #2
0
파일: vanitydb.cpp 프로젝트: TechMiX/BVAM
void VanityDB::removeAllRecords(QString networkByte,
                                QString prefix,
                                QString privateKey,
                                QString publicKey) {

    if (isEmpty())
        return;

    QStringList searchFields = (QStringList()
                                << networkByte
                                << prefix
                                << privateKey
                                << publicKey);

    for (int i=0; i<getRecordCount(); i++) {
        QStringList recordFields = records.at(i).split(fieldDelim);
        int cFields = 0, cMatched = 0;
        for (int j=0; j<recordFields.count(); j++) {
            if (searchFields.at(j) != "") {
                cFields++;
                if (recordFields.at(j) == searchFields.at(j))
                    cMatched++;
            }
        }
        if (cFields == cMatched) {
            records.removeAt(i);
            i--;
        }
    }
    rebuildData();
}
예제 #3
0
int libhdfsconnector::streamFileOffset()
{
    int returnCode = RETURN_FAILURE;

    fprintf(stderr, "\nStreaming in %s...\n", fileName);

    unsigned long fileSize = getFileSize(fileName);
    if (fileSize != RETURN_FAILURE)
    {
        if (strcmp(format.c_str(), "FLAT") == 0)
        {
            unsigned long recstoread = getRecordCount(fileSize, clusterCount, recLen, nodeID);

            if (recstoread != RETURN_FAILURE)
            {
                unsigned long offset = nodeID * (fileSize / clusterCount / recLen) * recLen;

                if ((fileSize / recLen) % clusterCount > 0)
                {
                    if ((fileSize / recLen) % clusterCount > nodeID)
                        offset += nodeID * recLen;
                    else
                        offset += ((fileSize / recLen) % clusterCount) * recLen;
                }

                fprintf(stderr, "fileSize: %lu offset: %lu size bytes: %lu, recstoread:%lu\n", fileSize, offset,
                        recstoread * recLen, recstoread);
                if (offset < fileSize)
                    returnCode = streamFlatFileOffset(fileName, offset, recstoread * recLen, bufferSize, 1);
            }
        }
        else if (strcmp(format.c_str(), "CSV") == 0)
        {
            fprintf(stderr, "Filesize: %ld, Offset: %ld, readlen: %ld\n", fileSize,
                    (fileSize / clusterCount) * nodeID, fileSize / clusterCount);

            returnCode = streamCSVFileOffset(fileName, (fileSize / clusterCount) * nodeID,
                    fileSize / clusterCount, terminator.c_str(), bufferSize, outputTerminator, recLen, maxLen,
                    quote.c_str(), 1);
        }
        else if (strcmp(format.c_str(), "XML") == 0)
        {
            fprintf(stderr, "Filesize: %ld, Offset: %ld, readlen: %ld\n", fileSize,
                    (fileSize / clusterCount) * nodeID, fileSize / clusterCount);

            returnCode = readXMLOffset(fileName, (fileSize / clusterCount) * nodeID,
                    fileSize / clusterCount, rowTag, headerText, footerText, bufferSize);
        }
        else
            fprintf(stderr, "Unknown format type: %s(%s)", format.c_str(), foptions.c_str());
    }
    else
        fprintf(stderr, "Could not determine HDFS file size: %s", fileName);

    return returnCode;
}
예제 #4
0
파일: DBFile.cpp 프로젝트: H0zen/newext
uint32 DBCFile::getMaxId()
{
    uint32 maxId = 0;
    for (uint32 i = 0; i < getRecordCount(); ++i)
    {
        if (maxId < getRecord(i).getUInt32(0))
            { maxId = getRecord(i).getUInt32(0); }
    }
    return maxId;
}
예제 #5
0
//-----------------------------------------------------------------------------
// 描述: 将游标指向起始位置(第一条记录之前)
//-----------------------------------------------------------------------------
bool MySqlDataSet::rewind()
{
    if (getRecordCount() > 0)
    {
        mysql_data_seek(res_, 0);
        return true;
    }
    else
        return false;
}
bool QgsCoordinateReferenceSystem::saveAsUserCRS()
{
  if ( ! mIsValidFlag )
  {
    QgsDebugMsg( "Can't save an invalid CRS!" );
    return false;
  }

  QString mySql;
  QString myName = QString( " * %1 (%2)" )
                   .arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
                   .arg( toProj4() );

  //if this is the first record we need to ensure that its srs_id is 10000. For
  //any rec after that sqlite3 will take care of the autonumering
  //this was done to support sqlite 3.0 as it does not yet support
  //the autoinc related system tables.
  if ( getRecordCount() == 0 )
  {
    mySql = "insert into tbl_srs (srs_id,description,projection_acronym,ellipsoid_acronym,parameters,is_geo) values ("
            + QString::number( USER_CRS_START_ID )
            + "," + quotedValue( myName )
            + "," + quotedValue( projectionAcronym() )
            + "," + quotedValue( ellipsoidAcronym() )
            + "," + quotedValue( toProj4() )
            + ",0)"; // <-- is_geo shamelessly hard coded for now
  }
  else
  {
    mySql = "insert into tbl_srs (description,projection_acronym,ellipsoid_acronym,parameters,is_geo) values ("
            + quotedValue( myName )
            + "," + quotedValue( projectionAcronym() )
            + "," + quotedValue( ellipsoidAcronym() )
            + "," + quotedValue( toProj4() )
            + ",0)"; // <-- is_geo shamelessly hard coded for now
  }
  sqlite3      *myDatabase;
  const char   *myTail;
  sqlite3_stmt *myPreparedStatement;
  int           myResult;
  //check the db is available
  myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase );
  if ( myResult != SQLITE_OK )
  {
    QgsDebugMsg( QString( "Can't open or create database %1: %2" )
                 .arg( QgsApplication::qgisUserDbFilePath() )
                 .arg( sqlite3_errmsg( myDatabase ) ) );
    return false;
  }
  QgsDebugMsg( QString( "Update or insert sql \n%1" ).arg( mySql ) );
  myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
  sqlite3_step( myPreparedStatement );
  // XXX Need to free memory from the error msg if one is set
  return myResult == SQLITE_OK;
}
예제 #7
0
size_t DBCFile::getMaxId()
{
    assert(_data);

    size_t maxId = 0;
    for(size_t i = 0; i < getRecordCount(); ++i)
        if (maxId < getRecord(i).getUInt(0))
            maxId = getRecord(i).getUInt(0);

    return maxId;
}
/**
	@in:
	@return:int(0|1)
	@function:delete by record number
*/
int deleteRecordByNumber(int iNum)
{
	int i;

	//删除信息讲要删除的信息的后面信息全部前移
	for(i = iNum;i < getRecordCount();i++)
	{
		saArrayRecord[i] = saArrayRecord[i+1];
	}

	return 1;
}
예제 #9
0
QString RptSql::getFieldValue(QString fieldName, int recNo) {
    if (query->isActive()){
        if (recNo >= getRecordCount()) {
            qDebug() << "recNo more than recordCount";
            return "";
        } else {
            query->seek(recNo);
            int fieldNo = query->record().indexOf(fieldName);
            return query->value(fieldNo).toString();
        }
    } else {
        qDebug() << "Query is not active";
        return "";
    }
}
int main(int argc, char * argv[])
{
    //checks to make sure that there are 2 arguments - one for input and output
    inputCheck(argv);
    
    //Get the input file name...
    char *inputFileName = *(argv + 1);
    char *outputFileName = *(argv + 2);
    
    //Find out how many students are on the input file...
    int numberOfStudents = getRecordCount(inputFileName);
    
    //Create the number of students depending on the record count...
    Student listOfStudents[numberOfStudents];
    createStudents(listOfStudents, numberOfStudents);
    
    //Read the data of the input file...
    FILE *myFile = openFile(inputFileName);
    
    //Fill out all the student's info...
    fillStudentRecord(myFile, listOfStudents, numberOfStudents);
    
    //sortStudents using the array of student struct
    sortStudents(listOfStudents, numberOfStudents);
    
    //Calculate each student's GPA and recorded in the structure...
    getGPA(listOfStudents, numberOfStudents);
    
    //Calculate each student's Letter Grade and record in the structure...
    getGrade(listOfStudents, numberOfStudents);
    
    //Create ClassGrade structure pointer...
    ClassGrade *classGrade;
    classGrade = (ClassGrade *)malloc((sizeof classGrade) * 20);
    
    //Call functions to calculate the scores...
    getScoreAverage(listOfStudents, classGrade, numberOfStudents);
    getMinScore(listOfStudents, classGrade, numberOfStudents);
    getMaxScore(listOfStudents, classGrade, numberOfStudents);
    
    //Generate and output file with the student grade information
    generateOutputFile(outputFileName, inputFileName, listOfStudents, numberOfStudents);
    
    //Print out student's info...
    printAllStudents(listOfStudents, classGrade, numberOfStudents, inputFileName, outputFileName);
    
    return 0;
}
/**
	@in:
	@return:int(0|1)
	@function:删除记录
*/
int deleteRecord()
{
	int iNum = 0;//存放
	int iDeleteResult = 0;

	clearScreen();

	cout<<"  -------------------是时候整理下记录了-----------------\n"<<endl;
	cout<<"		请输入要删除记录的记录号:";
	cin>>iNum;
	if(iNum < getRecordCount())
	{
		//删除信息
		iDeleteResult = deleteRecordByNumber(iNum);
		if(iDeleteResult == 1)
		{
			//删除成功
			system("color 2f");//change color
			cout<<"\n		值得祝贺,删除成功后信息:\n"<<endl;
			showRecord();
		}else
		{
			//删除失败
			cout<<"\n		删除失败,系统遇到未知错误:"<<endl;
		system("color cf&ping -n 1 127.1>nul&color fc&ping -n 1 127.1>nul&color cf&ping -n 1 127.1>nul&color fc&ping -n 1 127.1>nul&color cf");//change color
		}
	}else
	{
		//不存在,显示错误
		cout<<"\n		没有此条记录:"<<iNum<<"不存在"<<endl;
		system("color cf&ping -n 1 127.1>nul&color fc&ping -n 1 127.1>nul&color cf&ping -n 1 127.1>nul&color fc&ping -n 1 127.1>nul&color cf");//change color
	}
	cout<<"  --------------------------------------------------\n"<<endl;
	pause();//pause
	system("color 4e");//change color
	clearScreen();//clear screen

	home();
	
	return 1;
}
예제 #12
0
파일: vanitydb.cpp 프로젝트: TechMiX/BVAM
bool VanityDB::isEmpty() {
    return ((getRecordCount() == 0)?true:false);
}
예제 #13
0
파일: msql_dbc.cpp 프로젝트: nmmmnu/ccc
void mSQLDBC::next(){
   row = msqlFetchRow(result);
   pos++;
};

boolean mSQLDBC::eof(){
예제 #14
0
//-----------------------------------------------------------------------------
// 描述: 返回数据集是否为空
//-----------------------------------------------------------------------------
bool MySqlDataSet::isEmpty()
{
    return (getRecordCount() == 0);
}