Add support for Unix fd D-Bus type

This commit is contained in:
sangelovic
2019-06-10 21:19:56 +02:00
committed by Stanislav Angelovič
parent efe799ef3f
commit 57c840637c
13 changed files with 125 additions and 2 deletions
+3
View File
@@ -43,6 +43,7 @@ namespace sdbus {
class ObjectPath;
class Signature;
template <typename... _ValueTypes> class Struct;
struct UnixFd;
class MethodReply;
namespace internal {
class ISdBus;
@@ -100,6 +101,7 @@ namespace sdbus {
Message& operator<<(const Variant &item);
Message& operator<<(const ObjectPath &item);
Message& operator<<(const Signature &item);
Message& operator<<(const UnixFd &item);
Message& operator>>(bool& item);
Message& operator>>(int16_t& item);
@@ -115,6 +117,7 @@ namespace sdbus {
Message& operator>>(Variant &item);
Message& operator>>(ObjectPath &item);
Message& operator>>(Signature &item);
Message& operator>>(UnixFd &item);
Message& openContainer(const std::string& signature);
Message& closeContainer();
+12
View File
@@ -40,6 +40,7 @@ namespace sdbus {
template <typename... _ValueTypes> class Struct;
class ObjectPath;
class Signature;
struct UnixFd;
class Message;
class MethodCall;
class MethodReply;
@@ -285,6 +286,17 @@ namespace sdbus {
}
};
template <>
struct signature_of<UnixFd>
{
static constexpr bool is_valid = true;
static const std::string str()
{
return "h";
}
};
template <typename _Element>
struct signature_of<std::vector<_Element>>
{
+39
View File
@@ -97,6 +97,12 @@ namespace sdbus {
mutable Message msg_{};
};
/********************************************//**
* @class Struct
*
* Representation of struct D-Bus type
*
***********************************************/
template <typename... _ValueTypes>
class Struct
: public std::tuple<_ValueTypes...>
@@ -135,6 +141,12 @@ namespace sdbus {
return result_type(std::forward<_Elements>(args)...);
}
/********************************************//**
* @class ObjectPath
*
* Representation of object path D-Bus type
*
***********************************************/
class ObjectPath : public std::string
{
public:
@@ -146,6 +158,12 @@ namespace sdbus {
using std::string::operator=;
};
/********************************************//**
* @class Signature
*
* Representation of Signature D-Bus type
*
***********************************************/
class Signature : public std::string
{
public:
@@ -157,6 +175,27 @@ namespace sdbus {
using std::string::operator=;
};
/********************************************//**
* @struct UnixFd
*
* Representation of Unix file descriptor D-Bus type
*
***********************************************/
struct UnixFd
{
int fd_ = -1;
UnixFd() = default;
UnixFd(int fd)
: fd_(fd)
{}
operator int() const
{
return fd_;
}
};
}
#endif /* SDBUS_CXX_TYPES_H_ */