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


C++ Statement::bind方法代码示例

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


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

示例1: get

void SQLiteStore::get(const std::string &path, GetCallback callback, void *ptr) {
    assert(uv_thread_self() == thread_id);
    if (!db || !*db) {
        if (callback) {
            callback(nullptr, ptr);
        }
        return;
    }

    GetBaton *get_baton = new GetBaton;
    get_baton->db = db;
    get_baton->path = path;
    get_baton->ptr = ptr;
    get_baton->callback = callback;

    uv_worker_send(worker, get_baton, [](void *data) {
        GetBaton *baton = (GetBaton *)data;
        const std::string url = unifyMapboxURLs(baton->path);
        //                                                    0       1         2
        Statement stmt = baton->db->prepare("SELECT `code`, `type`, `modified`, "
        //     3         4        5           6
            "`etag`, `expires`, `data`, `compressed` FROM `http_cache` WHERE `url` = ?");

        stmt.bind(1, url.c_str());
        if (stmt.run()) {
            // There is data.
            baton->response = std::unique_ptr<Response>(new Response);

            baton->response->code = stmt.get<int>(0);
            baton->type = ResourceType(stmt.get<int>(1));
            baton->response->modified = stmt.get<int64_t>(2);
            baton->response->etag = stmt.get<std::string>(3);
            baton->response->expires = stmt.get<int64_t>(4);
            baton->response->data = stmt.get<std::string>(5);
            if (stmt.get<int>(6)) { // == compressed
                baton->response->data = util::decompress(baton->response->data);
            }
        } else {
            // There is no data.
            // This is a noop.
        }
    }, [](void *data) {
        std::unique_ptr<GetBaton> baton { (GetBaton *)data };
        if (baton->callback) {
            baton->callback(std::move(baton->response), baton->ptr);
        }
    });
}
开发者ID:Dickordia,项目名称:mapbox-gl-native,代码行数:48,代码来源:sqlite_store.cpp

示例2: updateExpiration

void SQLiteStore::updateExpiration(const std::string &path, int64_t expires) {
    assert(uv_thread_self() == thread_id);
    if (!db || !*db) return;

    ExpirationBaton *expiration_baton = new ExpirationBaton;
    expiration_baton->db = db;
    expiration_baton->path = path;
    expiration_baton->expires = expires;

    uv_worker_send(worker, expiration_baton, [](void *data) {
        ExpirationBaton *baton = (ExpirationBaton *)data;
        const std::string url = unifyMapboxURLs(baton->path);
        Statement stmt = //                                 1               2
            baton->db->prepare("UPDATE `http_cache` SET `expires` = ? WHERE `url` = ?");
        stmt.bind<int64_t>(1, baton->expires);
        stmt.bind(2, url.c_str());
        stmt.run();
    }, [](void *data) {
        delete (ExpirationBaton *)data;
    });
}
开发者ID:Dickordia,项目名称:mapbox-gl-native,代码行数:21,代码来源:sqlite_store.cpp


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