MCPcopy Create free account
hub / github.com/Kistler-Group/sdbus-cpp / dumpToString

Method dumpToString

src/Message.cpp:633–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

631}
632
633std::string Message::dumpToString(DumpFlags flags) const
634{
635#if LIBSYSTEMD_VERSION>=245 && !defined(SDBUS_basu)
636 char* buffer{};
637 SCOPE_EXIT{ free(buffer); }; // NOLINT(cppcoreguidelines-no-malloc,hicpp-no-malloc,cppcoreguidelines-owning-memory)
638 size_t size{};
639
640 const std::unique_ptr<FILE, int(*)(FILE*)> stream{open_memstream(&buffer, &size), fclose};
641 SDBUS_THROW_ERROR_IF(!stream, "Failed to open memory stream", errno);
642
643 auto r = sd_bus_message_dump(static_cast<sd_bus_message*>(msg_), stream.get(), static_cast<uint64_t>(flags));
644 SDBUS_THROW_ERROR_IF(r < 0, "Failed to dump the message", -r);
645
646 (void)fflush(stream.get());
647
648 return {buffer, size};
649#else
650 (void)flags;
651 throw Error(Error::Name{SD_BUS_ERROR_NOT_SUPPORTED}, "Dumping sd-bus message not supported by underlying version of libsystemd");
652#endif
653}
654
655const char* Message::getInterfaceName() const
656{

Callers 1

TESTFunction · 0.45

Calls 2

ErrorClass · 0.70
getMethod · 0.45

Tested by 1

TESTFunction · 0.36