]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/utils/bamtools_options.cpp
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / utils / bamtools_options.cpp
index 71aa2ebd4507fa5ecd7800d66090c11b90f5f67d..565c90e56cdacb1084b6895505947393f788d3e1 100644 (file)
@@ -1,9 +1,8 @@
 // ***************************************************************************
 // 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;
@@ -109,7 +112,8 @@ void Options::DisplayHelp(void) {
                     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);
                 }
 
@@ -230,15 +234,18 @@ void Options::Parse(int argc, char* argv[], int offset) {
                             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;
                 }
             }
@@ -248,7 +255,8 @@ void Options::Parse(int argc, char* argv[], int offset) {
     // 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;
         }
     }
@@ -263,7 +271,10 @@ void Options::Parse(int argc, char* argv[], int offset) {
 }
 
 // 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;