Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
BSON_ITER_INIT_FROM_DATA(3)	    libbson	   BSON_ITER_INIT_FROM_DATA(3)

SYNOPSIS
	  bool
	  bson_iter_init_from_data (bson_iter_t	*iter, const uint8_t *data, size_t length);

PARAMETERS
        iter: A bson_iter_t.

        data: A buffer	to initialize with.

        length: The length of data in bytes.

DESCRIPTION
       The  bson_iter_init_from_data() function	shall initialize iter to iter-
       ate upon	the buffer data, which must contain a BSON document. Upon ini-
       tialization, 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
       Returns true if the iter	was successfully initialized.

EXAMPLE
	  static void
	  print_doc_id (const uint8_t *data, size_t length)
	  {
	     bson_iter_t iter;
	     bson_oid_t	oid;
	     char oidstr[25];

	     if	(bson_iter_init_from_data (&iter, data,	length)	&& 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");
	     }
	  }

AUTHOR
       MongoDB,	Inc

COPYRIGHT
       2009-present, MongoDB, Inc.

1.30.2				 Apr 12, 2025	   BSON_ITER_INIT_FROM_DATA(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=bson_iter_init_from_data&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>

home | help