sdbus-c++ 2.0.0
High-level C++ D-Bus library based on systemd D-Bus implementation
Loading...
Searching...
No Matches
Types.h File Reference
#include <sdbus-c++/Message.h>
#include <sdbus-c++/TypeTraits.h>
#include <cstring>
#include <memory>
#include <string>
#include <tuple>
#include <type_traits>
#include <typeinfo>
#include <utility>

Go to the source code of this file.

Classes

class  sdbus::Variant
 
class  sdbus::Struct< _ValueTypes >
 
class  sdbus::ObjectPath
 
class  sdbus::BusName
 
class  sdbus::InterfaceName
 
class  sdbus::MemberName
 
class  sdbus::Signature
 
struct  sdbus::UnixFd
 
struct  std::tuple_element< _I, sdbus::Struct< _ValueTypes... > >
 
struct  std::tuple_size< sdbus::Struct< _ValueTypes... > >
 

Macros

SDBUSCPP_REGISTER_STRUCT

A convenient way to extend sdbus-c++ type system with user-defined structs.

The macro teaches sdbus-c++ to recognize the user-defined struct as a valid C++ representation of a D-Bus Struct type, and enables clients to use their struct conveniently instead of the (too generic and less expressive) sdbus::Struct<...> in sdbus-c++ API.

The first argument is the struct type name and the remaining arguments are names of struct members. Members must be of types supported by sdbus-c++ (or of user-defined types that sdbus-c++ was taught to support). Members can be other structs (nesting is supported). The macro must be placed in the global namespace.

For example, given the user-defined struct ABC:

namespace foo { struct ABC { int number; std::string name; std::vector<double> data; }; }

one can teach sdbus-c++ about the contents of this struct simply with:

SDBUSCPP_REGISTER_STRUCT(foo::ABC, number, name, data);

The macro effectively generates the sdbus::Message serialization and deserialization operators and the sdbus::signature_of specialization for foo::ABC.

Up to 16 struct members are supported by the macro.

#define SDBUSCPP_REGISTER_STRUCT(STRUCT, ...)
 

Typedefs

using sdbus::ConnectionName = BusName
 
using sdbus::MethodName = MemberName
 
using sdbus::SignalName = MemberName
 
using sdbus::PropertyName = MemberName
 
template<typename _T1 , typename _T2 >
using sdbus::DictEntry = std::pair< _T1, _T2 >
 

Functions

template<typename... _Elements>
 sdbus::Struct (_Elements...) -> Struct< _Elements... >
 
template<typename... _Elements>
constexpr Struct< std::decay_t< _Elements >... > sdbus::make_struct (_Elements &&... args)
 

Detailed Description

(C) 2016 - 2021 KISTLER INSTRUMENTE AG, Winterthur, Switzerland (C) 2016 - 2024 Stanislav Angelovic stani.nosp@m.slav.nosp@m..ange.nosp@m.lovi.nosp@m.c@pro.nosp@m.tonm.nosp@m.ail.c.nosp@m.om

Created on: Nov 23, 2016 Project: sdbus-c++ Description: High-level D-Bus IPC C++ library based on sd-bus

This file is part of sdbus-c++.

sdbus-c++ is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version.

sdbus-c++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with sdbus-c++. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

◆ SDBUSCPP_REGISTER_STRUCT

#define SDBUSCPP_REGISTER_STRUCT (   STRUCT,
  ... 
)
Value:
namespace sdbus { \
static_assert(SDBUSCPP_PP_NARG(__VA_ARGS__) <= 16, \
"Not more than 16 struct members are supported, please open an issue if you need more"); \
inline sdbus::Message& operator<<(sdbus::Message& msg, const STRUCT& items) \
{ \
return msg << sdbus::Struct{std::forward_as_tuple(SDBUSCPP_STRUCT_MEMBERS(items, __VA_ARGS__))}; \
} \
inline sdbus::Message& operator>>(sdbus::Message& msg, STRUCT& items) \
{ \
sdbus::Struct s{std::forward_as_tuple(SDBUSCPP_STRUCT_MEMBERS(items, __VA_ARGS__))}; \
return msg >> s; \
} \
template <> \
struct signature_of<STRUCT> \
: signature_of<sdbus::Struct<SDBUSCPP_STRUCT_MEMBER_TYPES(STRUCT, __VA_ARGS__)>> \
{}; \
} \
Definition Message.h:81
Definition Types.h:135

Typedef Documentation

◆ DictEntry

template<typename _T1 , typename _T2 >
sdbus::DictEntry

DictEntry is implemented as std::pair, a standard value_type in STL(-like) associative containers.