本文整理汇总了C++中BSON_ITER_HOLDS_INT32函数的典型用法代码示例。如果您正苦于以下问题:C++ BSON_ITER_HOLDS_INT32函数的具体用法?C++ BSON_ITER_HOLDS_INT32怎么用?C++ BSON_ITER_HOLDS_INT32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BSON_ITER_HOLDS_INT32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getValorDeUnaCopia_ArchivoDB
/*************************************************************************************************************************
F_SECUNDARIA: Obteniendo el VALOR dlong int IP, puerto o numBloque para una copiaX de un bloque X TESTEADO =)
****************************/
long int getValorDeUnaCopia_ArchivoDB (const bson_t * documento_X, int numBloque, int numDeCopia, char * claveRequerida)
{
bson_iter_t punteroDeBusqueda;
bson_iter_t valorEncontrado;
long int valorRequerido;
// GENERO LA CLAVE DE BUSQUEDA
//Ejemplo "Bloqlong int.IP" Bloques.numBloque.ArrayDeCopias.numDeCopia.claveRequerida (clavlong int IP o puerto o numDeBloque)
char *claveGenerada = string_new();
string_append(&claveGenerada, "Bloques");
string_append(&claveGenerada, ".");
string_append(&claveGenerada, string_itoa(numBloque));
string_append(&claveGenerada, ".copias.");
string_append(&claveGenerada, string_itoa(numDeCopia-1));
string_append(&claveGenerada, ".");
string_append(&claveGenerada, claveRequerida);
if (documento_X != NULL &&
bson_iter_init (&punteroDeBusqueda, documento_X) &&
bson_iter_find_descendant (&punteroDeBusqueda, claveGenerada, &valorEncontrado) &&
BSON_ITER_HOLDS_INT32 (&valorEncontrado))
{
valorRequerido = bson_iter_int32 (&valorEncontrado);
}
free(claveGenerada);
return valorRequerido;
}
开发者ID:andresbiso,项目名称:tp-2015-1c-mercurio-public,代码行数:35,代码来源:fsecundarias_mongodb.c
示例2: getCantidadDeCopiasDe1Bloque_ArchivoDB
//Devuelve un num positivo o Devuelve 0 si hay error
int getCantidadDeCopiasDe1Bloque_ArchivoDB(const bson_t * documento_X, int numBloque)
{
bson_iter_t punteroDeBusqueda;
bson_iter_t valorEncontrado;
int CantidadDeCopias = 0;
char *claveGenerada = string_new();
string_append(&claveGenerada, "Bloques");
string_append(&claveGenerada, ".");
string_append(&claveGenerada, string_itoa(numBloque));
string_append(&claveGenerada, ".");
string_append(&claveGenerada, "cantidadDeCopias");
if (documento_X != NULL &&
bson_iter_init (&punteroDeBusqueda, documento_X) &&
bson_iter_find_descendant (&punteroDeBusqueda, claveGenerada, &valorEncontrado) &&
BSON_ITER_HOLDS_INT32 (&valorEncontrado))
{
CantidadDeCopias = bson_iter_int32 (&valorEncontrado);
}
free(claveGenerada);
return CantidadDeCopias;
}
开发者ID:andresbiso,项目名称:tp-2015-1c-mercurio-public,代码行数:27,代码来源:fsecundarias_mongodb.c
示例3: test_write_concern_bson_omits_defaults
static void
test_write_concern_bson_omits_defaults (void)
{
mongoc_write_concern_t *write_concern;
const bson_t *gle;
const bson_t *bson;
bson_iter_t iter;
write_concern = mongoc_write_concern_new();
/*
* Check generated bson.
*/
ASSERT(write_concern);
gle = _mongoc_write_concern_get_gle(write_concern);
ASSERT(bson_iter_init_find(&iter, gle, "getlasterror") && BSON_ITER_HOLDS_INT32(&iter) && bson_iter_int32(&iter) == 1);
ASSERT(!bson_iter_init_find(&iter, gle, "fsync"));
ASSERT(!bson_iter_init_find(&iter, gle, "j"));
ASSERT(!bson_iter_init_find(&iter, gle, "w"));
ASSERT(gle);
bson = _mongoc_write_concern_get_bson(write_concern);
ASSERT(!bson_iter_init_find(&iter, bson, "getlasterror"));
ASSERT(!bson_iter_init_find(&iter, bson, "fsync"));
ASSERT(!bson_iter_init_find(&iter, bson, "j"));
ASSERT(!bson_iter_init_find(&iter, gle, "w"));
ASSERT(bson);
mongoc_write_concern_destroy(write_concern);
}
开发者ID:DuongNguyenHai,项目名称:mongo-c-driver,代码行数:31,代码来源:test-mongoc-write-concern.c
示例4: test_write_concern_bson_includes_false_fsync_and_journal
static void
test_write_concern_bson_includes_false_fsync_and_journal (void)
{
mongoc_write_concern_t *write_concern;
const bson_t *gle;
const bson_t *bson;
bson_iter_t iter;
write_concern = mongoc_write_concern_new();
/*
* Check generated bson.
*/
ASSERT(write_concern);
mongoc_write_concern_set_fsync(write_concern, false);
mongoc_write_concern_set_journal(write_concern, false);
gle = _mongoc_write_concern_get_gle(write_concern);
ASSERT(bson_iter_init_find(&iter, gle, "getlasterror") && BSON_ITER_HOLDS_INT32(&iter) && bson_iter_int32(&iter) == 1);
ASSERT(bson_iter_init_find(&iter, gle, "fsync") && BSON_ITER_HOLDS_BOOL(&iter) && !bson_iter_bool(&iter));
ASSERT(bson_iter_init_find(&iter, gle, "j") && BSON_ITER_HOLDS_BOOL(&iter) && !bson_iter_bool(&iter));
ASSERT(!bson_iter_init_find(&iter, gle, "w"));
ASSERT(gle);
bson = _mongoc_write_concern_get_bson(write_concern);
ASSERT(!bson_iter_init_find(&iter, bson, "getlasterror"));
ASSERT(bson_iter_init_find(&iter, bson, "fsync") && BSON_ITER_HOLDS_BOOL(&iter) && !bson_iter_bool(&iter));
ASSERT(bson_iter_init_find(&iter, bson, "j") && BSON_ITER_HOLDS_BOOL(&iter) && !bson_iter_bool(&iter));
ASSERT(!bson_iter_init_find(&iter, bson, "w"));
ASSERT(bson);
mongoc_write_concern_destroy(write_concern);
}
开发者ID:DuongNguyenHai,项目名称:mongo-c-driver,代码行数:33,代码来源:test-mongoc-write-concern.c
示例5: _mongoc_convert_validate_flags
bool
_mongoc_convert_validate_flags (mongoc_client_t *client,
const bson_iter_t *iter,
bson_validate_flags_t *flags,
bson_error_t *error)
{
if (BSON_ITER_HOLDS_BOOL (iter)) {
if (!bson_iter_as_bool (iter)) {
*flags = BSON_VALIDATE_NONE;
return true;
} else {
/* validate: false is ok but validate: true is prohibited */
CONVERSION_ERR ("Invalid option \"%s\": true, must be a bitwise-OR of"
" bson_validate_flags_t values.",
bson_iter_key (iter));
}
} else if (BSON_ITER_HOLDS_INT32 (iter)) {
if (bson_iter_int32 (iter) <= 0x1F) {
*flags = (bson_validate_flags_t) bson_iter_int32 (iter);
return true;
} else {
CONVERSION_ERR ("Invalid field \"%s\" in opts, must be a bitwise-OR of"
" bson_validate_flags_t values.",
bson_iter_key (iter));
}
}
CONVERSION_ERR ("Invalid type for option \"%s\": \"%s\"."
" \"%s\" must be a boolean or a bitwise-OR of"
" bson_validate_flags_t values.",
bson_iter_key (iter),
_mongoc_bson_type_to_str (bson_iter_type (iter)),
bson_iter_key (iter));
}
开发者ID:jmikola,项目名称:mongo-c-driver,代码行数:33,代码来源:mongoc-opts-helpers.c
示例6: mongoc_uri_set_option_as_int32
bool
mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri,
const char *option,
int32_t value)
{
const bson_t *options;
bson_iter_t iter;
BSON_ASSERT (option);
if (!mongoc_uri_option_is_int32 (option)) {
return false;
}
if ((options = mongoc_uri_get_options (uri)) &&
bson_iter_init_find_case (&iter, options, option)) {
if (BSON_ITER_HOLDS_INT32 (&iter)) {
bson_iter_overwrite_int32 (&iter, value);
return true;
} else {
return false;
}
}
bson_append_int32(&uri->options, option, -1, value);
return true;
}
开发者ID:fionaRowan,项目名称:mongo-c-driver,代码行数:27,代码来源:mongoc-uri.c
示例7: test_bson_iter_overwrite_int32
static void
test_bson_iter_overwrite_int32 (void)
{
bson_iter_t iter;
bson_t b;
bson_init(&b);
assert(bson_append_int32(&b, "key", -1, 1234));
assert(bson_iter_init_find(&iter, &b, "key"));
assert(BSON_ITER_HOLDS_INT32(&iter));
bson_iter_overwrite_int32(&iter, 4321);
assert(bson_iter_init_find(&iter, &b, "key"));
assert(BSON_ITER_HOLDS_INT32(&iter));
assert_cmpint(bson_iter_int32(&iter), ==, 4321);
bson_destroy(&b);
}
开发者ID:Cabriter,项目名称:abelkhan,代码行数:16,代码来源:test-iter.c
示例8: _mongoc_cursor_populate_error
static 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,代码来源:mongoc-cursor.c
示例9: test_write_concern_basic
static void
test_write_concern_basic (void)
{
mongoc_write_concern_t *write_concern;
const bson_t *b;
bson_iter_t iter;
write_concern = mongoc_write_concern_new();
/*
* Test defaults.
*/
assert(write_concern);
assert(!mongoc_write_concern_get_fsync(write_concern));
assert(!mongoc_write_concern_get_journal(write_concern));
assert(mongoc_write_concern_get_w(write_concern) == MONGOC_WRITE_CONCERN_W_DEFAULT);
assert(!mongoc_write_concern_get_wtimeout(write_concern));
assert(!mongoc_write_concern_get_wmajority(write_concern));
mongoc_write_concern_set_fsync(write_concern, TRUE);
assert(mongoc_write_concern_get_fsync(write_concern));
mongoc_write_concern_set_fsync(write_concern, FALSE);
assert(!mongoc_write_concern_get_fsync(write_concern));
mongoc_write_concern_set_journal(write_concern, TRUE);
assert(mongoc_write_concern_get_journal(write_concern));
mongoc_write_concern_set_journal(write_concern, FALSE);
assert(!mongoc_write_concern_get_journal(write_concern));
/*
* Test changes to w.
*/
mongoc_write_concern_set_w(write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY);
assert(mongoc_write_concern_get_wmajority(write_concern));
mongoc_write_concern_set_w(write_concern, MONGOC_WRITE_CONCERN_W_DEFAULT);
assert(!mongoc_write_concern_get_wmajority(write_concern));
mongoc_write_concern_set_wmajority(write_concern, 1000);
assert(mongoc_write_concern_get_wmajority(write_concern));
assert(mongoc_write_concern_get_wtimeout(write_concern) == 1000);
mongoc_write_concern_set_wtimeout(write_concern, 0);
assert(!mongoc_write_concern_get_wtimeout(write_concern));
mongoc_write_concern_set_w(write_concern, MONGOC_WRITE_CONCERN_W_DEFAULT);
assert(mongoc_write_concern_get_w(write_concern) == MONGOC_WRITE_CONCERN_W_DEFAULT);
mongoc_write_concern_set_w(write_concern, 3);
assert(mongoc_write_concern_get_w(write_concern) == 3);
/*
* Check generated bson.
*/
mongoc_write_concern_set_fsync(write_concern, TRUE);
mongoc_write_concern_set_journal(write_concern, TRUE);
b = _mongoc_write_concern_freeze(write_concern);
assert(bson_iter_init_find(&iter, b, "fsync") && BSON_ITER_HOLDS_BOOL(&iter) && bson_iter_bool(&iter));
assert(bson_iter_init_find(&iter, b, "j") && BSON_ITER_HOLDS_BOOL(&iter) && bson_iter_bool(&iter));
assert(bson_iter_init_find(&iter, b, "w") && BSON_ITER_HOLDS_INT32(&iter) && bson_iter_int32(&iter) == 3);
assert(b);
mongoc_write_concern_destroy(write_concern);
}
开发者ID:raohl,项目名称:mongo-c-driver,代码行数:59,代码来源:test-mongoc-write-concern.c
示例10: mongo_get_oauth_key
static 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,代码来源:dbd_mongo.c
示例11: mongoc_client_pool_new
mongoc_client_pool_t *
mongoc_client_pool_new (const mongoc_uri_t *uri)
{
mongoc_topology_t *topology;
mongoc_client_pool_t *pool;
const bson_t *b;
bson_iter_t iter;
ENTRY;
BSON_ASSERT (uri);
pool = (mongoc_client_pool_t *)bson_malloc0(sizeof *pool);
mongoc_mutex_init(&pool->mutex);
_mongoc_queue_init(&pool->queue);
pool->uri = mongoc_uri_copy(uri);
pool->min_pool_size = 0;
pool->max_pool_size = 100;
pool->size = 0;
topology = mongoc_topology_new(uri, false);
pool->topology = topology;
b = mongoc_uri_get_options(pool->uri);
if (bson_iter_init_find_case(&iter, b, "minpoolsize")) {
if (BSON_ITER_HOLDS_INT32(&iter)) {
pool->min_pool_size = BSON_MAX(0, bson_iter_int32(&iter));
}
}
if (bson_iter_init_find_case(&iter, b, "maxpoolsize")) {
if (BSON_ITER_HOLDS_INT32(&iter)) {
pool->max_pool_size = BSON_MAX(1, bson_iter_int32(&iter));
}
}
mongoc_counter_client_pools_active_inc();
RETURN(pool);
}
开发者ID:gabrielPeart,项目名称:libmongoc-xcode,代码行数:41,代码来源:mongoc-client-pool.c
示例12: database_find_blockchain_transaction
int database_find_blockchain_transaction(struct database* db, unsigned char* hash, size_t max_height, struct transaction** tx, size_t* height)
{
mongoc_collection_t* collection = mongoc_client_get_collection(db->client, database_name(db), "transactions");
// Build a query doc
bson_t* query = bson_new();
// Set the hash
BSON_APPEND_BINARY(query, "hash", BSON_SUBTYPE_BINARY, (uint8_t*)hash, 32);
// Force the height to be valid (on the main chain)
bson_t* height_doc = bson_new();
BSON_APPEND_DOCUMENT_BEGIN(query, "height", height_doc);
BSON_APPEND_INT32(height_doc, "$lte", (int)max_height);
BSON_APPEND_INT32(height_doc, "$gte", 0);
bson_append_document_end(query, height_doc);
// Perform find
mongoc_cursor_t* cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
bson_error_t error;
if(cursor == NULL || mongoc_cursor_error(cursor, &error)) {
printf("MongoDB error: %s\n", (cursor == NULL) ? "NULL cursor" : error.message);
return -1;
}
bson_t const* doc;
int found = 0;
while(mongoc_cursor_next(cursor, &doc) != 0) {
if(height != NULL) {
bson_iter_t iter;
if(!bson_iter_init_find(&iter, doc, "height") || !BSON_ITER_HOLDS_INT32(&iter)) {
printf("MongoDB error: tx doesn't have height!\n");
return -1;
}
*height = (size_t)bson_iter_int32(&iter);
}
if(tx != NULL) {
*tx = transaction_from_bson(doc);
}
found = 1;
break;
}
mongoc_cursor_destroy(cursor);
bson_destroy(height_doc);
bson_destroy(query);
mongoc_collection_destroy(collection);
return found;
}
开发者ID:chaind,项目名称:chaind,代码行数:52,代码来源:database_transaction.c
示例13: test_bson_iter_mixed
static void
test_bson_iter_mixed (void)
{
bson_iter_t iter;
bson_decimal128_t iter_value;
bson_decimal128_t value;
bson_t *b;
bson_t *b2;
b = bson_new();
b2 = bson_new();
value.high = 0;
value.low = 1;
assert(bson_append_utf8(b2, "foo", -1, "bar", -1));
assert(bson_append_code(b, "0", -1, "var a = {};"));
assert(bson_append_code_with_scope(b, "1", -1, "var b = {};", b2));
assert(bson_append_int32(b, "2", -1, 1234));
assert(bson_append_int64(b, "3", -1, 4567));
assert(bson_append_time_t(b, "4", -1, 123456));
assert(bson_append_decimal128(b, "5", -1, &value));
assert(bson_iter_init(&iter, b));
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_CODE(&iter));
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_CODEWSCOPE(&iter));
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_INT32(&iter));
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_INT64(&iter));
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_DATE_TIME(&iter));
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_DECIMAL128(&iter));
assert(!bson_iter_next(&iter));
assert(bson_iter_init_find(&iter, b, "3"));
assert(!strcmp(bson_iter_key(&iter), "3"));
assert(bson_iter_int64(&iter) == 4567);
assert(bson_iter_next(&iter));
assert(BSON_ITER_HOLDS_DATE_TIME(&iter));
assert(bson_iter_time_t(&iter) == 123456);
assert(bson_iter_date_time(&iter) == 123456000);
assert(bson_iter_next(&iter));
/* This test uses memcmp because libbson lacks decimal128 comparison. */
bson_iter_decimal128(&iter, &iter_value);
assert(memcmp(&iter_value, &value, sizeof(value)) == 0);
assert(!bson_iter_next(&iter));
bson_destroy(b);
bson_destroy(b2);
}
开发者ID:Cabriter,项目名称:abelkhan,代码行数:51,代码来源:test-iter.c
示例14: sim_parser_connect_id
static gboolean
sim_parser_connect_id (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_INT32(piter))
{
cmd->id = bson_iter_int32(piter);
result = TRUE;
}
return result;
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:14,代码来源:sim-parser-connect.c
示例15: getCantidadTotalDeBloques_ArchivoDB
/*************************************************************************************************************************
F_SECUNDARIA: Obteniendo CANTIDAD TOTAL DE BLOQUES que conforman un Archivo TESTEADO =)
****************************/
int getCantidadTotalDeBloques_ArchivoDB(const bson_t * documento_X)
//Devuelve un num positivo o Devuelve 0 si hay error
{
bson_iter_t punteroDeBusqueda;
bson_iter_t valorEncontrado;
int CantidadBloques = 0;
if (documento_X != NULL &&
bson_iter_init (&punteroDeBusqueda, documento_X) &&
bson_iter_find_descendant (&punteroDeBusqueda, "cantidadDeBloques", &valorEncontrado) &&
BSON_ITER_HOLDS_INT32 (&valorEncontrado))
{
CantidadBloques = bson_iter_int32 (&valorEncontrado);
}
return CantidadBloques;
}
开发者ID:andresbiso,项目名称:tp-2015-1c-mercurio-public,代码行数:20,代码来源:fsecundarias_mongodb.c
示例16: sim_parser_connect_type
static gboolean
sim_parser_connect_type (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_INT32(piter))
{
cmd->data.connect.type = bson_iter_int32 (piter);
if (sim_parse_check_session_type (cmd->data.connect.type))
result = TRUE;
else
g_message ("Bad BSON connect message (type)");
}
return result;
}
开发者ID:jackpf,项目名称:ossim-arc,代码行数:17,代码来源:sim-parser-connect.c
示例17: mongoc_uri_get_option_as_int32
int32_t
mongoc_uri_get_option_as_int32(const mongoc_uri_t *uri, const char *option,
int32_t fallback)
{
const bson_t *options;
bson_iter_t iter;
int32_t retval = fallback;
if ((options = mongoc_uri_get_options (uri)) &&
bson_iter_init_find_case (&iter, options, option) &&
BSON_ITER_HOLDS_INT32 (&iter)) {
if (!(retval = bson_iter_int32(&iter))) {
retval = fallback;
}
}
return retval;
}
开发者ID:arjuns123,项目名称:mongo-c-driver,代码行数:19,代码来源:mongoc-uri.c
示例18: ConvertValue
SEXP 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,代码来源:bson.c
示例19: _bson_to_error
static 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,代码来源:mongoc-client.c
示例20: ConvertValue
SEXP 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,代码来源:bson.c
注:本文中的BSON_ITER_HOLDS_INT32函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论