mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
minor refactor
This commit is contained in:
parent
2a8b750ad7
commit
8ff629e1cd
15 changed files with 120 additions and 107 deletions
|
|
@ -1,40 +1,7 @@
|
|||
#ifndef UTIL_COMMAND_LINE_HPP_
|
||||
#define UTIL_COMMAND_LINE_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include "../files/engine_paths.hpp"
|
||||
|
||||
class ArgsReader {
|
||||
int argc;
|
||||
char** argv;
|
||||
int pos = 0;
|
||||
const char* last = "";
|
||||
public:
|
||||
ArgsReader(int argc, char** argv) : argc(argc), argv(argv) {}
|
||||
|
||||
void skip() {
|
||||
pos++;
|
||||
}
|
||||
|
||||
bool hasNext() const {
|
||||
return pos < argc && strlen(argv[pos]);
|
||||
}
|
||||
|
||||
bool isKeywordArg() const {
|
||||
return last[0] == '-';
|
||||
}
|
||||
|
||||
std::string next() {
|
||||
if (pos >= argc) {
|
||||
throw std::runtime_error("unexpected end");
|
||||
}
|
||||
last = argv[pos];
|
||||
return argv[pos++];
|
||||
}
|
||||
};
|
||||
class EnginePaths;
|
||||
|
||||
/// @return false if engine start can
|
||||
bool parse_cmdline(int argc, char** argv, EnginePaths& paths);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue