// ***************************************************************************
// bamtools_options.cpp (c) 2010 Derek Barnett, Erik Garrison
// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
// ---------------------------------------------------------------------------
-// Last modified: 7 September 2010
+// Last modified: 10 October 2011
// ---------------------------------------------------------------------------
// Parses command line arguments and creates a help menu
// ---------------------------------------------------------------------------
// * (BamTools namespace, added stdin/stdout) (DB)
// ***************************************************************************
-#include "bamtools_options.h"
+#include "utils/bamtools_options.h"
+using namespace BamTools;
+
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
using namespace std;
-using namespace BamTools;
string Options::m_programName; // the program name
string Options::m_description; // the main description
string Options::m_exampleArguments; // the example arguments
vector<OptionGroup> Options::m_optionGroups; // stores the option groups
map<string, OptionValue> Options::m_optionsMap; // stores the options in a map
-string Options::m_stdin = "stdin"; // string representation of stdin
-string Options::m_stdout = "stdout"; // string representation of stdout
+const string Options::m_stdin = "stdin"; // string representation of stdin
+const string Options::m_stdout = "stdout"; // string representation of stdout
// adds a simple option to the parser
-void Options::AddOption(const string& argument, const string& optionDescription, bool& foundArgument, OptionGroup* group) {
-
+void Options::AddOption(const string& argument,
+ const string& optionDescription,
+ bool& foundArgument,
+ OptionGroup* group)
+{
Option o;
o.Argument = argument;
o.Description = optionDescription;
const std::string stringValue = optionIter->DefaultValue;
sb << stringValue;
} else {
- printf("ERROR: Found an unsupported data type for argument %s when casting the default value.\n", optionIter->Argument.c_str());
+ printf("ERROR: Found an unsupported data type for argument %s when casting the default value.\n",
+ optionIter->Argument.c_str());
exit(1);
}
vector<string>* pVectorValue = (vector<string>*)ovMapIter->second.pValue;
pVectorValue->push_back(val);
} else {
- printf("ERROR: Found an unsupported data type for argument %s when parsing the arguments.\n", argument.c_str());
+ printf("ERROR: Found an unsupported data type for argument %s when parsing the arguments.\n",
+ argument.c_str());
exit(1);
}
} else {
- errorBuilder << ERROR_SPACER << "The argument (" << argument << ") expects a value, but none was found." << endl;
+ errorBuilder << ERROR_SPACER << "The argument (" << argument
+ << ") expects a value, but none was found." << endl;
foundError = true;
}
} else {
- errorBuilder << ERROR_SPACER << "The argument (" << argument << ") expects a value, but none was found." << endl;
+ errorBuilder << ERROR_SPACER << "The argument (" << argument
+ << ") expects a value, but none was found." << endl;
foundError = true;
}
}
// check if we missed any required parameters
for (ovMapIter = m_optionsMap.begin(); ovMapIter != m_optionsMap.end(); ++ovMapIter) {
if (ovMapIter->second.IsRequired && !*ovMapIter->second.pFoundArgument) {
- errorBuilder << ERROR_SPACER << ovMapIter->second.ValueTypeDescription << " was not specified. Please use the " << ovMapIter->first << " parameter." << endl;
+ errorBuilder << ERROR_SPACER << ovMapIter->second.ValueTypeDescription
+ << " was not specified. Please use the " << ovMapIter->first << " parameter." << endl;
foundError = true;
}
}
}
// sets the program info
-void Options::SetProgramInfo(const string& programName, const string& description, const string& arguments) {
+void Options::SetProgramInfo(const string& programName,
+ const string& description,
+ const string& arguments)
+{
m_programName = programName;
m_description = description;
m_exampleArguments = arguments;