mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
command_line refactor
This commit is contained in:
parent
1b1f11e0b8
commit
93acc5ce57
2 changed files with 64 additions and 55 deletions
|
|
@ -7,35 +7,35 @@
|
|||
#include "../files/engine_paths.h"
|
||||
|
||||
class ArgsReader {
|
||||
int argc;
|
||||
char** argv;
|
||||
int pos = 0;
|
||||
const char* last = "";
|
||||
int argc;
|
||||
char** argv;
|
||||
int pos = 0;
|
||||
const char* last = "";
|
||||
public:
|
||||
ArgsReader(int argc, char** argv) : argc(argc), argv(argv) {}
|
||||
ArgsReader(int argc, char** argv) : argc(argc), argv(argv) {}
|
||||
|
||||
void skip() {
|
||||
pos++;
|
||||
}
|
||||
void skip() {
|
||||
pos++;
|
||||
}
|
||||
|
||||
bool hasNext() const {
|
||||
return pos < argc;
|
||||
}
|
||||
bool hasNext() const {
|
||||
return pos < argc;
|
||||
}
|
||||
|
||||
bool isKeywordArg() const {
|
||||
return last[0] == '-';
|
||||
}
|
||||
bool isKeywordArg() const {
|
||||
return last[0] == '-';
|
||||
}
|
||||
|
||||
std::string next() {
|
||||
if (pos >= argc) {
|
||||
throw std::runtime_error("unexpected end");
|
||||
}
|
||||
last = argv[pos];
|
||||
return argv[pos++];
|
||||
}
|
||||
std::string next() {
|
||||
if (pos >= argc) {
|
||||
throw std::runtime_error("unexpected end");
|
||||
}
|
||||
last = argv[pos];
|
||||
return argv[pos++];
|
||||
}
|
||||
};
|
||||
|
||||
/* @return false if engine start can*/
|
||||
extern bool parse_cmdline(int argc, char** argv, EnginePaths& paths);
|
||||
|
||||
#endif // UTIL_COMMAND_LINE_H_
|
||||
#endif // UTIL_COMMAND_LINE_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue