Ignore:
Timestamp:
Mar 3, 2011, 7:28:48 PM (10 years ago)
Author:
tbretz
Message:
Added fEnvMap and a default name mapper.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Configuration.h

    r10183 r10220  
    33
    44#include <boost/program_options.hpp>
    5 /*
    6 \attention
    7 \callgraph
    8 \callergraph
    9 \category
    10 \dot
    11 \remark
    12 \see
    13 \throws
    14 \todo
    15 \warning
    16 
    17 \e  italic
    18 \b  bold
    19 \c  typewriter
    20 
    21 \code
    22 \endcode
    23 
    24 \f$
    25 \f[ \f]
    26 */
    275
    286namespace po = boost::program_options;
     
    3917
    4018    const std::string fName; /// argv[0]
     19
     20    std::map<std::string, std::string> fEnvMap;
    4121
    4222    po::options_description fOptionsCommandline[2]; /// Description of the command-line options
     
    5939
    6040    /// A default mapper for environment variables skipping all of them
    61     static const std::string NameMapper(const std::string &) { return ""; }
     41    std::string DefaultMapper(const std::string env)
     42    {
     43        return fEnvMap[env];
     44    }
    6245
    6346    /// Pointer to the mapper function for environment variables
    64     const std::string (*fNameMapper)(const std::string&);
     47    boost::function1<std::string, std::string> fNameMapper;
    6548
    6649    /// Helper function which return the max of the two arguments in the first argument
     
    8871    void AddOptionsEnvironment(const po::options_description &env, bool visible=true);
    8972    void AddOptionsDatabase(const po::options_description &db, bool visible=true);
     73    void AddOptions(const po::options_description &opt, bool visible=true)
     74    {
     75        AddOptionsCommandline(opt, visible);
     76        AddOptionsConfigfile(opt, visible);
     77        AddOptionsEnvironment(opt, visible);
     78        AddOptionsDatabase(opt, visible);
     79    }
    9080
    9181    void SetArgumentPositions(const po::positional_options_description &desc);
    9282
    93     void SetNameMapper(const std::string (*mapper)(const std::string&));
     83    void SetNameMapper(const boost::function1<std::string, std::string> &func);
     84    void SetNameMapper();
     85
     86    void AddEnv(const std::string &conf, const std::string &env)
     87    {
     88        fEnvMap[env] = conf;
     89    }
    9490
    9591    // Output
Note: See TracChangeset for help on using the changeset viewer.