mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
add vctest (WIP)
This commit is contained in:
parent
d9bd60f473
commit
5e8805f241
16 changed files with 439 additions and 52 deletions
37
src/util/ArgsReader.hpp
Normal file
37
src/util/ArgsReader.hpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
||||
namespace util {
|
||||
class ArgsReader {
|
||||
const char* last = "";
|
||||
char** argv;
|
||||
int argc;
|
||||
int pos = 0;
|
||||
public:
|
||||
ArgsReader(int argc, char** argv) : argv(argv), argc(argc) {
|
||||
}
|
||||
|
||||
void skip() {
|
||||
pos++;
|
||||
}
|
||||
|
||||
bool hasNext() const {
|
||||
return pos < argc && std::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++];
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue