pelican/core/src/PipelineApplication.cpp
/**
 * @details
 * This method is called by the constructor and parses the command line
 * arguments to create the configuration object.
 */
@details
This method is called by the constructor and parses the command line
arguments to create the configuration object.
@details This method is called by the constructor and parses the command line arguments to create the configuration object .
void PipelineApplication::_createConfig(int argc, char** argv)
{
    if (argc == 0 || argv == NULL)
        throw QString("PipelineApplication: no config file or other options specified.");
    opts::options_description desc("Allowed options");
    desc.add_options()
        ("help", "Produce help message.")
        ("config,c", opts::value<std::string>(), "Set configuration file.")
    ;
    opts::positional_options_description p;
    p.add("config", -1);
    opts::variables_map varMap;
    opts::store(opts::command_line_parser(argc, argv).options(desc)
            .positional(p).run(), varMap);
    opts::notify(varMap);
    if (varMap.count("help")) {
        std::cout << desc << "\n";
        return;
    }
    std::string configFilename = "";
    if (varMap.count("config"))
        configFilename = varMap["config"].as<std::string>();
    if (configFilename.empty()) {
        std::cout << "WARNING: No configuration file supplied." << std::endl;
    }
    try {
        _config = Config(QString::fromStdString(configFilename));
    }
    catch (const QString& error) {
        std::cerr << "ERROR: " << error.toStdString() << std::endl;
    }
}
void PipelineApplication :: _createConfig ( int argc , char * * argv ) { if ( argc == 0 || argv == NULL ) throw QString ( " " ) ; opts :: options_description desc ( " " ) ; desc . add_options ( ) ( " " , " " ) ( " " , opts :: value < std :: string > ( ) , " " ) ; opts :: positional_options_description p ; p . add ( " " , -1 ) ; opts :: variables_map varMap ; opts :: store ( opts :: command_line_parser ( argc , argv ) . options ( desc ) . positional ( p ) . run ( ) , varMap ) ; opts :: notify ( varMap ) ; if ( varMap . count ( " " ) ) { std :: cout << desc << " \n " ; return ; } std :: string configFilename = " " ; if ( varMap . count ( " " ) ) configFilename = varMap [ " " ] . as < std :: string > ( ) ; if ( configFilename . empty ( ) ) { std :: cout << " " << std :: endl ; } try { _config = Config ( QString :: fromStdString ( configFilename ) ) ; } catch ( const QString & error ) { std :: cerr << " " << error . toStdString ( ) << std :: endl ; } }
@details
 This method is called by the constructor and parses the command line
 arguments to create the configuration object.
@details This method is called by the constructor and parses the command line arguments to create the configuration object .
// Check that argc and argv are nonzero // Declare the supported options. // A string without a selection flag in the first argument position is // assumed to be a config file. // Parse the command line arguments. // Check for help message. // Get the configuration file name. // Check if no configuration file is supplied. // Construct the configuration object. // The static object is initialised only once.