Util: Change System to direct-list-initialization

This commit is contained in:
Riyyi
2021-09-17 13:02:29 +02:00
parent 9926849640
commit 26ceceeba5
2 changed files with 7 additions and 6 deletions
+5 -5
View File
@@ -18,7 +18,7 @@ System::System()
{ {
} }
System::System(std::vector<std::string> arguments) System::System(const std::vector<std::string>& arguments)
: m_arguments(arguments) : m_arguments(arguments)
{ {
} }
@@ -44,7 +44,7 @@ System System::operator()(std::string command)
command = command.substr(index + 1); command = command.substr(index + 1);
} }
return System(arguments); return { arguments };
} }
System System::operator()(std::string_view command) System System::operator()(std::string_view command)
@@ -59,12 +59,12 @@ System System::operator()(const std::vector<const char*>& arguments)
stringArguments[i] = arguments[i]; stringArguments[i] = arguments[i];
} }
return System(stringArguments); return { stringArguments };
} }
System System::operator()(const std::vector<std::string>& arguments) System System::operator()(const std::vector<std::string>& arguments)
{ {
return System(arguments); return { arguments };
} }
System System::operator()(const std::vector<std::string_view>& arguments) System System::operator()(const std::vector<std::string_view>& arguments)
@@ -74,7 +74,7 @@ System System::operator()(const std::vector<std::string_view>& arguments)
stringArguments[i] = arguments[i]; stringArguments[i] = arguments[i];
} }
return System(stringArguments); return { stringArguments };
} }
// Shell equivalent ; // Shell equivalent ;
+2 -1
View File
@@ -14,7 +14,6 @@ using SplitCallback = std::function<void(size_t, char*)>;
class System { class System {
public: public:
System(); System();
System(std::vector<std::string> arguments);
virtual ~System() {} virtual ~System() {}
enum FileDescriptor { enum FileDescriptor {
@@ -43,6 +42,8 @@ public:
int status() const { return m_status; } int status() const { return m_status; }
private: private:
System(const std::vector<std::string>& arguments);
System exec(std::string input = ""); System exec(std::string input = "");
void readFromFileDescriptor(int fileDescriptor[2], std::string& output); void readFromFileDescriptor(int fileDescriptor[2], std::string& output);