Ejemplo n.º 1
0
// /* these work with BSON_OBJECT and BSON_ARRAY */
// /**
//  * Get the BSON subobject currently pointed to by the
//  * iterator.
//  *
//  * @note When copyData is 0, the subobject becomes invalid when its parent's
//  *       data buffer is deallocated. For either value of copyData, you must
//  *       pass the subobject to bson_destroy when you are done using it.
//  *
//  * @param i the bson_iterator.
//  * @param sub an unitialized BSON object which will become the new subobject.
//  */
// MONGO_EXPORT void bson_iterator_subobject_init( const bson_iterator *i, bson *sub, bson_bool_t copyData );
func (it *BsonIterator) SubObjectInit(sub *Bson, copyData bool) {
	_copyData := 0
	if copyData {
		_copyData = 1
	}
	C.bson_iterator_subobject_init(it.iterator, sub._bson, C.bson_bool_t(_copyData))
}
Ejemplo n.º 2
0
/**
 * Append a bson_bool_t to a bson.
 *
 * @param b the bson to append to.
 * @param name the key for the boolean value.
 * @param v the bson_bool_t to append.
 *
 * @return BSON_OK or BSON_ERROR.
 */
func (b *Bson) AppendBool(name string, v bool) int {
	i := 0
	if v {
		i = 1
	}
	return int(C.bson_append_bool(b._bson, C.CString(name), C.bson_bool_t(i)))
}