WPILibC++ 2024.3.2
MessagePack.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include <span>
10#include <string>
11#include <string_view>
12
13#include "wpi/mpack.h"
14
15namespace mpack {
16
18 mpack_write_str(writer, str.data(), str.size());
19}
20
22 std::span<const uint8_t> data) {
23 mpack_write_bytes(writer, reinterpret_cast<const char*>(data.data()),
24 data.size());
25}
26
28 std::span<const uint8_t> data) {
29 mpack_reader_init_data(reader, reinterpret_cast<const char*>(data.data()),
30 data.size());
31}
32
34 uint32_t maxLen = 1024);
35
37 std::string* out, uint32_t maxLen = 1024);
38
39} // namespace mpack
basic_string_view< char > string_view
Definition: core.h:501
struct mpack_tag_t mpack_tag_t
An MPack tag is a MessagePack object header.
Definition: mpack.h:2087
mpack_error_t
Error states for MPack objects.
Definition: mpack.h:2008
struct mpack_reader_t mpack_reader_t
A buffered MessagePack decoder.
Definition: mpack.h:4410
struct mpack_writer_t mpack_writer_t
A buffered MessagePack encoder.
Definition: mpack.h:3090
Abstracts all platform-specific code from MPack and handles configuration options.
Definition: MessagePack.h:15
void mpack_write_str(mpack_writer_t *writer, std::string_view str)
Definition: MessagePack.h:17
void mpack_reader_init_data(mpack_reader_t *reader, std::span< const uint8_t > data)
Definition: MessagePack.h:27
void mpack_write_bytes(mpack_writer_t *writer, std::span< const uint8_t > data)
Definition: MessagePack.h:21
mpack_error_t mpack_expect_str(mpack_reader_t *reader, std::string *out, uint32_t maxLen=1024)
mpack_error_t mpack_read_str(mpack_reader_t *reader, mpack_tag_t *tag, std::string *out, uint32_t maxLen=1024)