Browse Source

Util: Change System to direct-list-initialization

master
Riyyi 3 years ago
parent
commit
26ceceeba5
  1. 10
      src/util/system.cpp
  2. 3
      src/util/system.h

10
src/util/system.cpp

@ -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 ;

3
src/util/system.h

@ -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);

Loading…
Cancel
Save