pjmsg_mcap_wrapper
Loading...
Searching...
No Matches
types.inl
Go to the documentation of this file.
1#include "internal.hpp"
2
3namespace mcap {
4
6 switch (opcode) {
8 return "Header";
10 return "Footer";
11 case OpCode::Schema:
12 return "Schema";
13 case OpCode::Channel:
14 return "Channel";
15 case OpCode::Message:
16 return "Message";
17 case OpCode::Chunk:
18 return "Chunk";
20 return "MessageIndex";
22 return "ChunkIndex";
24 return "Attachment";
26 return "AttachmentIndex";
28 return "Statistics";
30 return "Metadata";
32 return "MetadataIndex";
34 return "SummaryOffset";
35 case OpCode::DataEnd:
36 return "DataEnd";
37 default:
38 return "Unknown";
39 }
40}
41
43 : offset(fileOffset)
44 , length(9 + 4 + metadata.name.size() + 4 + internal::KeyValueMapSize(metadata.metadata))
45 , name(metadata.name) {}
46
47bool RecordOffset::operator==(const RecordOffset& other) const {
48 if (chunkOffset != std::nullopt && other.chunkOffset != std::nullopt) {
49 if (*chunkOffset != *other.chunkOffset) {
50 // messages are in separate chunks, cannot be equal.
51 return false;
52 }
53 // messages are in the same chunk, compare chunk-level offsets.
54 return (offset == other.offset);
55 }
56 if (chunkOffset != std::nullopt || other.chunkOffset != std::nullopt) {
57 // one message is in a chunk and one is not, cannot be equal.
58 return false;
59 }
60 // neither message is in a chunk, compare file-level offsets.
61 return (offset == other.offset);
62}
63
64bool RecordOffset::operator>(const RecordOffset& other) const {
65 if (chunkOffset != std::nullopt) {
66 if (other.chunkOffset != std::nullopt) {
67 if (*chunkOffset == *other.chunkOffset) {
68 // messages are in the same chunk, compare chunk-level offsets.
69 return (offset > other.offset);
70 }
71 // messages are in separate chunks, compare file-level offsets
72 return (*chunkOffset > *other.chunkOffset);
73 } else {
74 // this message is in a chunk, other is not, compare file-level offsets.
75 return (*chunkOffset > other.offset);
76 }
77 }
78 if (other.chunkOffset != std::nullopt) {
79 // other message is in a chunk, this is not, compare file-level offsets.
80 return (offset > *other.chunkOffset);
81 }
82 // neither message is in a chunk, compare file-level offsets.
83 return (offset > other.offset);
84}
85
86} // namespace mcap
Definition crc32.hpp:5
OpCode
MCAP record types.
Definition types.hpp:59
MCAP_PUBLIC constexpr std::string_view OpCodeString(OpCode opcode)
Get the string representation of an OpCode.
Definition types.inl:5
uint64_t ByteOffset
Definition types.hpp:22
MetadataIndex()=default
Holds a named map of key/value strings containing arbitrary user data. Metadata records are found in ...
Definition types.hpp:316
bool operator==(const RecordOffset &other) const
Definition types.inl:47
bool operator>(const RecordOffset &other) const
Definition types.inl:64
std::optional< ByteOffset > chunkOffset
Definition types.hpp:356
ByteOffset offset
Definition types.hpp:355