10 #ifndef LLVM_DEBUGINFO_MSF_SEQUENCEDITEMSTREAM_H
11 #define LLVM_DEBUGINFO_MSF_SEQUENCEDITEMSTREAM_H
24 static size_t length(
const T &Item) =
delete;
37 template <
typename T,
typename Traits = SequencedItemTraits<T>>
44 auto ExpectedIndex = translateOffsetIndex(Offset);
46 return ExpectedIndex.takeError();
47 const auto &Item = Items[*ExpectedIndex];
48 if (Size > Traits::length(Item))
56 auto ExpectedIndex = translateOffsetIndex(Offset);
58 return ExpectedIndex.takeError();
59 Buffer = Traits::bytes(Items[*ExpectedIndex]);
67 for (
const auto &Item : Items)
68 Size += Traits::length(Item);
76 for (
const auto &Item : Items) {
77 if (CurrentOffset >= Offset)
79 CurrentOffset += Traits::length(Item);
82 if (CurrentOffset != Offset)
93 #endif // LLVM_DEBUGINFO_MSF_SEQUENCEDITEMSTREAM_H
SequencedItemStream represents a sequence of objects stored in a standard container but for which it ...
Error readBytes(uint32_t Offset, uint32_t Size, ArrayRef< uint8_t > &Buffer) const override
uint32_t getLength() const override
static ArrayRef< uint8_t > bytes(const T &Item)=delete
Tagged union holding either a T or a Error.
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
SequencedItemStream()=default
static size_t length(const T &Item)=delete
Error readLongestContiguousChunk(uint32_t Offset, ArrayRef< uint8_t > &Buffer) const override
static ErrorSuccess success()
Create a success value.
void setItems(ArrayRef< T > ItemArray)
Lightweight error class with error context and mandatory checking.