analyse: provide defaults for bits, window, and minimum
This commit is contained in:
parent
255beaefa5
commit
7558c08e7d
@ -56,27 +56,44 @@ static bool region_equal (emory::chunk::region const &a, emory::chunk::region co
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
enum {
|
||||
ARG_SELF,
|
||||
|
||||
ARGS_INPUT,
|
||||
ARGS_OUTPUT,
|
||||
|
||||
ARG_BITS,
|
||||
ARG_WINDOW,
|
||||
ARGS_MINIMUM,
|
||||
ARGS_INPUT,
|
||||
ARG_MINIMUM,
|
||||
|
||||
NUM_ARGS,
|
||||
NUM_ARGS_REQUIRED = 3,
|
||||
};
|
||||
|
||||
|
||||
static constexpr std::size_t DEFAULT_BITS = 12;
|
||||
static constexpr std::size_t DEFAULT_WINDOW = 4;
|
||||
static constexpr std::ptrdiff_t DEFAULT_MINIMUM = 512;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int main (int argc, char const **argv)
|
||||
{
|
||||
if (argc != NUM_ARGS) {
|
||||
std::cerr << "usage: " << argv[ARG_SELF] << " <bits> <window> <minimum> <input>\n";
|
||||
if (argc < NUM_ARGS_REQUIRED) {
|
||||
std::cerr << "usage: " << argv[ARG_SELF] << " <input> <output> [bits] [window] [minimum]\n"
|
||||
<< "default bits = " << DEFAULT_BITS << '\n'
|
||||
<< "default window = " << DEFAULT_WINDOW << '\n'
|
||||
<< "default minimum = " << DEFAULT_MINIMUM << '\n';
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#define PARSE_DEFAULT(NAME, TYPE) \
|
||||
argc > ARG_##NAME \
|
||||
? cruft::parse::from_string<TYPE> (argv[ARG_##NAME]) \
|
||||
: DEFAULT_##NAME
|
||||
|
||||
emory::chunk::params const p {
|
||||
.bits = cruft::parse::from_string<std::size_t> (argv[ARG_BITS ]),
|
||||
.window = cruft::parse::from_string<std::size_t> (argv[ARG_WINDOW]),
|
||||
.minimum = cruft::parse::from_string<std::ptrdiff_t> (argv[ARGS_MINIMUM]),
|
||||
.bits = PARSE_DEFAULT (BITS, std::size_t),
|
||||
.window = PARSE_DEFAULT (WINDOW, std::size_t),
|
||||
.minimum = PARSE_DEFAULT (MINIMUM, std::ptrdiff_t),
|
||||
};
|
||||
|
||||
cruft::mapped_file data (argv[ARGS_INPUT]);
|
||||
|
Loading…
Reference in New Issue
Block a user