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


C++ ProjectDatabase::qSqlDatabase方法代码示例

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


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

示例1: query

  std::vector<UrlRecord> CloudSessionRecord_Impl::workerUrlRecords() const {
    UrlRecordVector result;

    // return UrlRecords for which this CloudSessionRecord is the parent and the id is not
    // equal to m_serverUrlRecordId.
    ProjectDatabase database = projectDatabase();
    QSqlQuery query(*(database.qSqlDatabase()));
    std::stringstream ss;
    ss << "SELECT * FROM " << UrlRecord::databaseTableName();
    ss << " WHERE parentDatabaseTableName=:parentDatabaseTableName AND ";
    ss << "parentRecordId=:parentRecordId";
    if (m_serverUrlRecordId) {
      ss << " AND (NOT id=:id)";
    }
    query.prepare(toQString(ss.str()));
    query.bindValue(":parentDatabaseTableName",toQString(databaseTableName()));
    query.bindValue(":parentRecordId",id());
    if (m_serverUrlRecordId) {
      query.bindValue(":id",*m_serverUrlRecordId);
    }
    assertExec(query);
    while (query.next()) {
      UrlRecord workerUrlRecord(query,database);
      result.push_back(workerUrlRecord);
    }

    return result;
  }
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:28,代码来源:CloudSessionRecord.cpp

示例2: query

  std::vector<WorkflowRecord> ProblemRecord_Impl::workflowRecords() const {
    WorkflowRecordVector result;

    ProjectDatabase database = projectDatabase();
    QSqlQuery query(*(database.qSqlDatabase()));
    query.prepare(toQString("SELECT * FROM " + WorkflowRecord::databaseTableName() +
                            " WHERE problemRecordId=:problemRecordId ORDER BY workflowIndex"));
    query.bindValue(":problemRecordId",id());
    assertExec(query);
    OptionalInt previousIndex;
    bool resort(false);
    while (query.next()) {
      result.push_back(WorkflowRecord::factoryFromQuery(query, database).get());
      int index = result.back().workflowIndex();
      if (previousIndex) {
        if (index < previousIndex.get()) {
          resort = true;
        }
      }
      previousIndex = index;
    }

    if (resort) {
      WorkflowRecordWorkflowIndexLess comparator;
      std::sort(result.begin(),result.end(),comparator);
    }

    return result;
  }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:29,代码来源:ProblemRecord.cpp

示例3: query

  std::vector<VariableRecord> FunctionRecord_Impl::variableRecords() const {
    VariableRecordVector result;

    ProjectDatabase database = projectDatabase();
    QSqlQuery query(*(database.qSqlDatabase()));
    query.prepare(toQString("SELECT * FROM " + VariableRecord::databaseTableName() +
        " WHERE functionRecordId=:functionRecordId ORDER BY variableVectorIndex"));
    query.bindValue(":functionRecordId",id());
    assertExec(query);
    OptionalInt previousIndex;
    bool resort(false);
    while (query.next()) {
      result.push_back(VariableRecord::factoryFromQuery(query, database).get());
      int index = result.back().variableVectorIndex();
      if (previousIndex) {
        if (index <= previousIndex.get()) {
          resort = true; // if variables are changed around, order in database itself can
                         // get out of date (as compared to database + dirty records).
        }
      }
      previousIndex = index;
    }

    if (resort) {
      VariableRecordVariableVectorIndexLess comparator;
      std::sort(result.begin(),result.end(),comparator);
    }

    return result;
  }
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:30,代码来源:FunctionRecord.cpp

示例4: getMeasureRecord

  MeasureRecord MeasureGroupRecord_Impl::getMeasureRecord(int measureVectorIndex) const
  {
    ProjectDatabase database = this->projectDatabase();
    OptionalMeasureRecord candidate;

    QSqlQuery query(*(database.qSqlDatabase()));
    query.prepare(toQString("SELECT * FROM " + MeasureRecord::databaseTableName() +
        " WHERE variableRecordId=:variableRecordId AND measureVectorIndex=:measureVectorIndex"));
    query.bindValue(":variableRecordId", this->id());
    query.bindValue(":measureVectorIndex", measureVectorIndex);
    assertExec(query);
    if (query.first()) {
      candidate = MeasureRecord::factoryFromQuery(query,database).get();
    }

    // check actual vector index. can get out of date during construction.
    if ((!candidate) ||
        (!candidate->measureVectorIndex()) ||
        (candidate->measureVectorIndex().get() != measureVectorIndex))
    {
      // get all and look for index by hand
      for (const MeasureRecord& dpr : measureRecords(false)) {
        if (dpr.measureVectorIndex() && (dpr.measureVectorIndex().get() == measureVectorIndex)) {
          return dpr;
        }
      }
    }
    else {
      return *candidate;
    }
    LOG_AND_THROW("Invalid DiscretMeasure measureVectorIndex "
        << measureVectorIndex << " for MeasureGroup '" << name() << "'.");
    return MeasureRecord(std::shared_ptr<detail::MeasureRecord_Impl>(),database);
  }
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:34,代码来源:MeasureGroupRecord.cpp

示例5: numMeasures

  unsigned MeasureGroupRecord_Impl::numMeasures(bool selectedMeasuresOnly) const
  {
    unsigned result = 0;

    ProjectDatabase database = this->projectDatabase();

    QSqlQuery query(*(database.qSqlDatabase()));

    if (selectedMeasuresOnly){
      query.prepare(toQString("SELECT COUNT(*) FROM " + MeasureRecord::databaseTableName() +
          " WHERE variableRecordId=:id AND isSelected=:isSelected"));
      query.bindValue(":id", this->id());
      query.bindValue(":isSelected", true);
    }else{
      query.prepare(toQString("SELECT COUNT(*) FROM " + MeasureRecord::databaseTableName() +
          " WHERE variableRecordId=:id"));
      query.bindValue(":id", this->id());
    }

    assertExec(query);
    if (query.first()){
      result = query.value(0).toUInt();
    }

    return result;
  }
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:26,代码来源:MeasureGroupRecord.cpp

示例6: query

  std::vector<FunctionRecord> OptimizationProblemRecord_Impl::objectiveRecords() const {
    FunctionRecordVector result;

    ProjectDatabase database = projectDatabase();
    QSqlQuery query(*(database.qSqlDatabase()));
    query.prepare(toQString("SELECT * FROM " + FunctionRecord::databaseTableName() +
                  " WHERE problemRecordId=:problemRecordId AND functionType=:functionType " +
                  "ORDER BY functionVectorIndex"));
    query.bindValue(":problemRecordId", id());
    query.bindValue(":functionType",FunctionType::Objective);
    assertExec(query);
    OptionalInt previousIndex;
    bool resort(false);
    while (query.next()) {
      result.push_back(FunctionRecord::factoryFromQuery(query, database).get());
      int index = result.back().functionVectorIndex();
      if (previousIndex) {
        if (index <= previousIndex.get()) {
          resort = true; // if functions are moved around, order in database itself can
                         // get out of date (as compared to database + dirty records).
        }
      }
      previousIndex = index;
    }

    if (resort) {
      FunctionRecordFunctionVectorIndexLess comparator;
      std::sort(result.begin(),result.end(),comparator);
    }

    return result;
  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:32,代码来源:OptimizationProblemRecord.cpp

示例7: query

std::vector<UrlRecord> UrlRecord::getUrlRecords(ProjectDatabase& database) {
  std::vector<UrlRecord> result;

  QSqlQuery query(*(database.qSqlDatabase()));
  query.prepare(toQString("SELECT * FROM " + UrlRecord::databaseTableName()));
  assertExec(query);
  while (query.next()) {
    result.push_back(UrlRecord(query, database));
  }

  return result;
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:12,代码来源:UrlRecord.cpp

示例8: query

std::vector<WorkflowRecord> WorkflowRecord::getWorkflowRecords(ProjectDatabase& projectDatabase)
{
  std::vector<WorkflowRecord> result;

  QSqlQuery query(*(projectDatabase.qSqlDatabase()));
  query.prepare(toQString("SELECT * FROM " + WorkflowRecord::databaseTableName()));
  assertExec(query);
  while (query.next()) {
    result.push_back(projectDatabase.getFromQuery<WorkflowRecord>(query));
  }

  return result;
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:13,代码来源:WorkflowRecord.cpp

示例9: query

std::vector<VagrantSessionRecord> VagrantSessionRecord::getVagrantSessionRecords(ProjectDatabase& database) {
  std::vector<VagrantSessionRecord> result;

  QSqlQuery query(*(database.qSqlDatabase()));
  query.prepare(toQString("SELECT * FROM " + CloudSessionRecord::databaseTableName() + " WHERE cloudSessionRecordType=:cloudSessionRecordType"));
  query.bindValue(":cloudSessionRecordType", CloudSessionRecordType::VagrantSessionRecord);
  assertExec(query);
  while (query.next()) {
    result.push_back(VagrantSessionRecord(query, database));
  }

  return result;
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:13,代码来源:VagrantSessionRecord.cpp

示例10: query

  std::vector<AttributeRecord> InputVariableRecord_Impl::attributeRecords() const {
    AttributeRecordVector result;

    ProjectDatabase database = projectDatabase();
    QSqlQuery query(*(database.qSqlDatabase()));
    query.prepare(toQString("SELECT * FROM " + AttributeRecord::databaseTableName() + " WHERE variableRecordId=:variableRecordId"));
    query.bindValue(":variableRecordId",id());
    assertExec(query);
    while (query.next()) {
      result.push_back(database.getFromQuery<AttributeRecord>(query));
    }

    return result;
  }
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:14,代码来源:InputVariableRecord.cpp

示例11: query

boost::optional<OpenStudioAlgorithmRecord> OpenStudioAlgorithmRecord::getOpenStudioAlgorithmRecord(int id, ProjectDatabase& database) {
  boost::optional<OpenStudioAlgorithmRecord> result;

  QSqlQuery query(*(database.qSqlDatabase()));
  query.prepare(toQString("SELECT * FROM " + AlgorithmRecord::databaseTableName() + " WHERE algorithmRecordType=:algorithmRecordType AND id=:id"));
  query.bindValue(":algorithmRecordType", AlgorithmRecordType::OpenStudioAlgorithmRecord);
  query.bindValue(":id",id);
  assertExec(query);
  if (query.first()) {
    result = OpenStudioAlgorithmRecord::factoryFromQuery(query, database);
  }

  return result;
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:14,代码来源:OpenStudioAlgorithmRecord.cpp

示例12: query

std::vector<RulesetRecord> RulesetRecord::getRulesetRecords(ProjectDatabase& database)
{
  std::vector<RulesetRecord> result;

  QSqlQuery query(*(database.qSqlDatabase()));
  query.prepare(toQString("SELECT * FROM " + RulesetRecord::databaseTableName()));
  assertExec(query);
  while (query.next()) {
    boost::optional<RulesetRecord> rulesetRecord = factoryFromQuery(query, database);
    BOOST_ASSERT(rulesetRecord);
    result.push_back(*rulesetRecord);
  }

  return result;
}
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:15,代码来源:RulesetRecord.cpp

示例13: query

std::vector<FSUDaceAlgorithmRecord> FSUDaceAlgorithmRecord::getFSUDaceAlgorithmRecords(ProjectDatabase& database) {
  std::vector<FSUDaceAlgorithmRecord> result;

  QSqlQuery query(*(database.qSqlDatabase()));
  query.prepare(toQString("SELECT * FROM " + AlgorithmRecord::databaseTableName() +
      " WHERE algorithmRecordType=:algorithmRecordType AND " +
      "dakotaAlgorithmRecordType=:dakotaAlgorithmRecordType"));
  query.bindValue(":dakotaAlgorithmRecordType", DakotaAlgorithmRecordType::FSUDaceAlgorithmRecord);
  assertExec(query);
  while (query.next()) {
    result.push_back(FSUDaceAlgorithmRecord(query, database));
  }

  return result;
}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:15,代码来源:FSUDaceAlgorithmRecord.cpp

示例14: query

boost::optional<ActionClauseRecord> ActionClauseRecord::getActionClauseRecord(int id, ProjectDatabase& database)
{
    boost::optional<ActionClauseRecord> result;

    QSqlQuery query(*(database.qSqlDatabase()));
    query.prepare(toQString("SELECT * FROM " + ClauseRecord::databaseTableName() + " WHERE id=:id AND clauseRecordType=:clauseRecordType"));
    query.bindValue(":id", id);
    query.bindValue(":clauseRecordType", ClauseRecordType::ActionClauseRecord);
    assertExec(query);
    if (query.first()) {
        result = factoryFromQuery(query, database);
    }

    return result;
}
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:15,代码来源:ActionClauseRecord.cpp

示例15: query

      static boost::optional<T> getJoinRecord(int leftId, int rightId, ProjectDatabase projectDatabase)
      {
        boost::optional<T> result;
        
        QSqlQuery query(*(projectDatabase.qSqlDatabase()));
        query.prepare(toQString("SELECT * FROM " + T::databaseTableName() + " WHERE leftId=:leftId AND rightId=:rightId"));
        query.bindValue(":leftId", leftId);
        query.bindValue(":rightId", rightId);
        assertExec(query);
        if(query.first()){
          result = T(boost::shared_ptr<typename T::ImplType>(new typename T::ImplType(query, projectDatabase)), projectDatabase);
        }

        return result;
      }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:15,代码来源:JoinRecord.hpp


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