CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
MsgPack.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
carla/Buffer.h
"
10
11
#include <rpc/msgpack.hpp>
12
13
namespace
carla
{
14
15
class
MsgPack
{
16
public
:
17
18
template
<
typename
T>
19
static
Buffer
Pack
(
const
T &obj) {
20
namespace
mp =
::clmdep_msgpack
;
21
mp::sbuffer sbuf;
22
mp::pack(sbuf, obj);
23
return
Buffer
(
reinterpret_cast<
const
unsigned
char
*
>
(sbuf.data()), sbuf.size());
24
}
25
26
template
<
typename
T>
27
static
T
UnPack
(
const
Buffer
&buffer) {
28
namespace
mp =
::clmdep_msgpack
;
29
return
mp::unpack(
reinterpret_cast<
const
char
*
>
(buffer.
data
()), buffer.
size
()).template as<T>();
30
}
31
32
template
<
typename
T>
33
static
T
UnPack
(
const
unsigned
char
*data,
size_t
size) {
34
namespace
mp =
::clmdep_msgpack
;
35
return
mp::unpack(
reinterpret_cast<
const
char
*
>
(data), size).template as<T>();
36
}
37
};
38
39
}
// namespace carla
Buffer.h
carla::Buffer
A piece of raw data.
Definition
carla/Buffer.h:42
carla::Buffer::data
const value_type * data() const noexcept
Direct access to the allocated memory or nullptr if no memory is allocated.
Definition
carla/Buffer.h:156
carla::Buffer::size
size_type size() const noexcept
Definition
carla/Buffer.h:197
carla::Buffer::Buffer
Buffer()=default
Create an empty buffer.
carla::MsgPack
Definition
MsgPack.h:15
carla::MsgPack::UnPack
static T UnPack(const Buffer &buffer)
Definition
MsgPack.h:27
carla::MsgPack::UnPack
static T UnPack(const unsigned char *data, size_t size)
Definition
MsgPack.h:33
carla::MsgPack::Pack
static Buffer Pack(const T &obj)
Definition
MsgPack.h:19
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
clmdep_msgpack
Definition
MsgPackAdaptors.h:26
Generated by
1.18.0