Commit 22b6cb47 authored by Kučera Petr RNDr. Ph.D.'s avatar Kučera Petr RNDr. Ph.D.
Browse files

pccheck and pccompile prepared to use PrgOptions

parent 419439d8
......@@ -15,8 +15,6 @@
#include <future>
#include <iostream>
#include <cxxopts.hpp>
#include "cardinal.h"
#include "cnfcompress.h"
#include "logstream.h"
......@@ -150,9 +148,19 @@ parse_log_enc_opts(
return true;
}
int
parse_arguments(int argc, char *argv[], config_t &conf)
std::optional<config_t>
parse_arguments(int argc, char *argv[])
{
config_t conf;
SUBool::PrgOptions opts(true);
opts.SetHelpDesc(prg_help);
opts.InputOutput(&conf.input_file, &conf.output_file);
if (!opts.Parse(argc, argv))
{
return {};
}
return conf;
#if 0
try
{
cxxopts::Options options(SUBool::kPrgName, SUBool::kPrgDesc);
......@@ -405,6 +413,7 @@ parse_arguments(int argc, char *argv[], config_t &conf)
return 1;
}
return 0;
#endif
}
int
......@@ -604,15 +613,13 @@ execute(const config_t &conf, SUBool::CNF cnf)
int
main(int argc, char *argv[])
{
config_t conf;
int r = parse_arguments(argc, argv, conf);
if (r != 0)
auto conf = parse_arguments(argc, argv);
if (!conf)
{
return r;
return 1;
}
SUBool::logs.mVerbLevel = conf.verbosity;
SUBool::CNF cnf;
r = input(conf, &cnf);
auto r = input(*conf, &cnf);
if (r != 0)
{
return r;
......@@ -623,12 +630,11 @@ main(int argc, char *argv[])
std::signal(SIGINT, terminate);
SUBool::logs.TLog(SUBool::LogStream::LOG_LEVEL::MINLINES)
<< "PCCompile " << SUBool::kVersionInfo << std::endl;
<< "PCCheck" << SUBool::kVersionInfo << std::endl;
dump_config(
conf, static_cast<unsigned>(SUBool::LogStream::LOG_LEVEL::MINLINES));
SUBool::AmoEncoder::sGlobalKind = conf.amo_encoding;
SUBool::ExOneEncoder::sGlobalKind = conf.exone_encoding;
auto ret = execute(conf, std::move(cnf));
dump_config(*conf, 3);
SUBool::AmoEncoder::sGlobalKind = conf->amo_encoding;
SUBool::ExOneEncoder::sGlobalKind = conf->exone_encoding;
auto ret = execute(*conf, std::move(cnf));
return ret;
}
......@@ -14,8 +14,6 @@
#include <future>
#include <iostream>
#include <cxxopts.hpp>
#include "cardinal.h"
#include "cnfcompress.h"
#include "logstream.h"
......@@ -33,7 +31,9 @@
const std::string SUBool::kPrgName = "pccompile";
const std::string SUBool::kPrgDesc =
"compiling a CNF into a propagation complete or unit refutation complete "
"CNF. Implements an incremental algorithm based on adding empowering "
"CNF.";
const std::string prg_help =
"Implements an incremental algorithm based on adding empowering "
"implicates and a learning algorithm";
enum class GOAL
......@@ -221,6 +221,15 @@ parse_log_enc_opts(
int
parse_arguments(int argc, char *argv[], config_t &conf)
{
SUBool::PrgOptions opts(true);
opts.SetHelpDesc(prg_help);
opts.InputOutput(&conf.input_file, &conf.output_file);
if (!opts.Parse(argc, argv))
{
return 1;
}
return 0;
#if 0
try
{
cxxopts::Options options("pccompile",
......@@ -607,6 +616,7 @@ parse_arguments(int argc, char *argv[], config_t &conf)
return 1;
}
return 0;
#endif
}
int
......@@ -828,7 +838,6 @@ main(int argc, char *argv[])
{
return r;
}
SUBool::logs.mVerbLevel = the_conf.verbosity;
SUBool::CNF cnf;
r = input(the_conf, &cnf);
if (r != 0)
......@@ -844,8 +853,7 @@ main(int argc, char *argv[])
SUBool::logs.TLog(SUBool::LogStream::LOG_LEVEL::MINLINES)
<< "PCCompile " << SUBool::kVersionInfo << std::endl;
dump_config(
the_conf, static_cast<unsigned>(SUBool::LogStream::LOG_LEVEL::MINLINES));
dump_config(the_conf, 3);
SUBool::AmoEncoder::sGlobalKind = the_conf.amo_encoding;
SUBool::ExOneEncoder::sGlobalKind = the_conf.exone_encoding;
auto ret = compile(std::move(cnf));
......
......@@ -149,7 +149,7 @@ namespace SUBool
po::options_description mVisible{};
po::positional_options_description mPositional{};
po::variables_map mVM{};
std::vector<std::shared_ptr<OptionsGroup>> mOptGroups;
std::vector<std::shared_ptr<OptionsGroup>> mOptGroups{};
void Help() const;
void Version() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment