这篇教程C++ BSON_ITER_HOLDS_UTF8函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BSON_ITER_HOLDS_UTF8函数的典型用法代码示例。如果您正苦于以下问题:C++ BSON_ITER_HOLDS_UTF8函数的具体用法?C++ BSON_ITER_HOLDS_UTF8怎么用?C++ BSON_ITER_HOLDS_UTF8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BSON_ITER_HOLDS_UTF8函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _mongoc_cursor_populate_errorstatic void_mongoc_cursor_populate_error (mongoc_cursor_t *cursor, const bson_t *doc, bson_error_t *error){ bson_uint32_t code = MONGOC_ERROR_QUERY_FAILURE; bson_iter_t iter; const char *msg = "Unknown query failure"; BSON_ASSERT (cursor); BSON_ASSERT (doc); BSON_ASSERT (error); if (bson_iter_init_find (&iter, doc, "code") && BSON_ITER_HOLDS_INT32 (&iter)) { code = bson_iter_int32 (&iter); } if (bson_iter_init_find (&iter, doc, "$err") && BSON_ITER_HOLDS_UTF8 (&iter)) { msg = bson_iter_utf8 (&iter, NULL); } if (cursor->is_command && bson_iter_init_find (&iter, doc, "errmsg") && BSON_ITER_HOLDS_UTF8 (&iter)) { msg = bson_iter_utf8 (&iter, NULL); } bson_set_error(error, MONGOC_ERROR_QUERY, code, "%s", msg);}
开发者ID:andrewmori,项目名称:mongo-c-driver,代码行数:31,
示例2: _mongoc_sasl_set_propertiesvoid_mongoc_sasl_set_properties (mongoc_sasl_t *sasl, const mongoc_uri_t *uri){ const bson_t *options; bson_iter_t iter; bson_t properties; const char *service_name = NULL; bool canonicalize = false; _mongoc_sasl_set_pass(sasl, mongoc_uri_get_password(uri)); _mongoc_sasl_set_user(sasl, mongoc_uri_get_username(uri)); options = mongoc_uri_get_options (uri); if (!mongoc_uri_get_mechanism_properties (uri, &properties)) { bson_init (&properties); } if (bson_iter_init_find_case ( &iter, options, MONGOC_URI_GSSAPISERVICENAME) && BSON_ITER_HOLDS_UTF8 (&iter)) { service_name = bson_iter_utf8 (&iter, NULL); } if (bson_iter_init_find_case (&iter, &properties, "SERVICE_NAME") && BSON_ITER_HOLDS_UTF8 (&iter)) { /* newer "authMechanismProperties" URI syntax takes precedence */ service_name = bson_iter_utf8 (&iter, NULL); } _mongoc_sasl_set_service_name (sasl, service_name); /* * Driver Authentication Spec: "Drivers MAY allow the user to request * canonicalization of the hostname. This might be required when the hosts * report different hostnames than what is used in the kerberos database. * The default is "false". * * Some underlying GSSAPI layers will do this for us, but can be disabled in * their config (krb.conf). * * See CDRIVER-323 for more information. */ if (bson_iter_init_find_case ( &iter, options, MONGOC_URI_CANONICALIZEHOSTNAME) && BSON_ITER_HOLDS_BOOL (&iter)) { canonicalize = bson_iter_bool (&iter); } if (bson_iter_init_find_case ( &iter, &properties, "CANONICALIZE_HOST_NAME") && BSON_ITER_HOLDS_UTF8 (&iter)) { /* newer "authMechanismProperties" URI syntax takes precedence */ canonicalize = !strcasecmp (bson_iter_utf8 (&iter, NULL), "true"); } sasl->canonicalize_host_name = canonicalize; bson_destroy (&properties);}
开发者ID:acmorrow,项目名称:mongo-c-driver,代码行数:60,
示例3: test_bson_iter_utf8static voidtest_bson_iter_utf8 (void){ uint32_t len = 0; bson_iter_t iter; bson_t *b; char *s; b = bson_new(); assert(bson_append_utf8(b, "foo", -1, "bar", -1)); assert(bson_append_utf8(b, "bar", -1, "baz", -1)); assert(bson_iter_init(&iter, b)); assert(bson_iter_next(&iter)); assert(BSON_ITER_HOLDS_UTF8(&iter)); assert(!strcmp(bson_iter_key(&iter), "foo")); assert(!strcmp(bson_iter_utf8(&iter, NULL), "bar")); s = bson_iter_dup_utf8(&iter, &len); assert_cmpstr("bar", s); assert_cmpint(len, ==, 3); bson_free(s); assert(bson_iter_next(&iter)); assert(BSON_ITER_HOLDS_UTF8(&iter)); assert(!strcmp(bson_iter_key(&iter), "bar")); assert(!strcmp(bson_iter_utf8(&iter, NULL), "baz")); assert(!bson_iter_next(&iter)); bson_destroy(b);}
开发者ID:Cabriter,项目名称:abelkhan,代码行数:27,
示例4: mongo_get_oauth_keystatic int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) { mongoc_collection_t * collection = mongo_get_collection("oauth_key"); if (!collection) return -1; bson_t query; bson_init(&query); BSON_APPEND_UTF8(&query, "kid", (const char *)kid); bson_t fields; bson_init(&fields); BSON_APPEND_INT32(&fields, "lifetime", 1); BSON_APPEND_INT32(&fields, "timestamp", 1); BSON_APPEND_INT32(&fields, "as_rs_alg", 1); BSON_APPEND_INT32(&fields, "ikm_key", 1); mongoc_cursor_t * cursor; cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 1, 0, &query, &fields, NULL); int ret = -1; ns_bzero(key,sizeof(oauth_key_data_raw)); STRCPY(key->kid,kid); if (!cursor) { TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error querying MongoDB collection 'oauth_key'/n"); } else { const bson_t * item; uint32_t length; bson_iter_t iter; if (mongoc_cursor_next(cursor, &item)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "as_rs_alg") && BSON_ITER_HOLDS_UTF8(&iter)) { STRCPY(key->as_rs_alg,bson_iter_utf8(&iter, &length)); } if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "ikm_key") && BSON_ITER_HOLDS_UTF8(&iter)) { STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length)); } if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) { key->timestamp = (u64bits)bson_iter_int64(&iter); } if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) { key->lifetime = (u32bits)bson_iter_int32(&iter); } ret = 0; } mongoc_cursor_destroy(cursor); } mongoc_collection_destroy(collection); bson_destroy(&query); bson_destroy(&fields); return ret;}
开发者ID:SteppeChange,项目名称:coturn,代码行数:56,
示例5: sim_parser_connect_versionstatic gbooleansim_parser_connect_version (bson_iter_t *piter, const char *key, SimCommand *cmd){ g_return_val_if_fail (piter != NULL, FALSE); g_return_val_if_fail (cmd != NULL, FALSE); g_return_val_if_fail (key != NULL, FALSE); cmd->data.connect.sensor_ver = g_new0 (SimVersion, 1); if (BSON_ITER_HOLDS_UTF8(piter)) { /* We need to split the version x.y.z.n */ const gchar *version = bson_iter_utf8 (piter, NULL); if (strlen (version) > 0) { sim_version_parse (version, &(cmd->data.connect.sensor_ver->major), &(cmd->data.connect.sensor_ver->minor), &(cmd->data.connect.sensor_ver->micro), &(cmd->data.connect.sensor_ver->nano)); } } return TRUE;}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:25,
示例6: bson_find_create_tableboolbson_find_create_table (bson_t *bson_schema, const char *table_name, bson_iter_t *iter_col){ bson_iter_t iter_json, iter_ary, iter_sql, iter_table_prop; bson_iter_init_find (&iter_json, bson_schema, "json") || DIE; BSON_ITER_HOLDS_ARRAY (&iter_json) || DIE; bson_iter_recurse (&iter_json, &iter_ary) || DIE; while (bson_iter_next (&iter_ary)) { (BSON_ITER_HOLDS_DOCUMENT (&iter_ary) || DIE); bson_iter_recurse (&iter_ary, &iter_sql) || DIE; if (bson_iter_find (&iter_sql, "create_table") && (BSON_ITER_HOLDS_DOCUMENT (&iter_sql) || DIE) && (bson_iter_recurse (&iter_sql, &iter_table_prop) || DIE) && (bson_iter_find (&iter_table_prop, "table_name") || DIE) && (BSON_ITER_HOLDS_UTF8 (&iter_table_prop) || DIE) && (strcmp (bson_iter_utf8 (&iter_table_prop, NULL), table_name) == 0) && (bson_iter_find (&iter_table_prop, "columns") || DIE) && (BSON_ITER_HOLDS_ARRAY (&iter_table_prop) || DIE)) { bson_iter_recurse (&iter_table_prop, iter_col) || DIE; return true; } } return (false);}
开发者ID:delort,项目名称:mongo-musicbrainz,代码行数:27,
示例7: copy_labels_plus_unknown_commit_resultstatic voidcopy_labels_plus_unknown_commit_result (const bson_t *src, bson_t *dst){ bson_iter_t iter; bson_iter_t src_label; bson_t dst_labels; char str[16]; uint32_t i = 0; const char *key; BSON_APPEND_ARRAY_BEGIN (dst, "errorLabels", &dst_labels); BSON_APPEND_UTF8 (&dst_labels, "0", UNKNOWN_COMMIT_RESULT); /* append any other errorLabels already in "src" */ if (bson_iter_init_find (&iter, src, "errorLabels") && bson_iter_recurse (&iter, &src_label)) { while (bson_iter_next (&src_label) && BSON_ITER_HOLDS_UTF8 (&src_label)) { if (strcmp (bson_iter_utf8 (&src_label, NULL), UNKNOWN_COMMIT_RESULT) != 0) { i++; bson_uint32_to_string (i, &key, str, sizeof str); BSON_APPEND_UTF8 ( &dst_labels, key, bson_iter_utf8 (&src_label, NULL)); } } } bson_append_array_end (dst, &dst_labels);}
开发者ID:samantharitter,项目名称:mongo-c-driver,代码行数:29,
示例8: _score_tagsstatic int_score_tags (const bson_t *read_tags, const bson_t *node_tags){ uint32_t len; bson_iter_t iter; const char *key; const char *str; int count; int i; bson_return_val_if_fail(read_tags, -1); bson_return_val_if_fail(node_tags, -1); count = bson_count_keys(read_tags); if (!bson_empty(read_tags) && bson_iter_init(&iter, read_tags)) { for (i = count; bson_iter_next(&iter); i--) { if (BSON_ITER_HOLDS_UTF8(&iter)) { key = bson_iter_key(&iter); str = bson_iter_utf8(&iter, &len); if (_contains_tag(node_tags, key, str, len)) { return count; } } } return -1; } return 0;}
开发者ID:watsonsong,项目名称:mongo-c-driver,代码行数:31,
示例9: mongo_get_admin_userstatic int mongo_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd){ mongoc_collection_t * collection = mongo_get_collection("admin_user"); if(!collection) return -1; realm[0]=0; pwd[0]=0; bson_t query; bson_init(&query); BSON_APPEND_UTF8(&query, "name", (const char *)usname); bson_t fields; bson_init(&fields); BSON_APPEND_INT32(&fields, "realm", 1); BSON_APPEND_INT32(&fields, "password", 1); mongoc_cursor_t * cursor; cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 1, 0, &query, &fields, NULL); int ret = -1; if (!cursor) { TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error querying MongoDB collection 'admin_user'/n"); } else { const bson_t * item; uint32_t length; bson_iter_t iter; if (mongoc_cursor_next(cursor, &item)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "realm") && BSON_ITER_HOLDS_UTF8(&iter)) { strncpy((char*)realm,bson_iter_utf8(&iter, &length),STUN_MAX_REALM_SIZE); ret = 0; } if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "password") && BSON_ITER_HOLDS_UTF8(&iter)) { strncpy((char*)pwd,bson_iter_utf8(&iter, &length),STUN_MAX_PWD_SIZE); ret = 0; } } mongoc_cursor_destroy(cursor); } mongoc_collection_destroy(collection); bson_destroy(&query); bson_destroy(&fields); return ret;}
开发者ID:SteppeChange,项目名称:coturn,代码行数:47,
示例10: get_column_mapintget_column_map (bson_t *bson_schema, const char *table_name, column_map_t **column_map, int *column_map_size){ bson_iter_t iter_col, iter_dup; int size; column_map_t *column_map_p; const char *data_type; data_type_map_t *data_type_map_p; bson_find_create_table (bson_schema, table_name, &iter_col) || DIE; for (iter_dup = iter_col, size = 0; bson_iter_next (&iter_dup); size++) ; *column_map = calloc (sizeof (column_map_t), size); *column_map_size = size; column_map_p = *column_map; while (bson_iter_next (&iter_col)) { bson_iter_t iter_col_prop; BSON_ITER_HOLDS_DOCUMENT (&iter_col) || DIE; bson_iter_recurse (&iter_col, &iter_col_prop) || DIE; bson_iter_find (&iter_col_prop, "column_name") || DIE; BSON_ITER_HOLDS_UTF8 (&iter_col_prop) || DIE; column_map_p->column_name = bson_iter_dup_utf8 (&iter_col_prop, NULL); bson_iter_find (&iter_col_prop, "data_type") || DIE; BSON_ITER_HOLDS_UTF8 (&iter_col_prop) || DIE; data_type = bson_iter_utf8 (&iter_col_prop, NULL); column_map_p->data_type = data_type; for (data_type_map_p = data_type_map; data_type_map_p < (data_type_map + sizeof (data_type_map)) && strcmp (data_type_map_p->data_type, data_type) != 0; data_type_map_p++) ; if (data_type_map < (data_type_map + sizeof (data_type_map))) column_map_p->bson_append_from_s = data_type_map_p->bson_append_from_s ? data_type_map_p->bson_append_from_s : bson_append_utf8_from_s; else DIE; column_map_p++; } return true;}
开发者ID:delort,项目名称:mongo-musicbrainz,代码行数:44,
示例11: _test_bson_type_print_descriptionstatic void_test_bson_type_print_description (bson_iter_t *iter){ if (bson_iter_find (iter, "description") && BSON_ITER_HOLDS_UTF8 (iter)) { if (test_suite_debug_output ()) { fprintf (stderr, " - %s/n", bson_iter_utf8 (iter, NULL)); fflush (stderr); } }}
开发者ID:Cabriter,项目名称:abelkhan,代码行数:10,
示例12: _score_tagsstatic int_score_tags (const bson_t *read_tags, const bson_t *node_tags){ uint32_t len; bson_iter_t iter; bson_iter_t sub_iter; const char *key; const char *str; int count; bool node_matches_set; bson_return_val_if_fail(read_tags, -1); bson_return_val_if_fail(node_tags, -1); count = bson_count_keys(read_tags); /* Execute this block if read tags were provided, else bail and return 0 (all nodes equal) */ if (!bson_empty(read_tags) && bson_iter_init(&iter, read_tags)) { /* * Iterate over array of read tag sets provided (each element is a tag set) * Tag sets are provided in order of preference so return the count of the * first set that matches the node or -1 if no set matched the node. */ while (count && bson_iter_next(&iter)) { if (BSON_ITER_HOLDS_DOCUMENT(&iter) && bson_iter_recurse(&iter, &sub_iter)) { node_matches_set = true; /* Iterate over the key/value pairs (tags) in the current set */ while (bson_iter_next(&sub_iter) && BSON_ITER_HOLDS_UTF8(&sub_iter)) { key = bson_iter_key(&sub_iter); str = bson_iter_utf8(&sub_iter, &len); /* If any of the tags do not match, this node cannot satisfy this tag set. */ if (!_contains_tag(node_tags, key, str, len)) { node_matches_set = false; break; } } /* This set matched, return the count as the score */ if (node_matches_set) { return count; } /* Decrement the score and try to match the next set. */ count--; } } return -1; } return 0;}
开发者ID:durtal,项目名称:mongolite,代码行数:55,
示例13: mongoc_database_has_collection/** * mongoc_database_has_collection: * @database: (in): A #mongoc_database_t. * @name: (in): The name of the collection to check for. * @error: (out) (allow-none): A location for a #bson_error_t, or %NULL. * * Checks to see if a collection exists within the database on the MongoDB * server. * * This will return %false if their was an error communicating with the * server, or if the collection does not exist. * * If @error is provided, it will first be zeroed. Upon error, error.domain * will be set. * * Returns: %true if @name exists, otherwise %false. @error may be set. */boolmongoc_database_has_collection (mongoc_database_t *database, const char *name, bson_error_t *error){ mongoc_collection_t *collection; mongoc_read_prefs_t *read_prefs; mongoc_cursor_t *cursor; const bson_t *doc; bson_iter_t iter; bool ret = false; const char *cur_name; bson_t q = BSON_INITIALIZER; char ns[140]; ENTRY; BSON_ASSERT (database); BSON_ASSERT (name); if (error) { memset (error, 0, sizeof *error); } bson_snprintf (ns, sizeof ns, "%s.%s", database->name, name); ns[sizeof ns - 1] = '/0'; read_prefs = mongoc_read_prefs_new (MONGOC_READ_PRIMARY); collection = mongoc_client_get_collection (database->client, database->name, "system.namespaces"); cursor = mongoc_collection_find (collection, MONGOC_QUERY_NONE, 0, 0, 0, &q, NULL, read_prefs); while (!mongoc_cursor_error (cursor, error) && mongoc_cursor_more (cursor)) { while (mongoc_cursor_next (cursor, &doc) && bson_iter_init_find (&iter, doc, "name") && BSON_ITER_HOLDS_UTF8 (&iter)) { cur_name = bson_iter_utf8(&iter, NULL); if (!strcmp(cur_name, ns)) { ret = true; GOTO(cleanup); } } }cleanup: mongoc_cursor_destroy (cursor); mongoc_collection_destroy (collection); mongoc_read_prefs_destroy (read_prefs); RETURN(ret);}
开发者ID:huaizhenshihs,项目名称:mongo-c-driver,代码行数:71,
示例14: _bson_to_errorstatic void_bson_to_error (const bson_t *b, bson_error_t *error){ bson_iter_t iter; int code = 0; BSON_ASSERT(b); if (!error) { return; } if (bson_iter_init_find(&iter, b, "code") && BSON_ITER_HOLDS_INT32(&iter)) { code = bson_iter_int32(&iter); } if (bson_iter_init_find(&iter, b, "$err") && BSON_ITER_HOLDS_UTF8(&iter)) { bson_set_error(error, MONGOC_ERROR_QUERY, code, "%s", bson_iter_utf8(&iter, NULL)); return; } if (bson_iter_init_find(&iter, b, "errmsg") && BSON_ITER_HOLDS_UTF8(&iter)) { bson_set_error(error, MONGOC_ERROR_QUERY, code, "%s", bson_iter_utf8(&iter, NULL)); return; } bson_set_error(error, MONGOC_ERROR_QUERY, MONGOC_ERROR_QUERY_FAILURE, "An unknown error ocurred on the server.");}
开发者ID:kvidzibo,项目名称:mongo-c-driver,代码行数:40,
示例15: mongoc_database_has_collection/** * mongoc_database_has_collection: * @database: (in): A #mongoc_database_t. * @name: (in): The name of the collection to check for. * @error: (out) (allow-none): A location for a #bson_error_t, or %NULL. * * Checks to see if a collection exists within the database on the MongoDB * server. * * This will return %false if their was an error communicating with the * server, or if the collection does not exist. * * If @error is provided, it will first be zeroed. Upon error, error.domain * will be set. * * Returns: %true if @name exists, otherwise %false. @error may be set. */boolmongoc_database_has_collection (mongoc_database_t *database, const char *name, bson_error_t *error){ bson_iter_t col_iter; bool ret = false; const char *cur_name; bson_t filter = BSON_INITIALIZER; mongoc_cursor_t *cursor; const bson_t *doc; ENTRY; BSON_ASSERT (database); BSON_ASSERT (name); if (error) { memset (error, 0, sizeof *error); } BSON_APPEND_UTF8 (&filter, "name", name); cursor = mongoc_database_find_collections (database, &filter, error); if (!cursor) { return ret; } if (error && ((error->domain != 0) || (error->code != 0))) { GOTO (cleanup); } while (mongoc_cursor_next (cursor, &doc)) { if (bson_iter_init (&col_iter, doc) && bson_iter_find (&col_iter, "name") && BSON_ITER_HOLDS_UTF8 (&col_iter) && (cur_name = bson_iter_utf8 (&col_iter, NULL))) { if (!strcmp (cur_name, name)) { ret = true; GOTO (cleanup); } } }cleanup: mongoc_cursor_destroy (cursor); RETURN (ret);}
开发者ID:3rf,项目名称:mongo-c-driver,代码行数:69,
示例16: mongoc_uri_get_auth_mechanismconst char *mongoc_uri_get_auth_mechanism (const mongoc_uri_t *uri){ bson_iter_t iter; BSON_ASSERT (uri); if (bson_iter_init_find_case (&iter, &uri->credentials, "authMechanism") && BSON_ITER_HOLDS_UTF8 (&iter)) { return bson_iter_utf8 (&iter, NULL); } return NULL;}
开发者ID:fionaRowan,项目名称:mongo-c-driver,代码行数:14,
示例17: mongoc_uri_get_replica_setconst char *mongoc_uri_get_replica_set (const mongoc_uri_t *uri){ bson_iter_t iter; BSON_ASSERT (uri); if (bson_iter_init_find_case(&iter, &uri->options, "replicaSet") && BSON_ITER_HOLDS_UTF8(&iter)) { return bson_iter_utf8(&iter, NULL); } return NULL;}
开发者ID:fionaRowan,项目名称:mongo-c-driver,代码行数:14,
示例18: mongoc_uri_get_auth_mechanismconst char *mongoc_uri_get_auth_mechanism (const mongoc_uri_t *uri){ bson_iter_t iter; bson_return_val_if_fail (uri, NULL); if (bson_iter_init_find_case (&iter, &uri->options, "authMechanism") && BSON_ITER_HOLDS_UTF8 (&iter)) { return bson_iter_utf8 (&iter, NULL); } return NULL;}
开发者ID:ChristianHeckl,项目名称:mongo-c-driver,代码行数:14,
示例19: sim_parser_connect_hostnamestatic gbooleansim_parser_connect_hostname (bson_iter_t *piter, const char *key, SimCommand *cmd){ g_return_val_if_fail (piter != NULL, FALSE); g_return_val_if_fail (cmd != NULL, FALSE); g_return_val_if_fail (key != NULL, FALSE); gboolean result = FALSE; if (BSON_ITER_HOLDS_UTF8 (piter)) { cmd->data.connect.hostname = g_strdup (bson_iter_utf8(piter, NULL)); result = TRUE; } return result;}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:15,
示例20: mongoc_uri_get_option_as_utf8const char*mongoc_uri_get_option_as_utf8 (const mongoc_uri_t *uri, const char *option, const char *fallback){ const bson_t *options; bson_iter_t iter; if ((options = mongoc_uri_get_options (uri)) && bson_iter_init_find_case (&iter, options, option) && BSON_ITER_HOLDS_UTF8 (&iter)) { return bson_iter_utf8 (&iter, NULL); } return fallback;}
开发者ID:arjuns123,项目名称:mongo-c-driver,代码行数:15,
示例21: _mongoc_convert_utf8bool_mongoc_convert_utf8 (mongoc_client_t *client, const bson_iter_t *iter, const char **str, bson_error_t *error){ if (BSON_ITER_HOLDS_UTF8 (iter)) { *str = bson_iter_utf8 (iter, NULL); return true; } CONVERSION_ERR ("Invalid field /"%s/" in opts, should contain string," " not %s", bson_iter_key (iter), _mongoc_bson_type_to_str (bson_iter_type (iter)));}
开发者ID:jmikola,项目名称:mongo-c-driver,代码行数:16,
示例22: _mongoc_database_find_collections_legacy_filterstatic mongoc_cursor_transform_mode_t_mongoc_database_find_collections_legacy_filter (const bson_t *bson, void *ctx_){ bson_iter_t iter; mongoc_database_find_collections_legacy_ctx_t *ctx; ctx = ctx_; if (bson_iter_init_find (&iter, bson, "name") && BSON_ITER_HOLDS_UTF8 (&iter) && (ctx->name = bson_iter_utf8 (&iter, NULL)) && !strchr (ctx->name, '$') && (0 == strncmp (ctx->name, ctx->dbname, ctx->dbname_len))) { return MONGO_CURSOR_TRANSFORM_MUTATE; } else { return MONGO_CURSOR_TRANSFORM_DROP; }}
开发者ID:NaughtyCode,项目名称:mongo-c-driver,代码行数:19,
示例23: _contains_tagstatic bool_contains_tag (const bson_t *b, const char *key, const char *value, size_t value_len){ bson_iter_t iter; bson_return_val_if_fail(b, false); bson_return_val_if_fail(key, false); bson_return_val_if_fail(value, false); if (bson_iter_init_find(&iter, b, key) && BSON_ITER_HOLDS_UTF8(&iter) && !strncmp(value, bson_iter_utf8(&iter, NULL), value_len)) { return true; } return false;}
开发者ID:watsonsong,项目名称:mongo-c-driver,代码行数:20,
示例24: mongo_get_auth_secretsstatic int mongo_get_auth_secrets(secrets_list_t *sl, u08bits *realm) { mongoc_collection_t * collection = mongo_get_collection("turn_secret"); if(!collection) return -1; bson_t query; bson_init(&query); BSON_APPEND_UTF8(&query, "realm", (const char *)realm); bson_t fields; bson_init(&fields); BSON_APPEND_INT32(&fields, "value", 1); mongoc_cursor_t * cursor; cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 0, 0, &query, &fields, NULL); int ret = -1; if (!cursor) { TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error querying MongoDB collection 'turn_secret'/n"); } else { const bson_t * item; uint32_t length; bson_iter_t iter; const char * value; while(mongoc_cursor_next(cursor, &item)) { if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "value") && BSON_ITER_HOLDS_UTF8(&iter)) { value = bson_iter_utf8(&iter, &length); add_to_secrets_list(sl, value); } } mongoc_cursor_destroy(cursor); ret = 0; } mongoc_collection_destroy(collection); bson_destroy(&query); bson_destroy(&fields); return ret;}
开发者ID:SteppeChange,项目名称:coturn,代码行数:41,
示例25: ConvertValueSEXP ConvertValue(bson_iter_t* iter){ if(BSON_ITER_HOLDS_INT32(iter)){ return ScalarInteger(bson_iter_int32(iter)); } else if(BSON_ITER_HOLDS_NULL(iter)){ return R_NilValue; } else if(BSON_ITER_HOLDS_BOOL(iter)){ return ScalarLogical(bson_iter_bool(iter)); } else if(BSON_ITER_HOLDS_DOUBLE(iter)){ return ScalarReal(bson_iter_double(iter)); } else if(BSON_ITER_HOLDS_INT64(iter)){ return ScalarReal((double) bson_iter_int64(iter)); } else if(BSON_ITER_HOLDS_UTF8(iter)){ return mkStringUTF8(bson_iter_utf8(iter, NULL)); } else if(BSON_ITER_HOLDS_CODE(iter)){ return mkStringUTF8(bson_iter_code(iter, NULL)); } else if(BSON_ITER_HOLDS_BINARY(iter)){ return ConvertBinary(iter); } else if(BSON_ITER_HOLDS_DATE_TIME(iter)){ return ConvertDate(iter); } else if(BSON_ITER_HOLDS_OID(iter)){ const bson_oid_t *val = bson_iter_oid(iter); char str[25]; bson_oid_to_string(val, str); return mkString(str); } else if(BSON_ITER_HOLDS_ARRAY(iter)){ bson_iter_t child1; bson_iter_t child2; bson_iter_recurse (iter, &child1); bson_iter_recurse (iter, &child2); return ConvertArray(&child1, &child2); } else if(BSON_ITER_HOLDS_DOCUMENT(iter)){ bson_iter_t child1; bson_iter_t child2; bson_iter_recurse (iter, &child1); bson_iter_recurse (iter, &child2); return ConvertObject(&child1, &child2); } else { stop("Unimplemented BSON type %d/n", bson_iter_type(iter)); }}
开发者ID:FrissAnalytics,项目名称:mongolite,代码行数:40,
示例26: ConvertValueSEXP ConvertValue(bson_iter_t* iter){ if(BSON_ITER_HOLDS_INT32(iter)){ return ScalarInteger(bson_iter_int32(iter)); } else if(BSON_ITER_HOLDS_NULL(iter)){ return R_NilValue; } else if(BSON_ITER_HOLDS_BOOL(iter)){ return ScalarLogical(bson_iter_bool(iter)); } else if(BSON_ITER_HOLDS_DOUBLE(iter)){ return ScalarReal(bson_iter_double(iter)); } else if(BSON_ITER_HOLDS_INT64(iter)){ return ScalarReal((double) bson_iter_int64(iter)); } else if(BSON_ITER_HOLDS_UTF8(iter)){ return mkStringUTF8(bson_iter_utf8(iter, NULL)); } else if(BSON_ITER_HOLDS_CODE(iter)){ return mkStringUTF8(bson_iter_code(iter, NULL)); } else if(BSON_ITER_HOLDS_BINARY(iter)){ return ConvertBinary(iter); } else if(BSON_ITER_HOLDS_DATE_TIME(iter)){ return ConvertDate(iter); } else if(BSON_ITER_HOLDS_OID(iter)){ //not sure if this casting works return mkRaw((unsigned char *) bson_iter_oid(iter), 12); } else if(BSON_ITER_HOLDS_ARRAY(iter)){ bson_iter_t child1; bson_iter_t child2; bson_iter_recurse (iter, &child1); bson_iter_recurse (iter, &child2); return ConvertArray(&child1, &child2); } else if(BSON_ITER_HOLDS_DOCUMENT(iter)){ bson_iter_t child1; bson_iter_t child2; bson_iter_recurse (iter, &child1); bson_iter_recurse (iter, &child2); return ConvertObject(&child1, &child2); } else { stop("Unimplemented BSON type %d/n", bson_iter_type(iter)); }}
开发者ID:CDC,项目名称:mongolite,代码行数:38,
示例27: monary_load_string_valueint monary_load_string_value(const bson_iter_t* bsonit, monary_column_item* citem, int idx){ char* dest; // Pointer to the final location of the array in mem const char* src; // Pointer to immutable buffer int size; uint32_t stringlen; // The size of the string according to iter_utf8 if (BSON_ITER_HOLDS_UTF8(bsonit)) { src = bson_iter_utf8(bsonit, &stringlen); size = citem->type_arg; if (stringlen > size) { stringlen = size; } dest = ((char*) citem->storage) + (idx * size); // Note: numpy strings need not end in /0 memcpy(dest, src, stringlen); return 1; } else { return 0; }}
开发者ID:amit4111989,项目名称:monary,代码行数:23,
示例28: _mongoc_uri_assign_read_prefs_modestatic void_mongoc_uri_assign_read_prefs_mode (mongoc_uri_t *uri) /* IN */{ const char *str; bson_iter_t iter; BSON_ASSERT(uri); if (mongoc_uri_get_option_as_bool (uri, "slaveok", false)) { mongoc_read_prefs_set_mode(uri->read_prefs, MONGOC_READ_SECONDARY_PREFERRED); } if (bson_iter_init_find_case(&iter, &uri->options, "readpreference") && BSON_ITER_HOLDS_UTF8(&iter)) { str = bson_iter_utf8(&iter, NULL); if (0 == strcasecmp("primary", str)) { mongoc_read_prefs_set_mode(uri->read_prefs, MONGOC_READ_PRIMARY); } else if (0 == strcasecmp("primarypreferred", str)) { mongoc_read_prefs_set_mode(uri->read_prefs, MONGOC_READ_PRIMARY_PREFERRED); } else if (0 == strcasecmp("secondary", str)) { mongoc_read_prefs_set_mode(uri->read_prefs, MONGOC_READ_SECONDARY); } else if (0 == strcasecmp("secondarypreferred", str)) { mongoc_read_prefs_set_mode(uri->read_prefs, MONGOC_READ_SECONDARY_PREFERRED); } else if (0 == strcasecmp("nearest", str)) { mongoc_read_prefs_set_mode(uri->read_prefs, MONGOC_READ_NEAREST); } else { MONGOC_WARNING("Unsupported readPreference value [readPreference=%s].", str); } } /* Warn on conflict, since read preference will be validated later */ if (mongoc_read_prefs_get_mode(uri->read_prefs) == MONGOC_READ_PRIMARY && !bson_empty(mongoc_read_prefs_get_tags(uri->read_prefs))) { MONGOC_WARNING("Primary read preference mode conflicts with tags."); }}
开发者ID:fionaRowan,项目名称:mongo-c-driver,代码行数:37,
注:本文中的BSON_ITER_HOLDS_UTF8函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BSP_Config函数代码示例 C++ BSON_ITER_HOLDS_INT32函数代码示例 |