src/mirbooking-utils.c
/**
 * mirbooking_read_sequences_from_mapped_file:
 * @iter: (out): A #MirbookingSequenceIter iterator capable of traversing the
 * sequence records in @mapped_file
 *
 * Read sequence records from a memory-mapped file. Each parsed sequence
 * records indirectly hold a reference to @mapped_file by referencing a slice
 * of the underlying memory via #GBytes.
 */
@iter: (out): A #MirbookingSequenceIter iterator capable of traversing the
sequence records in @mapped_file

Read sequence records from a memory-mapped file. Each parsed sequence
records indirectly hold a reference to @mapped_file by referencing a slice
of the underlying memory via #GBytes.
@iter : ( out ) : A #MirbookingSequenceIter iterator capable of traversing the sequence records in @mapped_file Read sequence records from a memory - mapped file . Each parsed sequence records indirectly hold a reference to @mapped_file by referencing a slice of the underlying memory via #GBytes .
gboolean
mirbooking_read_sequences_from_mapped_file (GMappedFile             *mapped_file,
                                            MirbookingFastaFormat    fasta_format,
                                            GType                    sequence_type,
                                            MirbookingSequenceIter **iter)
{
    g_autoptr (MirbookingSequenceIter) ret = g_new0 (MirbookingSequenceIter, 1);
    g_return_val_if_fail (g_type_is_a (sequence_type, MIRBOOKING_TYPE_SEQUENCE), FALSE);
    const gchar *contents = g_mapped_file_get_contents (mapped_file);
    gsize contents_len = g_mapped_file_get_length (mapped_file);
    g_autoptr (GInputStream) in = g_memory_input_stream_new_from_data (contents, contents_len, NULL);
    g_autoptr (GDataInputStream) dis = g_data_input_stream_new (in);
    ret->mapped_file   = g_mapped_file_ref (mapped_file);
    ret->dis           = g_steal_pointer (&dis);
    ret->fasta_format  = fasta_format;
    ret->sequence_type = sequence_type;
    *iter = g_steal_pointer (&ret);
    return TRUE;
}
gboolean mirbooking_read_sequences_from_mapped_file ( GMappedFile * mapped_file , MirbookingFastaFormat fasta_format , GType sequence_type , MirbookingSequenceIter * * iter ) { g_autoptr ( MirbookingSequenceIter ) ret = g_new0 ( MirbookingSequenceIter , 1 ) ; g_return_val_if_fail ( g_type_is_a ( sequence_type , MIRBOOKING_TYPE_SEQUENCE ) , FALSE ) ; const gchar * contents = g_mapped_file_get_contents ( mapped_file ) ; gsize contents_len = g_mapped_file_get_length ( mapped_file ) ; g_autoptr ( GInputStream ) in = g_memory_input_stream_new_from_data ( contents , contents_len , NULL ) ; g_autoptr ( GDataInputStream ) dis = g_data_input_stream_new ( in ) ; ret -> mapped_file = g_mapped_file_ref ( mapped_file ) ; ret -> dis = g_steal_pointer ( & dis ) ; ret -> fasta_format = fasta_format ; ret -> sequence_type = sequence_type ; * iter = g_steal_pointer ( & ret ) ; return TRUE ; }
mirbooking_read_sequences_from_mapped_file:
 @iter: (out): A #MirbookingSequenceIter iterator capable of traversing the
 sequence records in @mapped_file
mirbooking_read_sequences_from_mapped_file : @iter : ( out ) : A #MirbookingSequenceIter iterator capable of traversing the sequence records in @mapped_file