/******************************************************************************** * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /* * File: ProgOptions.cxx * Author: winckler * * Created on March 11, 2015, 10:20 PM */ #include #include #include #include #include #include #include #include #include #include #include // pair using namespace std; using namespace fair::mq; namespace po = boost::program_options; struct ValInfo { string value; string type; string origin; }; namespace fair::mq { ValInfo ConvertVarValToValInfo(const po::variable_value& v) { string origin; if (v.defaulted()) { origin = "[default]"; } else if (v.empty()) { origin = "[empty]"; } else { origin = "[provided]"; } try { pair info = PropertyHelper::GetPropertyInfo(v.value()); return {info.first, info.second, origin}; } catch (out_of_range& oor) { return {string("[unidentified_type]"), string("[unidentified_type]"), origin}; } } string ConvertVarValToString(const po::variable_value& v) { return ConvertVarValToValInfo(v).value; } ProgOptions::ProgOptions() : fAllOptions("FairMQ Command Line Options") { fAllOptions.add_options() ("help,h", "Print help") ("version,v", "Print version") ("severity", po::value()->default_value(""), "Log severity level (console): trace, debug, info, state, warn, error, fatal, nolog.") ("file-severity", po::value()->default_value("debug"), "Log severity level (file): trace, debug, info, state, warn, error, fatal, nolog") ("verbosity", po::value()->default_value("medium"), "Log verbosity level: veryhigh, high, medium, low") ("color", po::value()->default_value(true), "Log color (true/false)") ("log-to-file", po::value()->default_value(""), "Log output to a file.") ("print-options", po::value()->implicit_value(true), "Print options in machine-readable format (