1 #pragma once 2 3 #include <sdbusplus/message.hpp> 4 5 #include <algorithm> 6 #include <ranges> 7 #include <string_view> 8 9 namespace utils 10 { 11 12 namespace constants 13 { 14 constexpr std::string_view triggerDirStr = 15 "/xyz/openbmc_project/Telemetry/Triggers/"; 16 constexpr std::string_view reportDirStr = 17 "/xyz/openbmc_project/Telemetry/Reports/"; 18 19 constexpr std::string_view allowedCharactersInPath = 20 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_/"; 21 constexpr size_t maxPrefixesInId = 1; 22 23 const sdbusplus::message::object_path triggerDirPath = 24 sdbusplus::message::object_path(std::string(triggerDirStr)); 25 const sdbusplus::message::object_path reportDirPath = 26 sdbusplus::message::object_path(std::string(reportDirStr)); 27 } // namespace constants 28 29 inline bool isValidDbusPath(const std::string& path) 30 { 31 return (path.find_first_not_of(constants::allowedCharactersInPath) == 32 std::string::npos) && 33 !path.ends_with('/'); 34 } 35 36 sdbusplus::message::object_path pathAppend(sdbusplus::message::object_path path, 37 const std::string& appended); 38 39 std::string reportPathToId(const sdbusplus::message::object_path& path); 40 41 } // namespace utils 42