mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge branch 'main' into devtools
This commit is contained in:
commit
8ee493dbda
15 changed files with 120 additions and 107 deletions
|
|
@ -1,9 +1,44 @@
|
|||
#include "command_line.hpp"
|
||||
|
||||
#include "../files/engine_paths.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
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++];
|
||||
}
|
||||
};
|
||||
|
||||
bool perform_keyword(ArgsReader& reader, const std::string& keyword, EnginePaths& paths) {
|
||||
if (keyword == "--res") {
|
||||
auto token = reader.next();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace util {
|
||||
/// @brief Function used for string serialization in text formats
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue