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


C++ DataBase类代码示例

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


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

示例1: main

int main(int numArgs, char ** args)
{
    bool doOrder = true;
    if (numArgs == 2)
    {
        if (!strcmp(args[1], "order"))
            doOrder = true;
        else if (!strcmp(args[1], "rmse"))
            doOrder = false;
        else
        {
            qDebug() << "Argument" << args[1] << "not recognized" << endl;
            qDebug() << "Defaulting to ordering error" << endl;
            doOrder = true;
        } 
    }

    DataBase db;
    db.load();
    Probe probe(&db);
    SvdOrder alg(&db);
    QFile f("Features.dat");

    if (f.exists())
        alg.loadFeatures("Features.dat");
    else
        alg.calculateFeaturesByOrder();

    if (doOrder)
        probe.runProbeOrdering(&alg, "probe");
    else
        probe.runProbe(&alg, "probe");

    alg.saveFeatures("Features.dat");
}
开发者ID:alfador,项目名称:cs156b_team_-,代码行数:35,代码来源:main.cpp

示例2: on_showAllBtn_clicked

void EvictionWindow::on_showAllBtn_clicked()
{
    DataBase db;
    db.connectionOpen();

    QSqlQuery query;
    query.prepare("select * from clients");
    query.exec();

    QSqlQueryModel * model = new QSqlQueryModel();
    model->setQuery(query);
    model->QSqlQueryModel::setHeaderData(0, Qt::Horizontal, "ID");
    model->QSqlQueryModel::setHeaderData(1, Qt::Horizontal, "Имя");
    model->QSqlQueryModel::setHeaderData(2, Qt::Horizontal, "Фамилия");
    model->QSqlQueryModel::setHeaderData(3, Qt::Horizontal, "Паспорт");
    model->QSqlQueryModel::setHeaderData(4, Qt::Horizontal, "Количество дней");
    model->QSqlQueryModel::setHeaderData(5, Qt::Horizontal, "Дата посления");
    model->QSqlQueryModel::setHeaderData(6, Qt::Horizontal, "№ комнаты");
    model->QSqlQueryModel::setHeaderData(7, Qt::Horizontal, "Тип комнаты");
    ui->tableView->setModel(model);
    ui->tableView->resizeColumnToContents(4);
    ui->tableView->resizeColumnToContents(5);

    db.connectionClose();
}
开发者ID:hmlON,项目名称:HotelAdministrator,代码行数:25,代码来源:evictionwindow.cpp

示例3: freshSphLib

void CTestPage::freshSphLib()
{
	DataBase db;
	BOOL bTraining = FALSE;
	db.ResetTable(_T("SpeechLib"),bTraining);

	//CStringArray* idArray = db.GetAllUserInfo(_T("UserId"));

	CString SpeechDir = _T("F:\\SpeechDirectory");
	CString UserId,WavName,SphPath;
	CFileFind finder;
	
	UserId = _T("Test");
	SphPath = SpeechDir + _T("\\") + UserId + _T("\\") + _T("*.wav");
	BOOL res = finder.FindFile(SphPath);
	while(res){
		res = finder.FindNextFile();
		if(finder.IsDots()||finder.IsDirectory())  
			continue;
		WavName = finder.GetFileName();
		db.InsertSpeechLib(UserId,WavName);		
	}
	
	finder.Close();
	
}
开发者ID:jltong,项目名称:GraduateWorks,代码行数:26,代码来源:TestPage.cpp

示例4: ReFreshInstrumentData

// I added this code as a one time fix to update all the Instrument Data tables after I made sure that the
// Sipper file definitions were correct.
void  ReFreshInstrumentData (RunLog&  log)
{
  DataBase dbConn (log);

  InstrumentDataFileManager::InitializePush ();
  SipperFileListPtr  sipperFiles = dbConn.SipperFileLoad ("ETP2008", "", "");

  SipperFileList::iterator  idx;

  bool   cancelFlag = false;
  char   msgBuff[1024];

  for  (idx = sipperFiles->begin ();  idx != sipperFiles->end ();  idx++)
  {
    SipperFilePtr sf = *idx;

    cout << "Sipper File [" << sf->SipperFileName () << "]" << std::endl;

    dbConn.InstrumentDataReFreshSipperFile (sf->SipperFileName (), cancelFlag, msgBuff, sizeof (msgBuff));
  }

  InstrumentDataFileManager::InitializePop ();
  InstrumentData::FinalCleanUp ();

  exit (-1);

}  /* ReFreshInstrumentData */
开发者ID:KurtKramer,项目名称:Pices,代码行数:29,代码来源:GrayImageExtraction.cpp

示例5: DataBase

void Registration::on_registerButton_clicked()
{
    DataBase* db = new DataBase();
    db->connectToDataBase();

    if (isCorrectData()){
        if(ui->passwordEdit->text() ==  ui->passwordEdit_2->text()){
            if(db->isUnique(ui->loginEdit->text())){
                if(db->registration(ui->loginEdit->text(),ui->passwordEdit->text(),ui->nameEdit->text(),ui->surnameEdit->text(),ui->phoneEdit->text())){
                   MainWindow* w = new MainWindow();
                   this->close();
                   w->show();
                }
            } else {
                QMessageBox::warning(this, tr("Error") ,tr("Это имя уже занято. Попробуйте другое."));
            }
         } else {
            QMessageBox::warning(this, tr("Error") ,tr("Пароли не совпадают. Повторите попытку."));
            ui->passwordEdit->setText("");
            ui->passwordEdit_2->setText("");
          }
    } else {
        QMessageBox::warning(this, tr("Error") ,tr("Неккоректные данные!"));
    }

    db->closeDataBase();
}
开发者ID:kate-levoshko,项目名称:Kate-repos,代码行数:27,代码来源:registration.cpp

示例6: pit

void
PlotWidget::saveMarkers (DataBase &db)
{
  // save plot markers
  QHashIterator<QString, Plot *> pit(_plots);
  while (pit.hasNext())
  {
    pit.next();
    Plot *p = pit.value();
    
    QHash<QString, Marker *> markers = p->markers();
    QHashIterator<QString, Marker *> mit(markers);
    while (mit.hasNext())
    {
      mit.next();
      Marker *m = mit.value();
    
      if (m->readOnly())
        continue;
      
      if (! m->modified())
        continue;
      
      Entity *e = m->settings();
      e->setName(mit.key());
      
      db.transaction();
      db.set(e);
      db.commit();
      
      m->setModified(FALSE);
    }
  }
}
开发者ID:abhikalitra,项目名称:qtstalker,代码行数:34,代码来源:PlotWidget.cpp

示例7: user

void Test::user()
{
    DataBase db;
    QVERIFY(db.load());
    QFETCH(int, user);
    QFETCH(int, id);

    QList<int> movies;
    QList<int> votes;
    Movie m_movie(&db);
    for (int i = 0; i < db.totalMovies(); ++i) {
        m_movie.setId(i + 1);
        int x = m_movie.findVote(user);
        if (x >= 0) {
            movies.append(i + 1);
            votes.append(m_movie.score(x));
        }
    }
    User userObject(&db, user);
    QCOMPARE(userObject.id(), id);
    QCOMPARE(userObject.votes(), votes.count());
    userObject.setId(id);
    QCOMPARE(userObject.votes(), votes.count());

    for (int i = 0; i < votes.count(); ++i) {
        int movie = userObject.movie(i);
        QVERIFY((bool)(movies.contains(movie)));
        int score = userObject.score(i);
        QCOMPARE(votes[movies.indexOf(movie)], score);
    }
}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:31,代码来源:autotests.cpp

示例8: main

int main(int args, char* argv[]) {
    if (args!=2){
        usage();
        return -1;
    }

    //parameter
    int coarse_k=1024;

    DataSet* ds = new DataSet();
    ds->initDataSet(argv[1]);
    ds->readData(argv[1]);

    PqModel model;
    model.setCoarseK(coarse_k);
    char* centroid_file=NULL;
    DataBase* db = model.trainModel(ds,centroid_file);
    char* model_file = "model.dat";
    model.saveModel(model_file);
    char* database_file = "database.dat";
    db->saveDataBase(database_file);

    delete db;
    delete ds;
    return 0;
}
开发者ID:agangzz,项目名称:product-quantization,代码行数:26,代码来源:train_main.cpp

示例9: main

int main(int argc, char *argv[]){
	string cycleListFileName,dataDir;
	int cycleBegin,cycleEnd;
	

	//checking argv input
	if(argc > 6){//too many arguments
		cerr<<"Too many arguments.\n";
		system("pause");
		return -1;
	}

	else if(argc < 6){//too few arguments
		cerr<<"Too few arguments.\n";
		system("pause");
		return -1;
	}
	else{
	//data DIR
	cycleListFileName = argv[1];
	dataDir = argv[2];
	//Set cycle range
	if(atoi(argv[3])!='\0')
	cycleBegin = atoi(argv[3]);
	else{
	cerr << "Cyclr brgin number error!";
	system("pause");
	return 1;
	}
	if(atoi(argv[4])!='\0')
	cycleEnd = atoi(argv[4]);
	else{
	cerr << "Cycle end number error!";
	system("pause");
	return 1;
	}
	//set Segmentation number 
	segNum = atoi(argv[5]);
	if (segNum == 1)
		seg = disable;
	else 
		seg = enable;
	}

	//Start File IO	
 	// database
    DataBase db;

    db.init(dataDir, cycleListFileName);   // use filtered files directory as working directory

    if(!db.valid()){
        cerr << "Database initializing failed." << endl;
        system("pause");
        return 1;
    }
    cout<<endl;
    runFeatureExtraction(db,argv[3],argv[4]);
	return 0;
}
开发者ID:Po-haoHuang,项目名称:LED_FE_FS,代码行数:59,代码来源:run_FE.cpp

示例10: main

int main(int argc, char* argv[]){
    if(argc!=2) {
        usage();
        return 0;
    }

    //parameter
    int bucket_neig=16;
    int sift_neighbor_num=5000;
    int pic_neigh_num = 50;

    PqModel* model = new PqModel();
    char* model_file = "model.dat";
    model->loadModel(model_file);

    DataBase* db = new DataBase();
    char* database_file = "database.dat";
    db->loadDataBase(database_file);

    PqSearchEngine se;
    se.setBuckNeigNum(bucket_neig);
    se.setSiftNeigNum(sift_neighbor_num);
    se.setPicNeigNum(pic_neigh_num);
    se.setDataBase(db);
    se.setModel(model);

    /* first check if this two file exits.
     * if search_engine exits, load engine;
     * else if centorid_file exits, load centorid_file
     * else train model
     */
    //char *engine_file="search_engine.txt";
    //char *centorid_file="centroids.txt";

    //ifstream ifile(engine_file);
    //if(ifile.good()){
    //    ifile.close();
    //    se.loadEngine(engine_file);
    //}
    //else {
    //    ifile.close();
    //    /* argv[1] base pic_ftr dir */
    //    se.init(argv[1],coarse_k,centorid_file,engine_file);
    //}

    struct stat info;
    stat(argv[1],&info);
    if(S_ISDIR(info.st_mode)) {
        search_withdir(&se,argv[1]);
    }
    else {
        search_withfile(&se,argv[1]);
    }
    return 0;
}
开发者ID:agangzz,项目名称:product-quantization,代码行数:55,代码来源:main.cpp

示例11: main

int main(int argc, char **argv)
{
    Q_UNUSED(argc);
    Q_UNUSED(argv);

    DataBase db;
    db.load();

    QFile file("../../download/test.txt");
    if (!file.open(QFile::ReadOnly)) {
        qWarning() << "Unable to open test file";
        return 1;
    }

    //Probe probe(&db);

    Svd *svd = new Svd(&db);
    svd->calculateFeatures();

    QFile result("../../results.txt");
    if (!result.open(QFile::WriteOnly)) {
        qWarning() << "can't write";
        return 1;
    }
    QTextStream out(&result);
    QTextStream stream(&file);
    while (!stream.atEnd()) {
        QString line = stream.readLine();
        int userid = line.toInt();
        User user(&db, userid);

        QList<RowAndCount> list;
        for (int i = 0; i < db.totalMovies(); ++i) {
            //Movie movie(&db, i);
            svd->setMovie(i);
            double guess = 1.0;
            if (/*movie.findVote(userid) != -1) {//*/user.seenMovie(i) == -1) {
                guess = svd->determine(userid);
                //qDebug() << userid << i << guess;
            }
            list.append(RowAndCount(i, guess));
        }
        qSort(list);
        list = list.mid(0, 10);
        QStringList top10;
        foreach(RowAndCount rowAndCount, list) {
            int sourceRow = rowAndCount.row;
            top10.append(QString("%1").arg(sourceRow));
            Q_ASSERT(rowAndCount.count >= 1 && rowAndCount.count <= 5);
            //qDebug() << rowAndCount.count;
        }

        out << /*list[0].count << ":" <<*/ userid << ":" << top10.join(",") << endl;
    }
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:54,代码来源:main.cpp

示例12: QFETCH

void Test::userNext()
{
    QFETCH(int, start);
    QFETCH(int, next);

    DataBase db;
    QVERIFY(db.load());
    User user(&db, start);
    user.next();
    QCOMPARE(user.id(), next);
}
开发者ID:alexdavis-bf-toys,项目名称:github-contest,代码行数:11,代码来源:autotests.cpp

示例13: login

void MainWindow::login()
{
    if (appSettings->values.value("Interface/showLoginDialog").toBool()) {
        LoginDialog *dlg = new LoginDialog;

#ifdef APP_EDITION_DEMO
        dlg->setDriver(DataBase::SQLite);
        dlg->setDbName(":memory:");
        dlg->setDemoMode();
#endif

#ifdef APP_EDITION_BASE
        dlg->setDriver(DataBase::SQLite);
        dlg->setDbName("/tmp/test.db");
        // TODO
        // recent db
#endif

#ifdef APP_EDITION_PRO
        dlg->setDriver(DataBase::PostgreSQL);
        // TODO
        // ip, port etc.
#endif
        if (dlg->exec() == QDialog::Accepted) {
            DataBase *db = new DataBase;
            db->setDriver(dlg->driver);
            db->setDbName(dlg->dbName);
            appSettings->values.setValue("Interface/showLoginDialog", dlg->showOnStartup->isChecked());

            if (!db->openConnection()) {
                QMessageBox::critical(0, qApp->tr("Ошибка соединения"),
                                      qApp->tr("Невозможно установить соединение с базой данных."), QMessageBox::Ok);
                return;
            }

#ifdef APP_EDITION_DEMO
            db->createDemo();
#endif
            this->loadData(db);
        }

        dlg->deleteLater();
    }
    else {
#ifdef APP_EDITION_DEMO
        DataBase *db = new DataBase;
        db->setDriver(DataBase::SQLite);
        db->setDbName(":memory:");
        db->openConnection();
        db->createDemo();
        this->loadData(db);
#endif
    }
}
开发者ID:khasanov,项目名称:ArchaeologicalProject,代码行数:54,代码来源:MainWindow.cpp

示例14: DataBase

DataBase* PqModel::getDataBase(DataSet* ds ){
    DataBase* db = new DataBase();
    db->setFtrNum(ds->getFeatureNum());
    db->setCoarseK(m_coarse_k);
    coarseIdx(ds,db);
    pq(ds,db);

    db->setFtrFileName(ds->m_vfilename);
    int* ftrFileIdx= ivec_new_0(ds->getFeatureNum());
    memcpy(ftrFileIdx,ds->m_featureFileIdx,ds->getFeatureNum());
    db->setFtrFileIdx(ftrFileIdx);
    return db;
}
开发者ID:agangzz,项目名称:product-quantization,代码行数:13,代码来源:model.cpp

示例15: logWarning

/*
 *brief: 首先检查用户出入解析结果是否正确,
 *       检查数据空间中, 是否有对应的键
 *              有对应的键, 如果类型正确, 修改键值
 *              如果类型错误, 返回出错
 *       无对应的键, 设置值, 返回成功
 *
 */
int SetCommand::operator()(Client *client) const {
    ServerClient *serverClient = (ServerClient *)client;
    //check user resolved input
    const vector<string> &argv = client->getReceiveArgv();
    if (argv.size() != (unsigned int)(this->commandArgc() + 1)) {
        logWarning("set command receive error number of argv! argv_len[%d]", argv.size());
        client->initReplyHead(1);
        client->appendReplyBody(string("set no complete yet"));
        return CABINET_ERR;
    }

    const string &keyName = argv[1];
    const string &newValue = argv[2];
    //check key existence
    DataBase *db = serverClient->getDataBase();
    ValueObj *value = nullptr;
    //1. key exist
    if ((value = db->getValue(keyName)) != nullptr) {
        logDebug("set exist key, key[%s]", keyName.c_str());
        //check key type
        if (value->getValueType() != ValueObj::STRING_TYPE) {
            logDebug("set command execute in wrong type of value, key[%s] value_type[%d]", keyName.c_str(), value->getValueType());
            client->initReplyHead(1);
            client->appendReplyBody(string("I'm not string type."));
            return CABINET_OK;
        }
        logDebug("set string value, key[%s], new_value[%s]", keyName.c_str(), newValue.c_str());
        ((StringObj *)value)->set(newValue);
        client->initReplyHead(1);
        client->appendReplyBody(string("ok"));
        return CABINET_OK;
    }
    //2. key does not exist
    else {
        logDebug("set no-exist key, key[%s]", keyName.c_str());
        //to-do, insert new thing in dataspace
        ValueObj *newObj = new StringObj(newValue);
        if (db->insertKey(keyName, newObj) == CABINET_ERR) {
            logWarning("set command, insert key into dataspace error, key[%s]", keyName.c_str());
            client->initReplyHead(1);
            client->appendReplyBody(string("Set Error"));
            return CABINET_ERR;
        }
        client->initReplyHead(1);
        client->appendReplyBody(string("ok"));
        return CABINET_OK;
    }
}
开发者ID:dszhengyu,项目名称:cabinet,代码行数:56,代码来源:SetCommand.cpp


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