Ejemplo n.º 1
0
view::const_iterator view::find(stdx::string_view key) const {
    bson_t b;
    bson_iter_t iter;

    if (!bson_init_static(&b, _data, _length)) {
        return cend();
    }

    if (!bson_iter_init(&iter, &b)) {
        return cend();
    }

    if (key.empty()) {
        return cend();
    }

    while (bson_iter_next(&iter)) {
        const char* ikey = bson_iter_key(&iter);
        if (0 == strncmp(key.data(), ikey, key.size())) {
            return const_iterator(element(iter.raw, iter.len, iter.off));
        }
    }

    return cend();
}
Ejemplo n.º 2
0
void read_concern::acknowledge_string(stdx::string_view rc_string) {
    // libmongoc uses a NULL level to mean "use the server's default read_concern."
    libmongoc::read_concern_set_level(
        _impl->read_concern_t,
        rc_string.empty() ? NULL : bsoncxx::string::to_string(rc_string).data());
}