|
| 1 | +# This file is a part of UpROOT.jl, licensed under the MIT License (MIT). |
| 2 | + |
| 3 | +const AbstractBlob = AbstractVector{UInt8} |
| 4 | + |
| 5 | +""" |
| 6 | + UpROOT.OpaqueObject{tp,B<:AbstractVector{UInt8}} |
| 7 | +
|
| 8 | +An opaque object of symbolic type `tp`. `tp` must be a `Symbol`. Use the |
| 9 | +`data` field to access the byte representation. |
| 10 | +""" |
| 11 | +struct OpaqueObject{tp,B<:AbstractBlob} |
| 12 | + data::B |
| 13 | +end |
| 14 | + |
| 15 | + |
| 16 | +OpaqueObject{tp}(data::AbstractBlob) where {tp} = OpaqueObject{tp,typeof(data)}(data) |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +""" |
| 21 | + OpaqueObjectArray{tp,N,BA<:AbstractArray{<:AbstractBlob,N}} |
| 22 | +
|
| 23 | +An array of [`UpROOT.OpaqueObject`]s. |
| 24 | +""" |
| 25 | +struct OpaqueObjectArray{tp,N,BA<:AbstractArray{<:AbstractBlob,N}} <: AbstractArray{OpaqueObject{tp},N} |
| 26 | + data::BA |
| 27 | +end |
| 28 | + |
| 29 | + |
| 30 | +OpaqueObjectArray{tp}(data::AbstractArray{<:AbstractBlob,N}) where {tp,N} = OpaqueObjectArray{tp,N,typeof(data)}(data) |
| 31 | + |
| 32 | + |
| 33 | +Base.size(A::OpaqueObjectArray) = size(A.data) |
| 34 | + |
| 35 | +Base.IndexStyle(A::OpaqueObjectArray) = IndexStyle(A.data) |
| 36 | + |
| 37 | +Base.@propagate_inbounds function Base.getindex(A::OpaqueObjectArray{tp}, idxs::Vararg{Integer,N}) where {tp,N} |
| 38 | + OpaqueObject{tp}(getindex(A.data, idxs...)) |
| 39 | +end |
| 40 | + |
| 41 | +Base.@propagate_inbounds function Base.getindex(A::OpaqueObjectArray{tp}, idxs...) where {tp} |
| 42 | + OpaqueObjectArray{tp}(getindex(A.data, idxs...)) |
| 43 | +end |
0 commit comments