Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CommandLineParser.cpp

    r112b09 r7e6b00  
    66 */
    77
    8 #include "Helpers/MemDebug.hpp"
    9 
    108#include <boost/program_options.hpp>
    119#include <fstream>
    1210#include <iostream>
     11#include <map>
    1312
    1413#include "Patterns/Singleton_impl.hpp"
    1514#include "CommandLineParser.hpp"
     15#include "log.hpp"
     16#include "verbose.hpp"
    1617
    1718using namespace std;
     
    4748}
    4849
     50/** Scan the argument list for -a or --arguments and store their order for later use.
     51 * \param &ShortFormToActionMap e.g. gives "help" for "h"
     52 */
     53void CommandLineParser::scanforSequenceOfArguments(map <std::string, std::string> &ShortFormToActionMap)
     54{
     55  // go through all arguments
     56  for (int i=1;i<argc;i++) {
     57    (cout << Verbose(1) << "Checking on " << argv[i] << endl);
     58    // check whether they begin with - or -- and check that next letter is not numeric, if so insert
     59    if (argv[i][0] == '-') {
     60      (cout << Verbose(1) << "Possible argument: " << argv[i] << endl);
     61      if (argv[i][1] == '-') {
     62        (cout << Verbose(1) << "Putting " << argv[i] << " into the sequence." << endl);
     63        SequenceOfActions.push_back(&(argv[i][2]));
     64      } else if (((argv[i][1] < '0') || (argv[i][1] > '9')) && ((argv[i][1] != '.'))) {
     65        map <std::string, std::string>::iterator iter = ShortFormToActionMap.find(&(argv[i][1]));
     66        if (iter != ShortFormToActionMap.end()) {
     67          (cout << Verbose(1) << "Putting " << iter->second << " for " << iter->first << " into the sequence." << endl);
     68          SequenceOfActions.push_back(iter->second);
     69        }
     70      }
     71    }
     72  }
     73}
    4974
    5075
     
    7499 * \param **_argv argument array from main()
    75100 */
    76 void CommandLineParser::Run(int _argc, char **_argv)
     101void CommandLineParser::Run(int _argc, char **_argv, map <std::string, std::string> &ShortFormToActionMap)
    77102{
    78103  setOptions(_argc,_argv);
    79104  Parse();
     105  scanforSequenceOfArguments(ShortFormToActionMap);
    80106}
    81107
Note: See TracChangeset for help on using the changeset viewer.