X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=optionparser.cpp;fp=optionparser.cpp;h=7ff6ae7691b0437c1589051778d929307dbe36f1;hb=0470f6d037aacb3563c3f7010708120a4a67d4e6;hp=0000000000000000000000000000000000000000;hpb=bede5752eaeedb5a7e339439b6ba2f6670bca2b9;p=mothur.git diff --git a/optionparser.cpp b/optionparser.cpp new file mode 100644 index 0000000..7ff6ae7 --- /dev/null +++ b/optionparser.cpp @@ -0,0 +1,40 @@ +/* + * optionparser.cpp + * Mothur + * + * Created by Sarah Westcott on 6/8/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "optionparser.h" + +/***********************************************************************/ +void OptionParser::parse(string option, map& container) { + try { + + if (option != "") { + + string key, value; + //reads in parameters and values + while((option.find_first_of(',') != -1)) { //while there are parameters + splitAtComma(value, option); + splitAtEquals(key, value); + container[key] = value; + } + + //in case there is no comma and to get last parameter after comma + splitAtEquals(key, option); + container[key] = option; + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the OptionParser class Function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the OptionParser class function parse. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/***********************************************************************/ \ No newline at end of file