Wrapping a C-style Array (Pointer + Length) in a Range Interface
Andrea Fontana via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 9 08:01:08 PDT 2015
On Tuesday, 7 July 2015 at 12:26:33 UTC, Per Nordlöw wrote:
> I'm currently developing a high-level wrapper for FFMPEG at
>
> https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d
>
> My question now becomes how to most easily wrap the iteration
> over streams at
>
> https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d#L150
>
> https://github.com/nordlow/justd/blob/master/tests/t_ffmpeg.d#L152
>
> in a nice D-style range interface.
>
> Do I have to allocate a new D array and copy the `AVStream*`
> elements into that or is there a convenience wrapper for
> constructing a lazy range from a C style Array-pointer plus
> array-length?
>
> Note that the elements of the C array are pointers to structs,
> in this case instances of `AVStream`. This, of course,
> complicates the matter with regard to GC-safety.
>
> Comments on that please :)
I think a wrapper is quite easy to do, isn't it?
You just need to implement front popFront and empty and you're
done.
So you avoid slice-related problems...
More information about the Digitalmars-d-learn
mailing list