]> git.donarmstrong.com Git - mothur.git/blob - commandoptionparser.cpp
added mothur.h and fixed includes in many files
[mothur.git] / commandoptionparser.cpp
1 /*
2  *  commandoptionparser.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 10/23/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
10
11 using namespace std;
12
13 #include "globaldata.hpp"
14 #include "commandoptionparser.hpp"
15 #include "mothur.h"
16
17 //**********************************************************************************************************************
18 //This Function parses through the command line and pulls out the command then sends the options to  the parseGlobalData
19 CommandOptionParser::CommandOptionParser(string input){
20         try {
21                 int openParen = input.find_first_of('(');
22                 int closeParen = input.find_last_of(')');
23                 string optionString = "";
24                 commandString = "";
25         
26                 if(openParen != -1 && closeParen != -1){                        
27                         commandString = input.substr(0, openParen);   //commandString contains everything before "("
28                         optionString = input.substr(openParen+1, closeParen-openParen-1); //optionString contains everything between "(" and ")".
29                 }
30                                         
31                 GlobalData* globaldata = GlobalData::getInstance();
32                 globaldata->parseGlobalData(commandString, optionString);                       //parser to separate and check options
33         }
34         catch(exception& e) {
35                 cout << "Standard Error: " << e.what() << " has occurred in the CommandOptionParser class Function CommandOptionParser. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
36                 exit(1);
37         }
38         catch(...) {
39                 cout << "An unknown error has occurred in the CommandOptionParser class function CommandOptionParser. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
40                 exit(1);
41         }
42
43 }
44
45 //**********************************************************************************************************************
46
47 string CommandOptionParser::getCommandString()  {       return commandString;   }
48
49 //**********************************************************************************************************************