analyse: move default chunk params into params header
This commit is contained in:
parent
7558c08e7d
commit
f2afa2a421
@ -19,4 +19,10 @@ namespace emory::chunk {
|
|||||||
/// The minimum number of bytes for a matching region.
|
/// The minimum number of bytes for a matching region.
|
||||||
std::ptrdiff_t minimum;
|
std::ptrdiff_t minimum;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr params DEFAULT_PARAMS {
|
||||||
|
.bits = 12,
|
||||||
|
.window = 8,
|
||||||
|
.minimum = 4096,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -69,32 +69,27 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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)
|
int main (int argc, char const **argv)
|
||||||
{
|
{
|
||||||
if (argc < NUM_ARGS_REQUIRED) {
|
if (argc < NUM_ARGS_REQUIRED) {
|
||||||
std::cerr << "usage: " << argv[ARG_SELF] << " <input> <output> [bits] [window] [minimum]\n"
|
std::cerr << "usage: " << argv[ARG_SELF] << " <input> <output> [bits] [window] [minimum]\n"
|
||||||
<< "default bits = " << DEFAULT_BITS << '\n'
|
<< "default bits = " << emory::chunk::DEFAULT_PARAMS.bits << '\n'
|
||||||
<< "default window = " << DEFAULT_WINDOW << '\n'
|
<< "default window = " << emory::chunk::DEFAULT_PARAMS.window << '\n'
|
||||||
<< "default minimum = " << DEFAULT_MINIMUM << '\n';
|
<< "default minimum = " << emory::chunk::DEFAULT_PARAMS.minimum << '\n';
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PARSE_DEFAULT(NAME, TYPE) \
|
emory::chunk::params p = emory::chunk::DEFAULT_PARAMS;
|
||||||
argc > ARG_##NAME \
|
if (argc > ARG_BITS)
|
||||||
? cruft::parse::from_string<TYPE> (argv[ARG_##NAME]) \
|
p.window = cruft::parse::from_string<std::size_t> (argv[ARG_WINDOW]);
|
||||||
: DEFAULT_##NAME
|
if (argc > ARG_WINDOW)
|
||||||
|
p.window = cruft::parse::from_string<std::size_t> (argv[ARG_BITS]);
|
||||||
|
if (argc > ARG_BITS)
|
||||||
|
p.minimum = cruft::parse::from_string<std::size_t> (argv[ARG_MINIMUM]);
|
||||||
|
|
||||||
|
std::cerr << p << '\n';
|
||||||
|
|
||||||
emory::chunk::params const p {
|
|
||||||
.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]);
|
cruft::mapped_file data (argv[ARGS_INPUT]);
|
||||||
std::cout << "size: " << data.size () << '\n';
|
std::cout << "size: " << data.size () << '\n';
|
||||||
|
Loading…
Reference in New Issue
Block a user