33namespace fs = std::filesystem;
39 std::vector<std::string> m_command;
45 std::vector<std::string> m_environment;
51 , std::vector<std::string>
const& command
52 , fs::path
const& path_dir_fifo
53 , std::vector<std::string>
const& environment
56 [[maybe_unused]] std::vector<std::string>
const& get_command()
const {
return m_command; }
57 [[maybe_unused]] fs::path get_stdin()
const {
return m_stdin; }
58 [[maybe_unused]] fs::path get_stdout()
const {
return m_stdout; }
59 [[maybe_unused]] fs::path get_stderr()
const {
return m_stderr; }
60 [[maybe_unused]] fs::path get_exit()
const {
return m_exit; }
61 [[maybe_unused]] fs::path get_pid()
const {
return m_pid; }
62 [[maybe_unused]] std::vector<std::string>
const& get_environment()
const {
return m_environment; }
71inline Message::Message()
85inline Message::Message(pid_t pid
86 , std::vector<std::string>
const& command
87 , fs::path
const& path_dir_fifo
88 , std::vector<std::string>
const& environment
89 ) : m_command(command)
90 , m_stdin(
ns_fs::placeholders_replace(path_dir_fifo /
"{}" /
"stdin.fifo", pid))
91 , m_stdout(
ns_fs::placeholders_replace(path_dir_fifo /
"{}" /
"stdout.fifo", pid))
92 , m_stderr(
ns_fs::placeholders_replace(path_dir_fifo /
"{}" /
"stderr.fifo", pid))
93 , m_exit(
ns_fs::placeholders_replace(path_dir_fifo /
"{}" /
"exit.fifo", pid))
94 , m_pid(
ns_fs::placeholders_replace(path_dir_fifo /
"{}" /
"pid.fifo", pid))
95 , m_environment(environment)
107 return_if(str_raw_json.empty(), Error(
"D::Empty json data"));
111 message.m_command = Pop(db(
"command").
template value<std::vector<std::string>>());
113 message.m_stdin = Pop(db(
"stdin").
template value<std::string>());
114 message.m_stdout = Pop(db(
"stdout").
template value<std::string>());
115 message.m_stderr = Pop(db(
"stderr").
template value<std::string>());
116 message.m_exit = Pop(db(
"exit").
template value<std::string>());
117 message.m_pid = Pop(db(
"pid").
template value<std::string>());
119 message.m_environment = Pop(db(
"environment").
template value<std::vector<std::string>>());
132 db(
"command") = message.m_command;
133 db(
"stdin") = message.get_stdin().string();
134 db(
"stdout") = message.get_stdout().string();
135 db(
"stderr") = message.get_stderr().string();
136 db(
"exit") = message.get_exit().string();
137 db(
"pid") = message.get_pid().string();
138 db(
"environment") = message.get_environment();
A type-safe wrapper around nlohmann::json for database operations.
friend Value< std::string > serialize(Message const &message) noexcept
Serializes a Message class into a json string.
friend Value< Message > deserialize(std::string_view str_raw_json) noexcept
Deserializes JSON string into a Binds object.
A database that interfaces with nlohmann json.
Enhanced error handling framework built on std::expected.
Portal IPC message serialization and deserialization.
Value< Message > deserialize(std::string_view str_raw_json) noexcept
Deserializes a json string into a Message class.
Value< std::string > serialize(Message const &message) noexcept
Serializes a Message class into a json string.
Value< Db > from_string(S &&s)
Parses a JSON string and creates a Db object.
Enhanced filesystem utilities wrapping std::filesystem.
Enhanced expected type with integrated logging capabilities.