27#ifndef SDBUS_CXX_TYPES_H_
28#define SDBUS_CXX_TYPES_H_
60 template <
typename _ValueType>
63 msg_.openVariant<_ValueType>();
69 template <
typename... _Elements>
70 Variant(
const std::variant<_Elements...>& value)
77 template <
typename _ValueType>
78 _ValueType get()
const
83 msg_.enterVariant<_ValueType>();
90 template <typename _ValueType, typename = std::enable_if_t<signature_of<_ValueType>::is_valid>>
91 explicit operator _ValueType()
const
93 return get<_ValueType>();
96 template <
typename... _Elements>
97 operator std::variant<_Elements...>()
const
99 std::variant<_Elements...> result;
105 template <
typename _Type>
106 bool containsValueOfType()
const
108 constexpr auto signature = as_null_terminated(signature_of_v<_Type>);
109 return std::strcmp(signature.data(), peekValueType()) == 0;
112 bool isEmpty()
const;
114 void serializeTo(
Message& msg)
const;
115 void deserializeFrom(
Message& msg);
116 const char* peekValueType()
const;
132 template <
typename... _ValueTypes>
134 :
public std::tuple<_ValueTypes...>
137 using std::tuple<_ValueTypes...>::tuple;
141 explicit Struct(
const std::tuple<_ValueTypes...>& t)
142 : std::tuple<_ValueTypes...>(t)
146 template <std::
size_t _I>
149 return std::get<_I>(*
this);
152 template <std::
size_t _I>
153 const auto& get()
const
155 return std::get<_I>(*
this);
159 template <
typename... _Elements>
160 Struct(_Elements...) -> Struct<_Elements...>;
162 template<
typename... _Elements>
163 constexpr Struct<std::decay_t<_Elements>...>
164 make_struct(_Elements&&... args)
166 typedef Struct<std::decay_t<_Elements>...> result_type;
167 return result_type(std::forward<_Elements>(args)...);
181 : std::string(std::move(value))
187 using std::string::operator=;
200 explicit BusName(std::string value)
201 : std::string(std::move(value))
203 explicit BusName(
const char* value)
207 using std::string::operator=;
224 : std::string(std::move(value))
230 using std::string::operator=;
244 : std::string(std::move(value))
250 using std::string::operator=;
268 : std::string(std::move(value))
274 using std::string::operator=;
294 : fd_(checkedDup(fd))
315 fd_ = checkedDup(other.fd_);
321 *
this = std::move(other);
331 fd_ = std::exchange(other.fd_, -1);
340 [[nodiscard]]
int get()
const
345 void reset(
int fd = -1)
352 *
this =
UnixFd{fd, adopt_fd};
357 return std::exchange(fd_, -1);
360 [[nodiscard]]
bool isValid()
const
371 static int checkedDup(
int fd);
383 template<
typename _T1,
typename _T2>
388template <
size_t _I,
typename... _ValueTypes>
389struct std::tuple_element<_I, sdbus::Struct<_ValueTypes...>>
390 : std::tuple_element<_I, std::tuple<_ValueTypes...>>
393template <
typename... _ValueTypes>
394struct std::tuple_size<sdbus::Struct<_ValueTypes...>>
395 : std::tuple_size<std::tuple<_ValueTypes...>>
std::pair< _T1, _T2 > DictEntry
Definition Types.h:384
Definition TypeTraits.h:55
Definition TypeTraits.h:97