iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
port_name.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13#ifndef IOX2_PORT_NAME_HPP
14#define IOX2_PORT_NAME_HPP
15
16#include "iox2/bb/expected.hpp"
19
20namespace iox2 {
21
22class PortName;
23
26 public:
27 PortNameView(PortNameView&&) noexcept = default;
28 PortNameView(const PortNameView&) = default;
29 auto operator=(PortNameView&&) noexcept -> PortNameView& = default;
30 auto operator=(const PortNameView&) -> PortNameView& = default;
31 ~PortNameView() noexcept = default;
32
34 static auto from_native_ptr(iox2_port_name_ptr m_ptr) -> PortNameView;
35
37 auto native_ptr() const -> iox2_port_name_ptr;
38
40 auto to_string() const -> iox2::bb::StaticString<IOX2_PORT_NAME_LENGTH>;
41
43 auto to_owned() const -> PortName;
44
45
46 private:
47 explicit PortNameView(iox2_port_name_ptr ptr);
48 iox2_port_name_ptr m_ptr = nullptr;
49};
50
52class PortName {
53 public:
54 PortName(PortName&&) noexcept;
55 auto operator=(PortName&&) noexcept -> PortName&;
57 auto operator=(const PortName&) -> PortName&;
58 ~PortName() noexcept;
59
61 auto as_view() const -> PortNameView;
62
66 static auto create(const char* value) -> iox2::bb::Expected<PortName, bb::SemanticStringError>;
67
69 auto to_string() const -> iox2::bb::StaticString<IOX2_PORT_NAME_LENGTH>;
70
71 private:
72 friend class PortNameView;
73
74 explicit PortName(iox2_port_name_h handle);
75 void drop() noexcept;
76 static auto create_impl(const char* value, size_t value_len)
77 -> iox2::bb::Expected<PortName, bb::SemanticStringError>;
78
79 iox2_port_name_h m_handle = nullptr;
80};
81} // namespace iox2
82
83#endif
Non-owning view of a [PortName].
Definition port_name.hpp:25
PortNameView(PortNameView &&) noexcept=default
static auto from_native_ptr(iox2_port_name_ptr m_ptr) -> PortNameView
Creates a [PortNameView] from a native [iox2_port_name_ptr].
auto to_string() const -> iox2::bb::StaticString< IOX2_PORT_NAME_LENGTH >
Returns a [iox2::bb::StaticString] containing the [PortName].
auto to_owned() const -> PortName
Creates a copy of the corresponding [PortName] and returns it.
auto native_ptr() const -> iox2_port_name_ptr
Returns the native [iox2_port_name_ptr].
Represent the name for a [Port].
Definition port_name.hpp:52
PortName(PortName &&) noexcept