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


C++ ContentNode::mutable_last_access方法代码示例

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


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

示例1: getContentNode

/// TODO, need a better way to identify the file.
/// Lookup the file name.
/// Check the location.
/// File content hash. (Which part to hash and length).
bool ContentNode::getContentNode(QSqlDatabase & database,
                                 ContentNode &node)
{
    QSqlQuery query(database);
    query.prepare( "select id, title, authors, description, "
                   "last_access, publisher, md5, "
                   "rating, read_time, read_count, progress, attributes "
                   "from content where name = :name and location = :location "
                   "and size = :size" );
    query.bindValue(":name", node.name());
    query.bindValue(":location", node.location());
    query.bindValue(":size", node.size());

    if (query.exec() && query.next())
    {
        int index = 0;
        node.id_ = query.value(index++).toInt();
        node.title_ = query.value(index++).toString();
        node.mutable_authors() = query.value(index++).toString();
        node.mutable_description() = query.value(index++).toString();
        node.mutable_last_access() = query.value(index++).toString();
        node.mutable_publisher() = query.value(index++).toString();
        node.mutable_md5() = query.value(index++).toString();
        node.mutable_rating() = query.value(index++).toInt();
        node.mutable_read_time() = query.value(index++).toInt();
        node.mutable_read_count() = query.value(index++).toInt();
        node.mutable_progress() = query.value(index++).toString();
        node.mutable_attributes() = query.value(index++).toByteArray();
        return true;
    }
    return false;
}
开发者ID:qbikez,项目名称:booxsdk,代码行数:36,代码来源:content_node.cpp

示例2: getContentNodeByUrl

bool ContentNode::getContentNodeByUrl(QSqlDatabase& database,
                                      const QString & url,
                                      ContentNode & node)
{
    QSqlQuery query(database);
    query.prepare( "select id, name, location, title, authors, description, "
                   "last_access, publisher,  "
                   "rating, read_time, read_count, progress, attributes "
                   "from content where md5 = :md5" );
    query.bindValue(":md5", url);

    if (query.exec() && query.next())
    {
        int index = 0;
        node.id_ = query.value(index++).toInt();
        node.name_ = query.value(index++).toString();
        node.location_ = query.value(index++).toString();
        node.title_ = query.value(index++).toString();
        node.mutable_authors() = query.value(index++).toString();
        node.mutable_description() = query.value(index++).toString();
        node.mutable_last_access() = query.value(index++).toString();
        node.mutable_publisher() = query.value(index++).toString();
        node.mutable_md5() = url;
        node.mutable_rating() = query.value(index++).toInt();
        node.mutable_read_time() = query.value(index++).toInt();
        node.mutable_read_count() = query.value(index++).toInt();
        node.mutable_progress() = query.value(index++).toString();
        node.mutable_attributes() = query.value(index++).toByteArray();
        return true;
    }
    return false;
}
开发者ID:qbikez,项目名称:booxsdk,代码行数:32,代码来源:content_node.cpp

示例3: info

// Need to define the search policy.
// - Match the name, location and size.
// - Otherwise, we just ignore the request.
// - We can also use the hash code to match the file.
/// Query the content node in the specified database.
/// \param database The sqlitepp wrapper of database.
/// \param info The content node information returned by this function.
/// \param absolute_path The absolute path of the node.
/// \param create Create the content node automatically if not found.
/// \return This function returns true if the content node is already in
/// the database, otherwise it returns false.
bool
ContentNode::getContentNode(QSqlDatabase &database,
                            ContentNode & node,
                            const QString & absolute_path,
                            bool create)
{
    // Initialize query parameters and initialize all stuff
    // that does not rely on the database.
    QFileInfo info(absolute_path);

    node.mutable_size() = info.size();
    node.mutable_location() = info.path();
    node.mutable_name() = info.fileName();

    // Query by name, location and size.
    QSqlQuery query(database);
    query.prepare( "select id, title, authors, description, "
                   "last_access, publisher, md5, "
                   "rating, read_time, read_count, progress, attributes "
                   "from content where name = :name and location = :location "
                   "and size = :size" );
    query.bindValue(":name", node.name());
    query.bindValue(":location", node.location());
    query.bindValue(":size", node.size());

    if (query.exec() && query.next())
    {
        int index = 0;
        node.id_ = query.value(index++).toInt();
        node.title_ = query.value(index++).toString();
        node.mutable_authors() = query.value(index++).toString();
        node.mutable_description() = query.value(index++).toString();
        node.mutable_last_access() = query.value(index++).toString();
        node.mutable_publisher() = query.value(index++).toString();
        node.mutable_md5() = query.value(index++).toString();
        node.mutable_rating() = query.value(index++).toInt();
        node.mutable_read_time() = query.value(index++).toInt();
        node.mutable_read_count() = query.value(index++).toInt();
        node.mutable_progress() = query.value(index++).toString();
        node.mutable_attributes() = query.value(index++).toByteArray();
        return true;
    }

    // File has been moved, check the name and size.
    /*
    {
        statement st(database);
        st  << "select id, title, authors, description, "
            << "last_access, publisher, md5, "
            << "rating, read_time, read_count "
            << "from content where name = :name and size = :size",
            node.id_),
            into(info.mutable_title()),
            into(info.mutable_authors()),
            into(info.mutable_description()),
            into(info.mutable_last_access()),
            into(info.mutable_publisher()),
            into(info.mutable_md5()),
            into(info.mutable_rating()),
            into(info.mutable_read_time()),
            into(info.mutable_read_count()),
            use(info.name()),
            use(info.size());
        if (st.exec())
        {
            return true;
        }
    }

    // File name has been changed, check the md5 only.
    // Check if the md5 is ready or not. Make sure md5
    // is calculated only once.
    // TODO, maybe just ignore the node as it's not important.
    if (info.md5().empty() &&
        FileMd5Sum(absolute_path, info.mutable_md5()))
    {
        statement st(database);
        st  << "select id, title, authors, description, "
            << "last_access, publisher, "
            << "rating, read_time, read_count "
            << "from content where md5 = :md5",
            into(info.id_),
            into(info.mutable_title()),
            into(info.mutable_authors()),
            into(info.mutable_description()),
            into(info.mutable_last_access()),
            into(info.mutable_publisher()),
            into(info.mutable_rating()),
            into(info.mutable_read_time()),
//.........这里部分代码省略.........
开发者ID:qbikez,项目名称:booxsdk,代码行数:101,代码来源:content_node.cpp


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