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


C++ DatabaseResult::hasNext方法代码示例

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


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

示例1: getDbConnection

std::vector<Device *> ControllerDatabaseFactory::fetchDevices(
    const std::size_t id ) const {
    std::vector<Device *> devices;
    DatabaseStatement * statement;
    DatabaseResult * result;
    DatabaseResultRow * row;
    std::string query;
    std::size_t deviceId;

    query =
        "SELECT id "
        "FROM devices "
        "WHERE controller_id = ";
    query = query + std::to_string(id);
    statement = getDbConnection()->createStatement(query);
    if( statement != nullptr ) {
        result = statement->execute();
        if( result != nullptr ) {
            while( result->hasNext() ) {
                row = result->next();
                deviceId = static_cast<std::size_t>(
                        atol(row->getColumn(0).c_str()));
                devices.push_back(mDeviceContainer->get(deviceId));
                delete row;
            }
            delete result;
        }
        delete statement;
    }

    return ( devices );
}
开发者ID:JoeriHermans,项目名称:Intelligent-Automation-System,代码行数:32,代码来源:controller_database_factory.cpp

示例2: ValueType

std::vector<ValueType *> ValueTypeDatabaseFactory::fetchAll( void ) {
    DatabaseStatement * statement;
    DatabaseResult * result;
    DatabaseResultRow * row;
    std::vector<ValueType *> types;
    std::string strId;
    long bufferId;
    std::size_t id;
    std::string identifier;
    std::string name;
    std::string description;
    std::string regex;

    statement = getDbConnection()->createStatement(
        "SELECT *"
        "FROM value_types"
    );
    if( statement != nullptr ) {
        result = statement->execute();
        if( result != nullptr ) {
            while( result->hasNext() ) {
                row = result->next();
                strId = row->getColumn(0);
                identifier = row->getColumn(1);
                regex = row->getColumn(2);
                name = row->getColumn(3);
                description = row->getColumn(4);
                bufferId = atol(strId.c_str());
                id = static_cast<std::size_t>(bufferId);
                types.push_back(
                    new ValueType(id,identifier,name,description,regex)
                );
                delete row;
            }
            delete result;
        }
        delete statement;
    }

    return ( types );
}
开发者ID:JoeriHermans,项目名称:Intelligent-Automation-System,代码行数:41,代码来源:value_type_database_factory.cpp


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