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


C++ Computer::setID方法代码示例

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


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

示例1: getComputer

Computer ComputerRepository::getComputer(const unique_ptr<QSqlQuery> &query) {
    Computer comp;
    comp.setID(query->value("id").toInt());
    comp.setName(query->value("name").toString().toStdString());
    comp.setType(query->value("type").toString().toStdString());
    comp.setBuildYear(query->value("build_year").toInt());
    comp.setBuilt(query->value("built").toBool());
    return comp;
}
开发者ID:VLN-H7,项目名称:Skil2,代码行数:9,代码来源:computerrepository.cpp

示例2: if

vector<Computer> ComputerRepository::search(string input, string word) {
    db.open();
    vector<Computer> temp;

    QString qinput = QString::fromStdString(input);

    QString likeInput = "%" + qinput + "%";


    QSqlQuery query;

    if(word == "Name") {
        query.prepare("SELECT * FROM Computers c WHERE c.Name LIKE :contains ORDER BY Name;");

    } else if(word == "Build Year") {
        query.prepare("SELECT * FROM Computers c WHERE c.BuildYear LIKE :contains ORDER BY Name");

    } else if(word == "Type") {
        query.prepare("SELECT * FROM Computers c WHERE c.Type LIKE :contains ORDER BY Name");

    } else {
        query.prepare("SELECT * FROM Computers c WHERE c.Built LIKE :contains ORDER BY Name");

    }

    query.bindValue(":contains",likeInput);
    query.exec();

    while(query.next()) {
        Computer c;

        c.setName(query.value("Name").toString().toStdString());
        c.setBuildYear(query.value("BuildYear").toString().toStdString());
        c.setType(query.value("Type").toString().toStdString());
        c.setBuilt(query.value("Built").toInt());
        c.setID(query.value("ID").toInt());

        temp.push_back(c);
    }
    db.close();
    return temp;

}
开发者ID:moderndaymoron,项目名称:PersonCSciVer3,代码行数:43,代码来源:computerrepository.cpp

示例3: while

vector<Computer> ComputerRepository::getComputersFromScientist(Person scientist) {
    db.open();
    vector<Computer> temp;
    QSqlQuery query;
    query.prepare("SELECT * FROM Computers c JOIN Linker l ON l.c_ID = c.ID AND l.p_ID = ?");
    query.addBindValue(scientist.getID());
    query.exec();
    while(query.next()) {
        Computer c;

        c.setName(query.value("Name").toString().toStdString());
        c.setBuildYear(query.value("BuildYear").toString().toStdString());
        c.setType(query.value("Type").toString().toStdString());
        c.setBuilt(query.value("Built").toInt());
        c.setID(query.value("ID").toInt());

        temp.push_back(c);
    }

    db.close();
    return temp;
}
开发者ID:moderndaymoron,项目名称:PersonCSciVer3,代码行数:22,代码来源:computerrepository.cpp


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