![]() |
Mixed Data Coincidence Analysis Software 1.0
A program to analyze files produced by the EventMixer software.
|
00001 #include "CommandLineInterpreter.hh" 00002 00003 CommandLineInterpreter::CommandLineInterpreter(int argc, char *argv[], list<CommandLineArgument> myAcceptableFlags) 00004 { 00005 for(int i = 0; i<argc; i++) 00006 { 00007 string temp(argv[i]); 00008 if(temp[0]=='-') //we have a flag... 00009 { 00010 temp = temp.substr(1,temp.size()); 00011 bool found = false; 00012 for(list<CommandLineArgument>::iterator it = myAcceptableFlags.begin(); it!=myAcceptableFlags.end(); it++) 00013 { 00014 if(temp.compare(it->flag)==0) 00015 { 00016 if(i+it->numberOfArguments>argc) 00017 throw CommandLineException("Insufficient arguments for flag.\n"); 00018 vector<string> myList; 00019 for(int k = i+1; k<=i+it->numberOfArguments; k++) 00020 { 00021 string tmp(argv[k]); 00022 myList.push_back(tmp); 00023 } 00024 myFlaggedCommands[temp] = myList; 00025 i+=it->numberOfArguments; 00026 found=true; 00027 } 00028 } 00029 if(!found) 00030 throw CommandLineException("Command flag not recognized"); 00031 } 00032 else 00033 { 00034 myFlaglessCommands.push_back(argv[i]); 00035 } 00036 } 00037 } 00038 00039 vector<string> CommandLineInterpreter::readFlaggedCommand(string flag) 00040 { 00041 if(myFlaggedCommands.find(flag)!=myFlaggedCommands.end()) 00042 { 00043 if(myFlaggedCommands[flag].empty()) 00044 myFlaggedCommands[flag].push_back(""); 00045 return myFlaggedCommands[flag]; 00046 } 00047 else 00048 { 00049 return vector<string>(); 00050 } 00051 } 00052 00053 vector<string> CommandLineInterpreter::readFlaglessCommands() 00054 { 00055 return myFlaglessCommands; 00056 }