]> git.donarmstrong.com Git - mothur.git/blob - commandoptionparser.cpp
1.18.1
[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 #include "commandoptionparser.hpp"
12
13
14 //**********************************************************************************************************************
15 //This Function parses through the command line and pulls out the command then sends the options to  the parseGlobalData
16 CommandOptionParser::CommandOptionParser(string input){
17         try {
18                 m = MothurOut::getInstance();
19                 
20                 int openParen = input.find_first_of('(');
21                 int closeParen = input.find_last_of(')');
22                 optionString = "";
23                 commandString = "";
24
25                 if(openParen != -1 && closeParen != -1){                        
26                         commandString = input.substr(0, openParen);   //commandString contains everything before "("
27                         optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")".
28                 }
29                 else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); }
30                 else if (closeParen == -1) { m->mothurOut("[ERROR]:You are missing )"); m->mothurOutEndLine(); }
31                                         
32                 //GlobalData* globaldata = GlobalData::getInstance();
33                 //globaldata->parseGlobalData(commandString, optionString);                     //parser to separate and check options
34         }
35         catch(exception& e) {
36                 m->errorOut(e, "CommandOptionParser", "CommandOptionParser");
37                 exit(1);
38         }
39 }
40
41 //**********************************************************************************************************************
42
43 string CommandOptionParser::getCommandString()  {       return commandString;   }
44
45 //**********************************************************************************************************************
46
47 string CommandOptionParser::getOptionString()   {       return optionString;    }
48
49 //**********************************************************************************************************************