Added class to retrieve and store arguments
This commit is contained in:
@@ -30,7 +30,6 @@ public:
|
|||||||
void setBrightnessByPercentage();
|
void setBrightnessByPercentage();
|
||||||
|
|
||||||
std::vector<std::string> getOptions();
|
std::vector<std::string> getOptions();
|
||||||
//std::ofstream getStreamToOverwriteBrightness();
|
|
||||||
|
|
||||||
int getIncrement() const;
|
int getIncrement() const;
|
||||||
int getDecrement() const;
|
int getDecrement() const;
|
||||||
|
|||||||
@@ -1,32 +1,31 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "AlterBrightness.h"
|
#include "AlterBrightness.h"
|
||||||
#include "Brightness.h"
|
#include "Brightness.h"
|
||||||
|
#include"RetrieveArguments.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
RetrieveArguments args{argc, argv};
|
||||||
Brightness br{};
|
Brightness br{};
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
{
|
{
|
||||||
std::string control{*(argv + 1)};
|
auto control{args.argumentElements()[1]};
|
||||||
auto changeAmount = atoi(*(argv + 2));
|
auto changeAmount = args.argumentElements()[2];
|
||||||
auto brightnessPercentage = atoi(*(argv + 2));
|
auto brightnessPercentage = args.argumentElements()[2];
|
||||||
|
|
||||||
br.grabBrightness();
|
br.grabBrightness();
|
||||||
br.grabMaxBrightness();
|
br.grabMaxBrightness();
|
||||||
|
|
||||||
|
|
||||||
AlterBrightness ab{};
|
AlterBrightness ab{};
|
||||||
ab.setIncrement(changeAmount);
|
ab.setIncrement(atoi(changeAmount.c_str()));
|
||||||
ab.setDecrement(changeAmount);
|
ab.setDecrement(atoi(changeAmount.c_str()));
|
||||||
ab.setPercentageBrightness(brightnessPercentage);
|
ab.setPercentageBrightness(atoi(brightnessPercentage.c_str()));
|
||||||
|
|
||||||
ab.chooseChange((control));
|
ab.chooseChange((control));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (argc == 2)
|
else if (argc == 2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef RETRIEVEARGUMENTS_H
|
||||||
|
#define RETRIEVEARGUMENTS_H
|
||||||
|
|
||||||
|
#include<vector>
|
||||||
|
#include<string>
|
||||||
|
|
||||||
|
class RetrieveArguments
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RetrieveArguments() = default;
|
||||||
|
RetrieveArguments(const int, char*[]);
|
||||||
|
|
||||||
|
void initilize(const int, char*[]);
|
||||||
|
|
||||||
|
std::vector<std::string> argumentElements() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::string> arguments;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RetrieveArguments::RetrieveArguments(const int amountOfArguments, char* argumentsFromInit[])
|
||||||
|
{
|
||||||
|
for (auto index=1; index!=amountOfArguments; ++index)
|
||||||
|
{
|
||||||
|
arguments.push_back(std::string{*(argumentsFromInit + index)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RetrieveArguments::initilize(const int amountOfArguments, char* argumentsFromInit[])
|
||||||
|
{
|
||||||
|
for (auto index=1; index!=amountOfArguments; ++index)
|
||||||
|
arguments.push_back(std::string{*(argumentsFromInit + index)});
|
||||||
|
}
|
||||||
|
std::vector<std::string> RetrieveArguments::argumentElements() const
|
||||||
|
{
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
Hot.out: AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h
|
Hot.out: AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h RetrieveArguments.h
|
||||||
g++ AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h -o Hot.out
|
g++ AlterBrightness.cpp AlterBrightness.h Main.cpp Brightness.cpp Brightness.h RetrieveArguments.h -o Hot.out
|
||||||
|
|||||||
Reference in New Issue
Block a user