Reworked command line argument handling (#804)
* Reworked command line argument handling Added a new class to handle these
This commit is contained in:
parent
b1eafdbcc6
commit
165b66a718
2 changed files with 192 additions and 122 deletions
|
|
@ -37,6 +37,7 @@
|
|||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <unordered_map>
|
||||
#include <numeric>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
|
|
@ -71,6 +72,26 @@
|
|||
#include "camera.hpp"
|
||||
#include "benchmark.hpp"
|
||||
|
||||
class CommandLineParser
|
||||
{
|
||||
public:
|
||||
struct CommandLineOption {
|
||||
std::vector<std::string> commands;
|
||||
std::string value;
|
||||
bool hasValue = false;
|
||||
std::string help;
|
||||
bool set = false;
|
||||
};
|
||||
std::unordered_map<std::string, CommandLineOption> options;
|
||||
CommandLineParser();
|
||||
void add(std::string name, std::vector<std::string> commands, bool hasValue, std::string help);
|
||||
void printHelp();
|
||||
void parse(std::vector<const char*> arguments);
|
||||
bool isSet(std::string name);
|
||||
std::string getValueAsString(std::string name, std::string defaultValue);
|
||||
int32_t getValueAsInt(std::string name, int32_t defaultValue);
|
||||
};
|
||||
|
||||
class VulkanExampleBase
|
||||
{
|
||||
private:
|
||||
|
|
@ -160,6 +181,7 @@ public:
|
|||
uint32_t height = 720;
|
||||
|
||||
vks::UIOverlay UIOverlay;
|
||||
CommandLineParser commandLineParser;
|
||||
|
||||
/** @brief Last frame time measured using a high performance timer (if available) */
|
||||
float frameTimer = 1.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue