]> git.donarmstrong.com Git - mothur.git/blob - optionparser.cpp
7ff6ae7691b0437c1589051778d929307dbe36f1
[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 void OptionParser::parse(string option, map<string, string>& container) {
14         try {
15                 
16                 if (option != "") {
17                 
18                         string key, value;              
19                         //reads in parameters and values
20                         while((option.find_first_of(',') != -1)) {  //while there are parameters
21                                         splitAtComma(value, option);
22                                         splitAtEquals(key, value);
23                                         container[key] = value;
24                         }
25                 
26                         //in case there is no comma and to get last parameter after comma
27                         splitAtEquals(key, option);
28                         container[key] = option;
29                 }
30         }
31         catch(exception& e) {
32                 cout << "Standard Error: " << e.what() << " has occurred in the OptionParser class Function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
33                 exit(1);
34         }
35         catch(...) {
36                 cout << "An unknown error has occurred in the OptionParser class function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
37                 exit(1);
38         }
39 }
40 /***********************************************************************/