pjmsg_mcap_wrapper
Loading...
Searching...
No Matches
src
3rdparty
mcap
cpp
mcap
include
mcap
types.inl
Go to the documentation of this file.
1
#include "
internal.hpp
"
2
3
namespace
mcap
{
4
5
constexpr
std::string_view
OpCodeString
(
OpCode
opcode) {
6
switch
(opcode) {
7
case
OpCode::Header
:
8
return
"Header"
;
9
case
OpCode::Footer
:
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"
;
19
case
OpCode::MessageIndex
:
20
return
"MessageIndex"
;
21
case
OpCode::ChunkIndex
:
22
return
"ChunkIndex"
;
23
case
OpCode::Attachment
:
24
return
"Attachment"
;
25
case
OpCode::AttachmentIndex
:
26
return
"AttachmentIndex"
;
27
case
OpCode::Statistics
:
28
return
"Statistics"
;
29
case
OpCode::Metadata
:
30
return
"Metadata"
;
31
case
OpCode::MetadataIndex
:
32
return
"MetadataIndex"
;
33
case
OpCode::SummaryOffset
:
34
return
"SummaryOffset"
;
35
case
OpCode::DataEnd
:
36
return
"DataEnd"
;
37
default
:
38
return
"Unknown"
;
39
}
40
}
41
42
MetadataIndex::MetadataIndex
(
const
Metadata
& metadata,
ByteOffset
fileOffset)
43
: offset(fileOffset)
44
, length(9 + 4 + metadata.name.size() + 4 + internal::KeyValueMapSize(metadata.metadata))
45
, name(metadata.name) {}
46
47
bool
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
64
bool
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
std::string_view
internal.hpp
mcap
Definition
crc32.hpp:5
mcap::OpCode
OpCode
MCAP record types.
Definition
types.hpp:59
mcap::OpCode::MetadataIndex
@ MetadataIndex
mcap::OpCode::ChunkIndex
@ ChunkIndex
mcap::OpCode::Message
@ Message
mcap::OpCode::MessageIndex
@ MessageIndex
mcap::OpCode::DataEnd
@ DataEnd
mcap::OpCode::Schema
@ Schema
mcap::OpCode::SummaryOffset
@ SummaryOffset
mcap::OpCode::Channel
@ Channel
mcap::OpCode::Chunk
@ Chunk
mcap::OpCode::Header
@ Header
mcap::OpCode::Statistics
@ Statistics
mcap::OpCode::AttachmentIndex
@ AttachmentIndex
mcap::OpCode::Metadata
@ Metadata
mcap::OpCode::Footer
@ Footer
mcap::OpCode::Attachment
@ Attachment
mcap::OpCodeString
MCAP_PUBLIC constexpr std::string_view OpCodeString(OpCode opcode)
Get the string representation of an OpCode.
Definition
types.inl:5
mcap::ByteOffset
uint64_t ByteOffset
Definition
types.hpp:22
mcap::MetadataIndex::MetadataIndex
MetadataIndex()=default
mcap::Metadata
Holds a named map of key/value strings containing arbitrary user data. Metadata records are found in ...
Definition
types.hpp:316
mcap::RecordOffset
Definition
types.hpp:354
mcap::RecordOffset::operator==
bool operator==(const RecordOffset &other) const
Definition
types.inl:47
mcap::RecordOffset::operator>
bool operator>(const RecordOffset &other) const
Definition
types.inl:64
mcap::RecordOffset::chunkOffset
std::optional< ByteOffset > chunkOffset
Definition
types.hpp:356
mcap::RecordOffset::offset
ByteOffset offset
Definition
types.hpp:355
Generated by
1.9.8