]> git.donarmstrong.com Git - mothur.git/blob - optionparser.cpp
2de1621bcb9a73ac9c17b02384ee6d9b0f3f5d49
[mothur.git] / optionparser.cpp
1 /*
2  *  optionparser.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 6/8/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "optionparser.h"
11
12 /***********************************************************************/
13
14 OptionParser::OptionParser(string option) {
15         try {
16                 
17                 if (option != "") {
18                         
19                         string key, value;              
20                         //reads in parameters and values
21                         while((option.find_first_of(',') != -1)) {  //while there are parameters
22                                 splitAtComma(value, option);
23                                 splitAtEquals(key, value);
24                                 parameters[key] = value;
25                         }
26                         
27                         //in case there is no comma and to get last parameter after comma
28                         splitAtEquals(key, option);
29                         parameters[key] = option;
30                 }
31         }
32         catch(exception& e) {
33                 cout << "Standard Error: " << e.what() << " has occurred in the OptionParser class Function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
34                 exit(1);
35         }
36         catch(...) {
37                 cout << "An unknown error has occurred in the OptionParser class function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
38                 exit(1);
39         }
40 }
41
42 /***********************************************************************/
43
44 map<string, string> OptionParser::getParameters() {     return parameters;      }
45
46 /***********************************************************************/