Move input file / output file out of RenderParams
This commit is contained in:
1 parent
d71be68fae
commit
88d482dcb3
7 files changed
+12
-9
No files matched your search
+3
-3
@@ -128,12 +128,12 @@ int Cli::run(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this->params.input_file != "")
|
if (!this->input_file.empty())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Extraneous argument: %s\n", argv[i]);
|
fprintf(stderr, "Extraneous argument: %s\n", argv[i]);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
this->params.input_file = argv[i];
|
this->input_file = argv[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -190,7 +190,7 @@ int Cli::handle_option(size_t flag_idx, const char * arg_value)
|
|||||||
|
|
||||||
case flag_output:
|
case flag_output:
|
||||||
case flag_output_l:
|
case flag_output_l:
|
||||||
this->params.output_file = arg_value;
|
this->output_file = arg_value;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case flag_width:
|
case flag_width:
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class Cli
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderParams params;
|
RenderParams params;
|
||||||
|
string_view input_file;
|
||||||
|
opt<string_view> output_file;
|
||||||
|
|
||||||
int run(int argc, char * argv[]);
|
int run(int argc, char * argv[]);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ Engine::Engine(const RenderParams & params)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::run()
|
int Engine::run(string_view input_file, opt<string_view> output_file)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@ class Engine
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Engine(const RenderParams & params);
|
Engine(const RenderParams & params);
|
||||||
int run();
|
int run(string_view input_file, opt<string_view> output_file);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RenderParams params;
|
RenderParams params;
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
struct RenderParams
|
struct RenderParams
|
||||||
{
|
{
|
||||||
string input_file;
|
|
||||||
string output_file;
|
|
||||||
size_t width = 0u;
|
size_t width = 0u;
|
||||||
size_t height = 0u;
|
size_t height = 0u;
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
using string = std::string;
|
using string = std::string;
|
||||||
|
using string_view = std::string_view;
|
||||||
|
template <typename T> using opt = std::optional<T>;
|
||||||
+1
-1
@@ -11,5 +11,5 @@ int main(int argc, char * argv[])
|
|||||||
return rc - 1;
|
return rc - 1;
|
||||||
}
|
}
|
||||||
Engine engine(cli.params);
|
Engine engine(cli.params);
|
||||||
return engine.run();
|
return engine.run(cli.input_file, cli.output_file);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user