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


C++ qry函数代码示例

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


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

示例1: qry

ll qry(nd *n,int l,int r) {
    if(!n or n->mn > r or n->mx < l) return 0;
    if(l <= n->mn and n->mx <= r)
        return n->res;
    ll ret = l<=n->i.first and n->i.first<=r ? n->val : 0;
    ret = gcd(gcd(qry(n->ch[0],l,r),qry(n->ch[1],l,r)),ret);
    return ret;
}
开发者ID:BinAccel,项目名称:competitive-programming,代码行数:8,代码来源:ioi13p6.cpp

示例2: qry

ll qry(int ql,int qr,int l,int r,int ind){
    if(ql==l&&qr==r) return st[ind];
    if(lz[ind])
        pshd(ind);
    int mid=l+r>>1;
    if(qr<=mid) return qry(ql,qr,l,mid,ind<<1);
    else if(ql>mid) return qry(ql,qr,mid+1,r,ind<<1|1);
    else return qry(ql,mid,l,mid,ind<<1)|qry(mid+1,qr,mid+1,r,ind<<1|1);
}
开发者ID:BinAccel,项目名称:competitive-programming,代码行数:9,代码来源:620E.cpp

示例3: qry

bool TreeLeaf::updateName_DB()
{
    DBAcccessSafe   db_safe;
    //
    QSqlDatabase* ptr_db = db_safe.getDB();
    if (NULL == ptr_db)
        return false;
    //
    QSqlQuery qry(*ptr_db);
    //
    QString str_update_string = QString("UPDATE node_tbl SET node_name = :NAME WHERE id_node = :ID;");
    //
    if(! qry.prepare( str_update_string ) )
    {
        Logger::getInstance().logIt( en_LOG_ERRORS, qry.lastError().text(), &str_update_string );
        return false;
    };
    //
    qry.bindValue(":NAME", this->text(0));
    qry.bindValue(":ID",   m_iID);
    //
    if( !qry.exec() )
    {
        Logger::getInstance().logIt( en_LOG_ERRORS, qry.lastError().text(), &str_update_string );
        return false;
    };
    //
    m_strDatabaseNodeName = this->text(0);
    return true;
}
开发者ID:AlexanderMironov,项目名称:pdb,代码行数:30,代码来源:treeleaf.cpp

示例4: QDialog

AddCustomerAddLocationAddContactAddEmail::AddCustomerAddLocationAddContactAddEmail(QWidget *parent,
                                                                                   stringMatrix * newEmails,
                                                                                   const std::string & contact) :
    QDialog(parent),
    ui(new Ui::AddCustomerAddLocationAddContactAddEmail)
{
    ui->setupUi(this);
    ui->addButton->setDefault(true);
    this->emails = newEmails;
    this->contact = contact.c_str();
    std::stringstream qryss;
    qryss << "select id, kind from email_phone_kinds";
    Query qry(qryss.str());
    if (qry.failed) {
        emit CloseUponConnectionFailure();
        this->close();
    }
    else {
        for (int i = 0; i < (int)qry.r.size(); ++i){
            std::vector<std::string> newKind;
            newKind.push_back(qry.r[i][0].as<std::string>());
            newKind.push_back(qry.r[i][1].as<std::string>());
            kinds.push_back(newKind);
        }
        QStringList kindOptions;
        for (std::vector<std::vector<std::string>>::iterator tuple = kinds.begin(); tuple != kinds.end(); tuple++){
            kindOptions << (*tuple)[1].c_str();
        }
        ui->kindComboBox->addItems(kindOptions);
    }
}
开发者ID:jginsburgn,项目名称:ADA,代码行数:31,代码来源:addcustomeraddlocationaddcontactaddemail.cpp

示例5: database

/*! Selects a new database name \a dbname for the connection. If the
 *  connection is already using the named database, nothing happens.
 *  For those database backends which do not support the \c USE statement,
 *  the connection will be closed and reopened as needed. This name is \i not
 *  the same as the connection's name.
 *  \warning Every effort is made to avoid leaving the connection in a closed
 *  (or otherwise unusable state) but all bets are off when a non-existant
 *  database name is requested.
 */
void QxtSqlThreadManager::selectDatabase(const QString &dbname)
{
    QSqlDatabase conn = database();
    if(conn.isOpen()){
	// We're already open -- check to see if we can avoid a close
	if(conn.databaseName() == dbname)
	    return; // No need to do anything regardless
	if(conn.driverName().startsWith("QMYSQL", Qt::CaseInsensitive)){
	    // Database supports "USE" -- so do it that way
	    QSqlQuery qry(conn);
	    if(!qry.exec("USE "+conn.driver()->escapeIdentifier(dbname,
			    QSqlDriver::TableName)))
		qWarning() << Q_FUNC_INFO << "Failed to change database to"
		    << dbname << ", error:" << qry.lastError().text();
	    // Set name so we'll see it next time (then we're done here)
	    conn.setDatabaseName(dbname);
	    return;
	}
	// Couldn't swap names on the current connection -- so close it
	conn.close();
    }
    // Reaching here means we've got to set the database name & open it
    conn.setDatabaseName(dbname);
    if(!conn.open())
	qWarning() << Q_FUNC_INFO
	    << "Failed to open connection to database" << dbname
	    << ", error: " << conn.lastError().text();
}
开发者ID:develnk,项目名称:qxtweb-qt5,代码行数:37,代码来源:qxtsqlthreadmanager.cpp

示例6: QDialog

AddCustomerAddContactAddEmail::AddCustomerAddContactAddEmail(QWidget * parent,
                                                             stringMatrix * emails,
                                                             std::string contact) :
    QDialog(parent),
    ui(new Ui::AddCustomerAddContactAddEmail)
{
    ui->setupUi(this);
    ui->addButton->setDefault(true);

    this->emails = emails;
    this->contact = contact;

    std::stringstream qryss;
    qryss << "select id, kind " <<
             "from email_phone_kinds";
    Query qry(qryss.str());
    if (qry.failed) {
        emit CloseUponConnectionFailure();
        this->close();
    }
    else {
        QStringList comboBoxTexts;
        for (int i = 0; i < (int)qry.r.size(); ++i) {
            stringVector newKind;
            newKind.push_back(qry.r[i][0].as<std::string>());
            newKind.push_back(qry.r[i][1].as<std::string>());
            kinds.push_back(newKind);
            comboBoxTexts << qry.r[i][1].as<std::string>().c_str();
        }
        ui->kindComboBox->addItems(comboBoxTexts);
    }
}
开发者ID:jginsburgn,项目名称:ADA,代码行数:32,代码来源:addcustomeraddcontactaddemail.cpp

示例7: DEBUG_REPORT_LOG

bool CharacterNameLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated)
{
	int rowsFetched;
	DEBUG_REPORT_LOG(ConfigServerDatabase::getLogObjectLoading(),("Loading character names.\n"));
	
	CharacterNameQuery qry(schema);
	if (! (session->exec(&qry)))
	{
		objectsLocated = 0;
		return false;
	}
	while ((rowsFetched = qry.fetch()) > 0)
	{
		size_t numRows = qry.getNumRowsFetched();
		size_t count = 0;
		const std::vector<CharacterNameRow> &data = qry.getData();

		for (std::vector<CharacterNameRow>::const_iterator i=data.begin(); i!=data.end(); ++i)
		{
			if (++count > numRows)
				break;

			m_characterIds.push_back(i->character_id.getValue());
			m_stationIds.push_back(i->character_station_id.getValue());
			m_characterNames.push_back(i->character_name.getValueASCII());
			m_characterFullNames.push_back(i->character_full_name.getValueASCII());
			m_characterCreateTime.push_back(i->character_create_time.getValue() + (7 * 60 * 60));			
			m_characterLastLoginTime.push_back(i->character_last_login_time.getValue() + (7 * 60 * 60));
			DEBUG_REPORT_LOG(ConfigServerDatabase::getLogObjectLoading(),("\t%s:%s\n", i->character_id.getValue().getValueString().c_str(), i->character_name.getValueASCII().c_str()));
		}
	}

	objectsLocated = 0;
	return (rowsFetched >= 0);
}
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:35,代码来源:CharacterNameLocator.cpp

示例8: SyncStartFiSvrNet

void SyncStartFiSvrNet( CTcpIo& net, u32 port, bool bSvr, bool bClt)
{
        assert(bSvr || bClt);
        if (bSvr && bClt){
                net.Start(port);
        }else if (bSvr){
                net.StartServer(port);
        }else if (bClt){
                net.StartClient(port);
        }

        FicsConnQuery qry(net, ServerIpBook::GetInstance(), _T("../FicsConfig.xml"));
        while (true)
        {
                set<NodeConnInfo> connInfo;
                bool isFicsNetOk;
                qry.getNodeConnState(connInfo, isFicsNetOk);
                if (!isFicsNetOk){
                        FiSleep(1000);
                        continue;
                }
                break;
        }

}
开发者ID:f0xxx,项目名称:ficsCode,代码行数:25,代码来源:netIpBook.cpp

示例9: qry

bool AddCustomerWindow::verifyNameUniqueness(const std::string & rfc){
    std::stringstream qryss;
    qryss << "select id from entity_kinds where kind='Customer'";
    Query qry(qryss.str());
    if (qry.failed) {
        ui->statusbar->showMessage(connectionError.c_str());
    }
    else {
        std::string customerKindId = qry.r[0][qry.r.column_number("id")].as<std::string>();
        qryss.str("");
        qryss << "select id from entities " <<
                 "where entity_name=" << pg::quote(rfc) <<
                 " and kind=" << customerKindId;
        qry.setQuery(qryss.str());
        qry.run();
        if (qry.failed) {
            ui->statusbar->showMessage(connectionError.c_str());
        }
        else {
            if (qry.r.size() > 0) ui->statusbar->showMessage(nameexistscustomer.c_str());
            else {
                ui->statusbar->showMessage(nnameexistscustomer.c_str());
                return true;
            }
        }
    }
    return false;
}
开发者ID:jginsburgn,项目名称:ADA,代码行数:28,代码来源:addcustomerwindow.cpp

示例10: main

int main() {
    int Case;
    read(Case);
    for(int i = 1; i <= N; ++i)
        tr[i] = new node;
    while(Case--) {
        read(n);
        assert(n <= N);
        init();
        for(int i = 1; i < n; ++i) {
            int u, v;
            read(u), read(v);
            g.addedge(++u, ++v);
        }
        dfs(1, 0);
        build();
        read(qn);
        while(qn--) {
            char s[3];
            scanf("%s", s);
            int u;
            read(u), u++;
            if(s[0] == 'O') tr[u]->access();
            else printf("%.6lf\n", qry(u));
        }
    }
    return 0;
}
开发者ID:bailehang,项目名称:Code,代码行数:28,代码来源:MONOPLOY.cpp

示例11: qry

void 
auth::check_db()
{
    try
    {
        sqlite3pp::query qry(m_db, "SELECT value FROM settings WHERE key = 'schema_version'");
        sqlite3pp::query::iterator i = qry.begin();
        if( i == qry.end() )
        {
            // unusual - table exists but doesn't contain this row.
            // could have been created wrongly
            cerr << "Error, settings table missing schema_version key!" << endl
                << "Maybe you created the database wrong, or it's corrupt." << endl
                << "Try deleting the auth database" << endl;
            throw; // not caught here.
        }
        string val = (*i).get<string>(0);
        cout << "Auth database schema detected as version " << val << endl;
        // check the schema version is what we expect
        // TODO auto-upgrade to newest schema version as needed.
        if( val != "2" )
        {
            throw; // not caught here
        }
        // OK.
    }
    catch(sqlite3pp::database_error err)
    {
        // probably doesn't exist yet, try and create it
        // 
        cout << "database_error: " << err.what() << endl;
        create_db_schema();
    }
}
开发者ID:jonocole,项目名称:playdar,代码行数:34,代码来源:auth.cpp

示例12: qry

bool MyClient::logincheckf(QString name, QString pass){
    if(!this->logincheck){
        //Connect to Database and check for the user
        if(this->db->isOpen()){

        }else{
            this->db->open();
        }
        if(this->db->open()){
            QSqlQuery qry(*this->db);
            QString query_1 = "select * from user_main where name='" + name + "' and pass='" + pass + "' and code='-1';";
            if(qry.exec(query_1)){
                while(qry.next()){
                    this->cname = name;
                    this->cpass = pass;
                    return true;
                }
            }
        }
        return false;


    }
    return false;

}
开发者ID:AltairCA,项目名称:Chat_server,代码行数:26,代码来源:myclient.cpp

示例13: QDialog

DBFileDialog::DBFileDialog(QWidget* parent, Qt::WindowFlags fl)
    : QDialog(parent, fl)
{
    setupUi(this);


    // signals and slots connections
    connect(_btnOk, SIGNAL(clicked()), this, SLOT(accept()));
    connect(_btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
    connect(_list, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(sSelectedReport()));
    connect(_name, SIGNAL(textChanged(const QString&)), this, SLOT(sNameChanged(const QString&)));
    connect(_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(accept()));
    connect(_grade, SIGNAL(valueChanged(int)), this, SLOT(sGradeChanged(int)));

    _list->setColumnCount(2);
    QStringList cnames;
    cnames << tr("Name") << tr("Grade");
    QTreeWidgetItem * item = new QTreeWidgetItem(_list, cnames);
    item->setData(1, Qt::TextAlignmentRole, Qt::AlignLeft);
    item->setData(2, Qt::TextAlignmentRole, Qt::AlignRight);

    XSqlQuery qry(getSqlFromTag("fmt12", QSqlDatabase::database().driverName()));
    while(qry.next())
    {
      QTreeWidgetItem * item = new QTreeWidgetItem(_list, QStringList() << qry.value("report_name").toString() << qry.value("report_grade").toString());
      item->setData(0, Qt::UserRole, qry.value("report_id"));
    }
}
开发者ID:Wushaowei001,项目名称:xtuple,代码行数:28,代码来源:dbfiledialog.cpp

示例14: qry

QJsonObject DiceAPI::getJobsList(const QString& query)
{    
    QUrlQuery qry(apiUrl);
    qry.addQueryItem("fields", "id, company, position");
    qry.addQueryItem("q",query);
    QUrl url(apiUrl);
    url.setQuery(qry);
    QNetworkRequest request(url);
    request.setRawHeader(QByteArray("Authorization"), QByteArray((APIUserName + " " + token).toStdString().c_str()));

    QNetworkReply* reply = mgr.get(request);
    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();

    //check if reply is valid
    if(reply->error() == QNetworkReply::NoError)
    {
        //parsing JSON reply to get access_token
        QJsonDocument parsedReply = QJsonDocument::fromJson(QString(reply->readAll()).toUtf8());
        QJsonObject jsonObj = parsedReply.object();
        return jsonObj;
    }
    else
    {
        throw;
    }

}
开发者ID:olehpidhi,项目名称:DiceAPI,代码行数:29,代码来源:diceapi.cpp

示例15: QgsDebugMsg

bool QgsOracleConn::tableInfo( bool geometryColumnsOnly, bool userTablesOnly, bool allowGeometrylessTables )
{
  QgsDebugMsg( "Entering." );

  mLayersSupported.clear();

  QString sql, delim;

  QString
  prefix( userTablesOnly ? "user" : "all" ),
  owner( userTablesOnly ? "user AS owner" : "c.owner" );

  sql = QString( "SELECT %1,c.table_name,c.column_name,%2,o.object_type AS type"
                 " FROM %3_%4 c"
                 " JOIN %3_objects o ON c.table_name=o.object_name AND o.object_type IN ('TABLE','VIEW','SYNONYM')%5%6" )
        .arg( owner )
        .arg( geometryColumnsOnly ? "c.srid" : "NULL AS srid" )
        .arg( prefix )
        .arg( geometryColumnsOnly ? "sdo_geom_metadata" : "tab_columns" )
        .arg( userTablesOnly ? "" : " AND c.owner=o.owner" )
        .arg( geometryColumnsOnly ? "" : " WHERE c.data_type='SDO_GEOMETRY'" );

  if ( allowGeometrylessTables )
  {
    sql += QString( " UNION SELECT %1,object_name,NULL AS column_name,NULL AS srid,object_type AS type"
                    " FROM %2_objects c WHERE c.object_type IN ('TABLE','VIEW','SYNONYM')" )
           .arg( owner ).arg( prefix );
  }

  // sql = "SELECT * FROM (" + sql + ")";
  // sql += " ORDER BY owner,isview,table_name,column_name";

  QSqlQuery qry( mDatabase );
  if ( !exec( qry, sql ) )
  {
    QgsMessageLog::logMessage( tr( "Querying available tables failed.\nSQL:%1\nerror:%2\n" ).arg( qry.lastQuery() ).arg( qry.lastError().text() ), tr( "Oracle" ) );
    return false;
  }

  while ( qry.next() )
  {
    QgsOracleLayerProperty layerProperty;
    layerProperty.ownerName       = qry.value( 0 ).toString();
    layerProperty.tableName       = qry.value( 1 ).toString();
    layerProperty.geometryColName = qry.value( 2 ).toString();
    layerProperty.types           = QList<QGis::WkbType>() << ( qry.value( 2 ).isNull() ? QGis::WKBNoGeometry : QGis::WKBUnknown );
    layerProperty.srids           = QList<int>() << qry.value( 3 ).toInt();
    layerProperty.isView          = qry.value( 4 ) != "TABLE";
    layerProperty.pkCols.clear();

    mLayersSupported << layerProperty;
  }

  if ( mLayersSupported.size() == 0 )
  {
    QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined." ), tr( "Oracle" ) );
  }

  return true;
}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:60,代码来源:qgsoracleconn.cpp


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