CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
test
test/Buffer.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 <algorithm>
12
#include <memory>
13
#include <ostream>
14
#include <string>
15
16
namespace
util
{
17
namespace
buffer
{
18
19
using
carla::Buffer;
20
21
using
shared_buffer
= std::shared_ptr<Buffer>;
22
using
const_shared_buffer
= std::shared_ptr<const Buffer>;
23
24
static
inline
shared_buffer
make_empty
(
size_t
size = 0u) {
25
return
size == 0u ?
26
std::make_shared<Buffer>() :
27
std::make_shared<Buffer>(size);
28
}
29
30
shared_buffer
make_random
(
size_t
size);
31
32
template
<
typename
T>
33
static
inline
shared_buffer
make
(
const
T &
buffer
) {
34
return
std::make_shared<Buffer>(boost::asio::buffer(
buffer
));
35
}
36
37
static
inline
std::string
as_string
(
const
Buffer
&buf) {
38
return
{
reinterpret_cast<
const
char
*
>
(buf.
data
()), buf.
size
()};
39
}
40
41
std::string
to_hex_string
(
const
Buffer
&buf,
size_t
length = 16u);
42
43
}
// namespace buffer
44
}
// namespace util
45
46
namespace
carla
{
47
48
static
inline
std::ostream &
operator<<
(std::ostream &out,
const
Buffer
&buf) {
49
out <<
"["
<< buf.
size
() <<
" bytes] "
<<
util::buffer::to_hex_string
(buf);
50
return
out;
51
}
52
53
static
inline
bool
operator==
(
const
Buffer
&lhs,
const
Buffer
&rhs) {
54
return
55
(lhs.
size
() == rhs.
size
()) &&
56
std::equal(lhs.
begin
(), lhs.
end
(), rhs.
begin
());
57
}
58
59
static
inline
bool
operator!=
(
const
Buffer
&lhs,
const
Buffer
&rhs) {
60
return
!(lhs == rhs);
61
}
62
63
}
// namespace carla
Buffer.h
carla::Buffer
A piece of raw data.
Definition
carla/Buffer.h:42
carla::Buffer::begin
const_iterator begin() const noexcept
Definition
carla/Buffer.h:221
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::end
const_iterator end() const noexcept
Definition
carla/Buffer.h:233
util::buffer::Buffer
A piece of raw data.
Definition
carla/Buffer.h:42
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::operator<<
static std::ostream & operator<<(std::ostream &out, const Buffer &buf)
Definition
test/Buffer.h:48
carla::operator==
static bool operator==(const Buffer &lhs, const Buffer &rhs)
Definition
test/Buffer.h:53
carla::operator!=
static bool operator!=(const Buffer &lhs, const Buffer &rhs)
Definition
test/Buffer.h:59
util::buffer
Definition
test/Buffer.cpp:12
util::buffer::as_string
static std::string as_string(const Buffer &buf)
Definition
test/Buffer.h:37
util::buffer::make_empty
static shared_buffer make_empty(size_t size=0u)
Definition
test/Buffer.h:24
util::buffer::shared_buffer
std::shared_ptr< Buffer > shared_buffer
Definition
test/Buffer.h:21
util::buffer::to_hex_string
std::string to_hex_string(const Buffer &buf, size_t length)
Definition
test/Buffer.cpp:31
util::buffer::make_random
shared_buffer make_random(size_t size)
Definition
test/Buffer.cpp:14
util::buffer::const_shared_buffer
std::shared_ptr< const Buffer > const_shared_buffer
Definition
test/Buffer.h:22
util::buffer::make
static shared_buffer make(const T &buffer)
Definition
test/Buffer.h:33
util
Definition
test/Buffer.cpp:11
Generated by
1.18.0