util.hpp (9b2a20d3cfa1131521456b9ebfde7a7bb8b234bb) util.hpp (8664252af8cac7f5c3e9ce693e546e0a6d1af39a)
1#pragma once
2#include "types.hpp"
3
4#include <stdplus/raw.hpp>
1#pragma once
2#include "types.hpp"
3
4#include <stdplus/raw.hpp>
5#include <stdplus/zstring.hpp>
5#include <stdplus/zstring_view.hpp>
6
7#include <optional>
8#include <string>
9#include <string_view>
10#include <unordered_set>
11
12namespace phosphor
13{

--- 51 unchanged lines hidden (view full) ---

65
66namespace internal
67{
68
69/* @brief runs the given command in child process.
70 * @param[in] path - path of the binary file which needs to be execeuted.
71 * @param[in] args - arguments of the command.
72 */
6
7#include <optional>
8#include <string>
9#include <string_view>
10#include <unordered_set>
11
12namespace phosphor
13{

--- 51 unchanged lines hidden (view full) ---

65
66namespace internal
67{
68
69/* @brief runs the given command in child process.
70 * @param[in] path - path of the binary file which needs to be execeuted.
71 * @param[in] args - arguments of the command.
72 */
73void executeCommandinChildProcess(stdplus::const_zstring path, char** args);
73void executeCommandinChildProcess(stdplus::zstring_view path, char** args);
74
75/** @brief Get ignored interfaces from environment */
76std::string_view getIgnoredInterfacesEnv();
77
78/** @brief Parse the comma separated interface names */
79std::unordered_set<std::string_view>
80 parseInterfaces(std::string_view interfaces);
81
82/** @brief Get the ignored interfaces */
83const std::unordered_set<std::string_view>& getIgnoredInterfaces();
84
85} // namespace internal
86
87/* @brief runs the given command in child process.
88 * @param[in] path -path of the binary file which needs to be execeuted.
89 * @param[in] tArgs - arguments of the command.
90 */
91template <typename... ArgTypes>
74
75/** @brief Get ignored interfaces from environment */
76std::string_view getIgnoredInterfacesEnv();
77
78/** @brief Parse the comma separated interface names */
79std::unordered_set<std::string_view>
80 parseInterfaces(std::string_view interfaces);
81
82/** @brief Get the ignored interfaces */
83const std::unordered_set<std::string_view>& getIgnoredInterfaces();
84
85} // namespace internal
86
87/* @brief runs the given command in child process.
88 * @param[in] path -path of the binary file which needs to be execeuted.
89 * @param[in] tArgs - arguments of the command.
90 */
91template <typename... ArgTypes>
92void execute(stdplus::const_zstring path, ArgTypes&&... tArgs)
92void execute(stdplus::zstring_view path, ArgTypes&&... tArgs)
93{
94 using expandType = char*[];
95
96 expandType args = {const_cast<char*>(tArgs)..., nullptr};
97
98 internal::executeCommandinChildProcess(path, args);
99}
100
101} // namespace network
102
103} // namespace phosphor
93{
94 using expandType = char*[];
95
96 expandType args = {const_cast<char*>(tArgs)..., nullptr};
97
98 internal::executeCommandinChildProcess(path, args);
99}
100
101} // namespace network
102
103} // namespace phosphor