11 #include <unordered_map> 48 virtual uint64_t
size()
const = 0;
65 virtual uint64_t read(std::byte**
output, uint64_t offset, uint64_t
size) = 0;
76 uint64_t
size()
const override;
77 uint64_t read(std::byte**
output, uint64_t offset, uint64_t size)
override;
93 uint64_t
size()
const override;
94 uint64_t read(std::byte**
output, uint64_t offset, uint64_t size)
override;
119 virtual void reset(
const std::byte*
data, uint64_t
size, uint64_t uncompressedSize) = 0;
125 virtual Status status()
const = 0;
134 void reset(
const std::byte*
data, uint64_t
size, uint64_t uncompressedSize)
override;
135 uint64_t read(std::byte**
output, uint64_t offset, uint64_t size)
override;
136 uint64_t
size()
const override;
137 Status status()
const override;
156 void reset(
const std::byte*
data, uint64_t
size, uint64_t uncompressedSize)
override;
157 uint64_t read(std::byte**
output, uint64_t offset, uint64_t size)
override;
158 uint64_t
size()
const override;
159 Status status()
const override;
181 void reset(
const std::byte*
data, uint64_t
size, uint64_t uncompressedSize)
override;
182 uint64_t read(std::byte**
output, uint64_t offset, uint64_t size)
override;
183 uint64_t
size()
const override;
184 Status status()
const override;
194 void* decompressionContext_ =
nullptr;
240 Status open(std::ifstream& stream);
303 std::pair<ByteOffset, ByteOffset> byteRange(
Timestamp startTime,
315 const std::optional<Header>&
header()
const;
319 const std::optional<Footer>& footer()
const;
323 const std::optional<Statistics>& statistics()
const;
329 const std::unordered_map<ChannelId, ChannelPtr> channels()
const;
334 const std::unordered_map<SchemaId, SchemaPtr> schemas()
const;
357 const std::vector<ChunkIndex>& chunkIndexes()
const;
385 static std::optional<Compression> ParseCompression(
const std::string_view compression);
392 std::FILE* file_ =
nullptr;
405 std::unordered_map<ChannelId, std::map<Timestamp, ByteOffset>>
messageIndex_;
410 bool parsedSummary_ =
false;
429 std::optional<Record>
next();
431 const Status& status()
const;
442 std::function<void(const SchemaPtr, ByteOffset)>
onSchema;
443 std::function<void(const ChannelPtr, ByteOffset)>
onChannel;
444 std::function<void(const Message&, ByteOffset)>
onMessage;
459 const Status& status()
const;
474 std::function<void(const Header&, ByteOffset)>
onHeader;
475 std::function<void(const Footer&, ByteOffset)>
onFooter;
476 std::function<void(const SchemaPtr, ByteOffset, std::optional<ByteOffset>)> onSchema;
477 std::function<void(const ChannelPtr, ByteOffset, std::optional<ByteOffset>)> onChannel;
478 std::function<void(const Message&, ByteOffset, std::optional<ByteOffset>)> onMessage;
479 std::function<void(const Chunk&, ByteOffset)>
onChunk;
488 std::function<void(const DataEnd&, ByteOffset)>
onDataEnd;
489 std::function<void(const Record&, ByteOffset, std::optional<ByteOffset>)> onUnknownRecord;
504 const Status& status()
const;
527 void operator++(
int);
544 Impl& operator=(
const Impl&) =
delete;
550 bool has_value()
const;
587 #ifdef MCAP_IMPLEMENTATION 588 #include "reader.inl"
Compression
Supported MCAP compression algorithms.
const std::byte * compressedData_
An Attachment is an arbitrary file embedded in an MCAP file, including a name, content-type, timestamps, and optional CRC. Attachment records are written in the Data section, outside of Chunks.
std::function< void(const ChannelPtr, ByteOffset)> onChannel
std::function< void(const Status &)> ProblemCallback
Parse the Summary section to produce seeking indexes and summary statistics. If the Summary section i...
std::function< void(const SummaryOffset &, ByteOffset)> onSummaryOffset
const std::byte * compressedData_
uint64_t uncompressedSize_
The Statistics record is found in the Summary section, providing counts and timestamp ranges for the ...
constexpr ByteOffset EndOffset
Wraps a status code and string message carrying additional context.
Describes a Channel that messages are written to. A Channel represents a single connection from a pub...
std::function< void(const Footer &, ByteOffset)> onFooter
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
relop
An iterable view of Messages in an MCAP file.
TypedChunkReader chunkReader_
std::function< void(const Statistics &, ByteOffset)> onStatistics
std::input_iterator_tag iterator_category
std::function< void(const SchemaPtr, ByteOffset)> onSchema
constexpr Timestamp MaxTime
ByteArray uncompressedData_
ICompressedReader implementation that decompresses LZ4 (https://lz4.github.io/lz4/) data...
IReadable implementation wrapping a std::ifstream input file stream.
std::function< void(const Metadata &, ByteOffset)> onMetadata
std::function< void(const DataEnd &, ByteOffset)> onDataEnd
std::multimap< std::string, MetadataIndex > metadataIndexes_
std::function< void(const Record &, ByteOffset)> onUnknownRecord
std::function< void(const Chunk &, ByteOffset)> onChunk
An collection of Schemas, Channels, and Messages that supports compression and indexing.
basic_string_view< char > string_view
std::optional< Footer > footer_
Read the file sequentially from Header to DataEnd to produce seeking indexes and summary statistics...
Chunk Index records are found in the Summary section, providing summary information for a single Chun...
std::unordered_map< SchemaId, SchemaPtr > schemas_
std::vector< std::byte > buffer_
std::function< void(const MessageIndex &, ByteOffset)> onMessageIndex
Attachment Index records are found in the Summary section, providing summary information for a single...
Returned when iterating over Messages in a file, MessageView contains a reference to one Message...
std::unique_ptr< FileStreamReader > fileStreamInput_
std::multimap< std::string, AttachmentIndex > attachmentIndexes_
std::unordered_map< ChannelId, ChannelPtr > channels_
std::function< void(const Attachment &, ByteOffset)> onAttachment
std::vector< std::byte > buffer_
A low-level interface for parsing MCAP-style TLV records from a data source.
std::function< void(ByteOffset)> onChunkEnd
If the Summary section is missing or incomplete, allow falling back to reading the file sequentially ...
uint64_t uncompressedSize_
std::shared_ptr< Schema > SchemaPtr
std::function< void(const Message &, ByteOffset)> onMessage
static const char * reader(lua_State *L, void *ud, size_t *size)
std::unordered_map< ChannelId, std::map< Timestamp, ByteOffset > > messageIndex_
Summary Offset records are found in the Summary Offset section. Records in the Summary section are gr...
const ProblemCallback & onProblem_
std::shared_ptr< Channel > ChannelPtr
The final record in the Data section, signaling the end of Data and beginning of Summary. Optionally contains a CRC of the entire Data section.
const ProblemCallback onProblem_
An abstract interface for reading MCAP data.
std::vector< ChunkIndex > chunkIndexes_
An abstract interface for compressed readers.
std::unique_ptr< Impl > impl_
std::optional< MessageView > curMessageView_
bool operator==(QwtEventPattern::MousePattern b1, QwtEventPattern::MousePattern b2)
Compare operator.
A "null" compressed reader that directly passes through uncompressed data. No internal buffers are al...
IReadable implementation wrapping a FILE* pointer created by fopen() and a read buffer.
std::function< void(const AttachmentIndex &, ByteOffset)> onAttachmentIndex
A single Message published to a Channel.
internal::IntervalTree< ByteOffset, ChunkIndex > chunkRanges_
std::optional< Statistics > statistics_
std::optional< TypedRecordReader > recordReader_
std::function< void(const Header &, ByteOffset)> onHeader
std::function< void(const ChunkIndex &, ByteOffset)> onChunkIndex
span_constexpr std::size_t size(span< T, Extent > const &spn)
static const char * output
ByteArray uncompressedData_
Describes a schema used for message encoding and decoding and/or describing the shape of messages...
std::optional< Header > header_
A list of timestamps to byte offsets for a single Channel. This record appears after each Chunk...
BufferReader uncompressedReader_
std::vector< std::byte > ByteArray
A mid-level interface for parsing and validating MCAP records from a data source. ...
ICompressedReader implementation that decompresses Zstandard (https://facebook.github.io/zstd/) data.
std::unique_ptr< FileReader > fileInput_
A generic Type-Length-Value record using a uint8 type and uint64 length. This is the generic form of ...
std::function< void(const MetadataIndex &, ByteOffset)> onMetadataIndex
Provides a read interface to an MCAP file.