GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
BSON_ITER_INIT(3) libbson BSON_ITER_INIT(3)

bool
bson_iter_init (bson_iter_t *iter, const bson_t *bson);


  • iter: A bson_iter_t.
  • bson: A bson_t.

The bson_iter_init() function shall initialize iter to iterate upon the BSON document bson. Upon initialization, iter is placed before the first element. Callers must call bson_iter_next(), bson_iter_find(), or bson_iter_find_case() to advance to an element.

Returns true if the iter was successfully initialized.

static void
print_doc_id (const bson_t *doc)
{

bson_iter_t iter;
bson_oid_t oid;
char oidstr[25];
if (bson_iter_init (&iter, doc) && bson_iter_find (&iter, "_id") &&
BSON_ITER_HOLDS_OID (&iter)) {
bson_iter_oid (&iter, &oid);
bson_oid_to_string (&oid, oidstr);
printf ("%s\n", oidstr);
} else {
printf ("Document is missing _id.\n");
} } /* alternatively */ static void print_doc_id (const bson_t *doc) {
bson_iter_t iter;
bson_oid_t oid;
char oidstr[25];
if (bson_iter_init_find (&iter, doc, "_id") && BSON_ITER_HOLDS_OID (&iter)) {
bson_iter_oid (&iter, &oid);
bson_oid_to_string (&oid, oidstr);
printf ("%s\n", oidstr);
} else {
printf ("Document is missing _id.\n");
} }


MongoDB, Inc

2009-present, MongoDB, Inc.

July 3, 2025 1.30.4

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.