def decode_all(data, codec_options=DEFAULT_CODEC_OPTIONS):
 if (not isinstance(codec_options, CodecOptions)):
  raise _CODEC_OPTIONS_TYPE_ERROR
 docs = []
 position = 0
 end = (len(data) - 1)
 use_raw = _raw_document_class(codec_options.document_class)
 try:
  while (position < end):
   obj_size = _UNPACK_INT(data[position:(position + 4)])[0]
   if ((len(data) - position) < obj_size):
    raise InvalidBSON('invalid object size')
   obj_end = ((position + obj_size) - 1)
   if (data[obj_end:(position + obj_size)] != '\x00'):
    raise InvalidBSON('bad eoo')
   if use_raw:
    docs.append(codec_options.document_class(data[position:(obj_end + 1)], codec_options))
   else:
    docs.append(_elements_to_dict(data, (position + 4), obj_end, codec_options))
   position += obj_size
  return docs
 except InvalidBSON:
  raise
 except Exception:
  (_, exc_value, exc_tb) = sys.exc_info()
  reraise(InvalidBSON, exc_value, exc_tb)

def decode_all ( data , codec_options = DEFAULT_CODEC_OPTIONS ) : if ( not isinstance ( codec_options , CodecOptions ) ) : raise _CODEC_OPTIONS_TYPE_ERROR docs = [ ] position = 0 end = ( len ( data ) - 1 ) use_raw = _raw_document_class ( codec_options . document_class ) try : while ( position < end ) : obj_size = _UNPACK_INT ( data [ position : ( position + 4 ) ] ) [ 0 ] if ( ( len ( data ) - position ) < obj_size ) : raise InvalidBSON ( 'invalid object size' ) obj_end = ( ( position + obj_size ) - 1 ) if ( data [ obj_end : ( position + obj_size ) ] != '\x00' ) : raise InvalidBSON ( 'bad eoo' ) if use_raw : docs . append ( codec_options . document_class ( data [ position : ( obj_end + 1 ) ] , codec_options ) ) else : docs . append ( _elements_to_dict ( data , ( position + 4 ) , obj_end , codec_options ) ) position += obj_size return docs except InvalidBSON : raise except Exception : ( _ , exc_value , exc_tb ) = sys . exc_info ( ) reraise ( InvalidBSON , exc_value , exc_tb )
decode bson data to multiple documents .