mirror of https://github.com/tevador/RandomX
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
5 years ago
|
/*
|
||
|
Copyright (c) 2019 tevador
|
||
|
|
||
|
This file is part of RandomX.
|
||
|
|
||
|
RandomX is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
RandomX is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include <cstring>
|
||
|
#include <cstdlib>
|
||
|
#include <iostream>
|
||
|
|
||
|
inline void dump(const char* buffer, uint64_t count, const char* name) {
|
||
|
std::ofstream fout(name, std::ios::out | std::ios::binary);
|
||
|
fout.write(buffer, count);
|
||
|
fout.close();
|
||
|
}
|
||
|
|
||
|
inline void readOption(const char* option, int argc, char** argv, bool& out) {
|
||
|
for (int i = 0; i < argc; ++i) {
|
||
|
if (strcmp(argv[i], option) == 0) {
|
||
|
out = true;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
out = false;
|
||
|
}
|
||
|
|
||
|
inline void readIntOption(const char* option, int argc, char** argv, int& out, int defaultValue) {
|
||
|
for (int i = 0; i < argc - 1; ++i) {
|
||
|
if (strcmp(argv[i], option) == 0 && (out = atoi(argv[i + 1])) > 0) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
out = defaultValue;
|
||
|
}
|
||
|
|
||
|
inline void readInt(int argc, char** argv, int& out, int defaultValue) {
|
||
|
for (int i = 0; i < argc; ++i) {
|
||
|
if (*argv[i] != '-' && (out = atoi(argv[i])) > 0) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
out = defaultValue;
|
||
|
}
|