class McapWriter

Declaration

class McapWriter { /* full declaration omitted */ };

Description

Provides a write interface to an MCAP file.

Declared at: mcap/include/mcap/writer.hpp:320

Method Overview

  • public void addChannel(mcap::Channel & channel)
  • public void addSchema(mcap::Schema & schema)
  • public void close()
  • public void closeLastChunk()
  • public mcap::IWritable * dataSink()
  • public mcap::Status open(std::string_view filename, const mcap::McapWriterOptions & options)
  • public void open(std::ostream & stream, const mcap::McapWriterOptions & options)
  • public void open(mcap::IWritable & writer, const mcap::McapWriterOptions & options)
  • public const mcap::Statistics & statistics() const
  • public void terminate()
  • public static uint64_t write(mcap::IWritable & output, const mcap::AttachmentIndex & index)
  • public static uint64_t write(mcap::IWritable & output, const mcap::MetadataIndex & index)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Statistics & stats)
  • public static uint64_t write(mcap::IWritable & output, const mcap::SummaryOffset & summaryOffset)
  • public static uint64_t write(mcap::IWritable & output, const mcap::DataEnd & dataEnd)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Record & record)
  • public static void write(mcap::IWritable & output, const std::string_view str)
  • public static void write(mcap::IWritable & output, const mcap::ByteArray bytes)
  • public static void write(mcap::IWritable & output, mcap::OpCode value)
  • public static void write(mcap::IWritable & output, uint16_t value)
  • public static void write(mcap::IWritable & output, const mcap::KeyValueMap & map, uint32_t size = 0)
  • public static void write(mcap::IWritable & output, uint32_t value)
  • public static void write(mcap::IWritable & output, uint64_t value)
  • public static void write(mcap::IWritable & output, const std::byte * data, uint64_t size)
  • public static uint64_t write(mcap::IWritable & output, const mcap::ChunkIndex & index)
  • public static uint64_t write(mcap::IWritable & output, const mcap::MessageIndex & index)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Chunk & chunk)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Metadata & metadata)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Attachment & attachment)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Message & message)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Channel & channel)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Schema & schema)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Footer & footer, bool crcEnabled)
  • public static uint64_t write(mcap::IWritable & output, const mcap::Header & header)
  • public mcap::Status write(const mcap::Metadata & metadata)
  • public mcap::Status write(mcap::Attachment & attachment)
  • public mcap::Status write(const mcap::Message & message)
  • public static void writeMagic(mcap::IWritable & output)
  • public ~McapWriter()

Methods

void addChannel(mcap::Channel& channel)

Description

Add a new channel to the MCAP file and set `channel.id` to a generated channel id. The channel id is used when adding messages to the file.

Declared at: mcap/include/mcap/writer.hpp:380

Parameters

mcap::Channel& channel
Description of the channel to register. The `id` value is ignored and will be set to a generated channel id.

void addSchema(mcap::Schema& schema)

Description

Add a new schema to the MCAP file and set `schema.id` to a generated schema id. The schema id is used when adding channels to the file.

Declared at: mcap/include/mcap/writer.hpp:370

Parameters

mcap::Schema& schema
Description of the schema to register. The `id` field is ignored and will be set to a generated schema id.

void close()

Description

Write the MCAP footer, flush pending writes to the output stream, and reset internal state.

Declared at: mcap/include/mcap/writer.hpp:354

void closeLastChunk()

Description

finishes the current chunk in progress and writes it to the file, if a chunk is in progress.

Declared at: mcap/include/mcap/writer.hpp:423

mcap::IWritable* dataSink()

Description

Returns a pointer to the IWritable data destination backing this writer. Will return nullptr if the writer is not open.

Declared at: mcap/include/mcap/writer.hpp:417

mcap::Status open(
    std::string_view filename,
    const mcap::McapWriterOptions& options)

Description

Open a new MCAP file for writing and write the header.

Declared at: mcap/include/mcap/writer.hpp:331

Parameters

std::string_view filename
Filename of the MCAP file to write.
const mcap::McapWriterOptions& options
Options for MCAP writing. `profile` is required.

Returns

A non-success status if the file could not be opened for writing.

void open(std::ostream& stream,
          const mcap::McapWriterOptions& options)

Description

Open a new MCAP file for writing and write the header.

Declared at: mcap/include/mcap/writer.hpp:348

Parameters

std::ostream& stream
Output stream to write to.
const mcap::McapWriterOptions& options
Options for MCAP writing. `profile` is required.

void open(mcap::IWritable& writer,
          const mcap::McapWriterOptions& options)

Description

Open a new MCAP file for writing and write the header.

Declared at: mcap/include/mcap/writer.hpp:340

Parameters

mcap::IWritable& writer
An implementation of the IWritable interface. Output bytes will be written to this object.
const mcap::McapWriterOptions& options
Options for MCAP writing. `profile` is required.

const mcap::Statistics& statistics() const

Description

Current MCAP file-level statistics. This is written as a Statistics record in the Summary section of the MCAP file.

Declared at: mcap/include/mcap/writer.hpp:411

void terminate()

Description

Reset internal state without writing the MCAP footer or flushing pending writes. This should only be used in error cases as the output MCAP file will be truncated.

Declared at: mcap/include/mcap/writer.hpp:361

static uint64_t write(
    mcap::IWritable& output,
    const mcap::AttachmentIndex& index)

Declared at: mcap/include/mcap/writer.hpp:441

Parameters

mcap::IWritable& output
const mcap::AttachmentIndex& index

static uint64_t write(
    mcap::IWritable& output,
    const mcap::MetadataIndex& index)

Declared at: mcap/include/mcap/writer.hpp:442

Parameters

mcap::IWritable& output
const mcap::MetadataIndex& index

static uint64_t write(
    mcap::IWritable& output,
    const mcap::Statistics& stats)

Declared at: mcap/include/mcap/writer.hpp:443

Parameters

mcap::IWritable& output
const mcap::Statistics& stats

static uint64_t write(
    mcap::IWritable& output,
    const mcap::SummaryOffset& summaryOffset)

Declared at: mcap/include/mcap/writer.hpp:444

Parameters

mcap::IWritable& output
const mcap::SummaryOffset& summaryOffset

static uint64_t write(
    mcap::IWritable& output,
    const mcap::DataEnd& dataEnd)

Declared at: mcap/include/mcap/writer.hpp:445

Parameters

mcap::IWritable& output
const mcap::DataEnd& dataEnd

static uint64_t write(mcap::IWritable& output,
                      const mcap::Record& record)

Declared at: mcap/include/mcap/writer.hpp:446

Parameters

mcap::IWritable& output
const mcap::Record& record

static void write(mcap::IWritable& output,
                  const std::string_view str)

Declared at: mcap/include/mcap/writer.hpp:448

Parameters

mcap::IWritable& output
const std::string_view str

static void write(mcap::IWritable& output,
                  const mcap::ByteArray bytes)

Declared at: mcap/include/mcap/writer.hpp:449

Parameters

mcap::IWritable& output
const mcap::ByteArray bytes

static void write(mcap::IWritable& output,
                  mcap::OpCode value)

Declared at: mcap/include/mcap/writer.hpp:450

Parameters

mcap::IWritable& output
mcap::OpCode value

static void write(mcap::IWritable& output,
                  uint16_t value)

Declared at: mcap/include/mcap/writer.hpp:451

Parameters

mcap::IWritable& output
uint16_t value

static void write(mcap::IWritable& output,
                  const mcap::KeyValueMap& map,
                  uint32_t size = 0)

Declared at: mcap/include/mcap/writer.hpp:455

Parameters

mcap::IWritable& output
const mcap::KeyValueMap& map
uint32_t size = 0

static void write(mcap::IWritable& output,
                  uint32_t value)

Declared at: mcap/include/mcap/writer.hpp:452

Parameters

mcap::IWritable& output
uint32_t value

static void write(mcap::IWritable& output,
                  uint64_t value)

Declared at: mcap/include/mcap/writer.hpp:453

Parameters

mcap::IWritable& output
uint64_t value

static void write(mcap::IWritable& output,
                  const std::byte* data,
                  uint64_t size)

Declared at: mcap/include/mcap/writer.hpp:454

Parameters

mcap::IWritable& output
const std::byte* data
uint64_t size

static uint64_t write(
    mcap::IWritable& output,
    const mcap::ChunkIndex& index)

Declared at: mcap/include/mcap/writer.hpp:440

Parameters

mcap::IWritable& output
const mcap::ChunkIndex& index

static uint64_t write(
    mcap::IWritable& output,
    const mcap::MessageIndex& index)

Declared at: mcap/include/mcap/writer.hpp:439

Parameters

mcap::IWritable& output
const mcap::MessageIndex& index

static uint64_t write(mcap::IWritable& output,
                      const mcap::Chunk& chunk)

Declared at: mcap/include/mcap/writer.hpp:438

Parameters

mcap::IWritable& output
const mcap::Chunk& chunk

static uint64_t write(
    mcap::IWritable& output,
    const mcap::Metadata& metadata)

Declared at: mcap/include/mcap/writer.hpp:437

Parameters

mcap::IWritable& output
const mcap::Metadata& metadata

static uint64_t write(
    mcap::IWritable& output,
    const mcap::Attachment& attachment)

Declared at: mcap/include/mcap/writer.hpp:436

Parameters

mcap::IWritable& output
const mcap::Attachment& attachment

static uint64_t write(
    mcap::IWritable& output,
    const mcap::Message& message)

Declared at: mcap/include/mcap/writer.hpp:435

Parameters

mcap::IWritable& output
const mcap::Message& message

static uint64_t write(
    mcap::IWritable& output,
    const mcap::Channel& channel)

Declared at: mcap/include/mcap/writer.hpp:434

Parameters

mcap::IWritable& output
const mcap::Channel& channel

static uint64_t write(mcap::IWritable& output,
                      const mcap::Schema& schema)

Declared at: mcap/include/mcap/writer.hpp:433

Parameters

mcap::IWritable& output
const mcap::Schema& schema

static uint64_t write(mcap::IWritable& output,
                      const mcap::Footer& footer,
                      bool crcEnabled)

Declared at: mcap/include/mcap/writer.hpp:432

Parameters

mcap::IWritable& output
const mcap::Footer& footer
bool crcEnabled

static uint64_t write(mcap::IWritable& output,
                      const mcap::Header& header)

Declared at: mcap/include/mcap/writer.hpp:431

Parameters

mcap::IWritable& output
const mcap::Header& header

mcap::Status write(const mcap::Metadata& metadata)

Description

Write a metadata record to the output stream.

Declared at: mcap/include/mcap/writer.hpp:405

Parameters

const mcap::Metadata& metadata
Named group of key/value string pairs to add.

Returns

A non-zero error code on failure.

mcap::Status write(mcap::Attachment& attachment)

Description

Write an attachment to the output stream.

Declared at: mcap/include/mcap/writer.hpp:397

Parameters

mcap::Attachment& attachment
Attachment to add. The `attachment.crc` will be calculated and set if configuration options allow CRC calculation.

Returns

A non-zero error code on failure.

mcap::Status write(const mcap::Message& message)

Description

Write a message to the output stream.

Declared at: mcap/include/mcap/writer.hpp:388

Parameters

const mcap::Message& message

Returns

A non-zero error code on failure.

static void writeMagic(mcap::IWritable& output)

Declared at: mcap/include/mcap/writer.hpp:429

Parameters

mcap::IWritable& output

~McapWriter()

Declared at: mcap/include/mcap/writer.hpp:322