stuff-from-scratch/src/core/CommandLineArgs.cpp

51 lines
907 B
C++
Raw Normal View History

2020-05-02 07:31:03 +00:00
#include "CommandLineArgs.h"
CommandLineArgs::CommandLineArgs()
2020-05-09 14:29:45 +00:00
: mArugments(),
mLaunchPath()
2020-05-02 07:31:03 +00:00
{
}
2022-10-03 06:45:10 +00:00
std::unique_ptr<CommandLineArgs> CommandLineArgs::Create()
2020-05-09 14:29:45 +00:00
{
return std::make_unique<CommandLineArgs>();
}
2022-10-03 06:45:10 +00:00
std::filesystem::path CommandLineArgs::getLaunchPath()
2020-05-09 14:29:45 +00:00
{
return mLaunchPath;
}
2022-10-03 06:45:10 +00:00
void CommandLineArgs::recordLaunchPath()
2020-05-09 14:29:45 +00:00
{
mLaunchPath = std::filesystem::current_path();
}
2022-10-03 06:45:10 +00:00
void CommandLineArgs::process(int argc, char *argv[])
2020-05-02 07:31:03 +00:00
{
2020-05-09 14:29:45 +00:00
for(int idx=0; idx<argc; idx++)
{
mArugments.push_back(std::string(argv[idx]));
}
2020-05-02 07:31:03 +00:00
}
2022-10-03 06:45:10 +00:00
void CommandLineArgs::process(const std::vector<std::string>& args)
2021-10-31 13:04:48 +00:00
{
mArugments = args;
}
2022-10-03 06:45:10 +00:00
std::size_t CommandLineArgs::getNumberOfArgs() const
2020-05-02 07:31:03 +00:00
{
2020-05-09 14:29:45 +00:00
return mArugments.size();
2020-05-02 07:31:03 +00:00
}
2022-10-03 06:45:10 +00:00
std::string CommandLineArgs::getArg(std::size_t index) const
2020-05-02 07:31:03 +00:00
{
2020-05-09 14:29:45 +00:00
if(index<mArugments.size())
{
return mArugments[index];
}
return "";
2020-05-02 07:31:03 +00:00
}