Loading...
Searching...
No Matches
commandlineParser.h
Go to the documentation of this file.
#ifndef BALL_FORMAT_COMMANDLINEPARSER_H
#define BALL_FORMAT_COMMANDLINEPARSER_H
#include <BALL/DATATYPE/options.h>
#include <BALL/DATATYPE/string.h>
#include <BALL/FORMAT/paramFile.h>
#include <map>
#include <set>
namespace BALL
{
class BALL_EXPORT CommandlineParser
{
public:
CommandlineParser(String tool_name, String tool_description, String tool_version, String build_date, String category="");
void setToolManual(const String& manual);
static const String NOT_FOUND;
static const list<String> EMTPY_LIST;
void registerMandatoryIntegerParameter(const String& name, const String& description);
void registerMandatoryIntegerListParameter(const String& name, const String& description);
void registerMandatoryDoubleParameter(const String& name, const String& description);
void registerMandatoryDoubleListParameter(const String& name, const String& description);
void registerMandatoryStringParameter(const String& name, const String& description);
void registerMandatoryStringListParameter(const String& name, const String& description);
void registerMandatoryInputFile(const String& name, const String& description);
void registerMandatoryOutputFile(const String& name, const String& description);
void registerMandatoryInputFileList(const String& name, const String& description);
void registerMandatoryOutputFileList(const String& name, const String& description);
void registerMandatoryGalaxyOutputFolder(const String& name, const String& description);
void registerMandatoryGalaxyOutputId(const String& name, const String& description);
void registerOptionalIntegerParameter(const String& name, const String& description, int default_value = 0);
void registerOptionalIntegerListParameter(const String& name, const String& description, const std::vector<int>& default_values = vector<int>());
void registerOptionalDoubleParameter(const String& name, const String& description, double default_value = 0.0);
void registerOptionalDoubleListParameter(const String& name, const String& description, const std::vector<double>& default_values = vector<double>());
void registerOptionalStringParameter(const String& name, const String& description, const String& default_value = "");
void registerOptionalStringListParameter(const String& name, const String& description, const std::vector<String>& default_values = vector<String>());
void registerOptionalInputFile(const String& name, const String& description, const String& default_value = "");
void registerOptionalOutputFile(const String& name, const String& description, const String& default_value = "");
void registerOptionalInputFileList(const String& name, const String& description, const std::vector<String>& default_values = vector<String>());
void registerOptionalOutputFileList(const String& name, const String& description, const std::vector<String>& default_values = vector<String>());
void registerOptionalGalaxyOutputFolder(const String& name, const String& description, const String& default_value = "");
void registerOptionalGalaxyOutputId(const String& name, const String& description, const String& default_value = "");
void registerFlag(String name, String description, bool default_gui_value = false, bool hidden = false);
void registerAdvancedParameters(Options& options);
// exclude parameter from showing in help mode e.g. galaxy specific multi-output parameter
void setParameterAsAdvanced(String name);
void setParameterAsHidden(String name);
void setParameterRestrictions(String category, String par_name, double min_value, double max_value);
void setParameterRestrictions(String par_name, double min_value, double max_value);
void setParameterRestrictions(String category, String par_name, int min_value, int max_value);
void setParameterRestrictions(String par_name, int min_value, int max_value);
void setParameterRestrictions(String category, String par_name, list<String>& allowed_values);
void setParameterRestrictions(String par_name, list<String>& allowed_values);
void setSupportedFormats(String category, String par_name, String supported_formats);
void setSupportedFormats(String par_name, String supported_formats);
void parse(int argc, char* argv[]);
void copyAdvancedParametersToOptions(Options& options);
const String& get(String name);
bool has(String name);
const list<String>& getList(String name);
void printHelp(const std::set<String>& parameter_names = std::set<String>(), bool show_manual = true);
void printToolInfo();
const String& getStartTime();
const String& getStartCommand();
private:
void assertParamterTypeIsNotNumeric(ParamFile::ParameterType type);
void replaceEscapedCharacters_(String& parameter_value);
void checkAndRegisterParameter(String name, String description, ParamFile::ParameterType type, bool mandatory = false, String default_value = "", bool perform_check = true);
void checkAndRegisterFlag(String name, String description, bool default_gui_value = false, bool perform_check = true, bool hidden=false);
void validateRegisteredFilesHaveFormats();
void checkParameterName(const String& name, const bool perform_check = true);
std::set<String> reserved_params_;
std::list<std::pair<String, String> > escaped_chars_;
std::map<String, list<String> > parameter_map_;
std::map<String, ParamFile::ParameterDescription> registered_parameters_;
std::map<String, ParamFile::ParameterDescription> registered_flags_;
typedef std::map<String, ParamFile::ParameterDescription>::iterator MapIterator;
std::list<MapIterator> original_parameter_order_;
std::list<MapIterator> original_flag_order_;
Size max_parname_length_;
Size max_flagname_length_;
String tool_name_;
String tool_description_;
String tool_version_;
String build_date_;
String hostname_;
String start_time_;
String tool_manual_;
String start_command_;
String tool_category_;
};
}
#endif // BALL_FORMAT_COMMANDLINEPARSER_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::CommandlineParser::has
bool has(String name)
BALL::CommandlineParser::registerMandatoryOutputFileList
void registerMandatoryOutputFileList(const String &name, const String &description)
BALL::CommandlineParser::setParameterRestrictions
void setParameterRestrictions(String category, String par_name, int min_value, int max_value)
BALL::CommandlineParser::CommandlineParser
CommandlineParser(String tool_name, String tool_description, String tool_version, String build_date, String category="")
BALL::CommandlineParser::registerMandatoryGalaxyOutputFolder
void registerMandatoryGalaxyOutputFolder(const String &name, const String &description)
BALL::CommandlineParser::setParameterRestrictions
void setParameterRestrictions(String category, String par_name, list< String > &allowed_values)
BALL::CommandlineParser::getStartTime
const String & getStartTime()
BALL::CommandlineParser::registerOptionalIntegerListParameter
void registerOptionalIntegerListParameter(const String &name, const String &description, const std::vector< int > &default_values=vector< int >())
BALL::CommandlineParser::setParameterRestrictions
void setParameterRestrictions(String par_name, list< String > &allowed_values)
BALL::CommandlineParser::registerFlag
void registerFlag(String name, String description, bool default_gui_value=false, bool hidden=false)
BALL::CommandlineParser::registerOptionalStringParameter
void registerOptionalStringParameter(const String &name, const String &description, const String &default_value="")
BALL::CommandlineParser::registerMandatoryDoubleParameter
void registerMandatoryDoubleParameter(const String &name, const String &description)
BALL::CommandlineParser::setParameterAsHidden
void setParameterAsHidden(String name)
BALL::CommandlineParser::registerOptionalInputFileList
void registerOptionalInputFileList(const String &name, const String &description, const std::vector< String > &default_values=vector< String >())
BALL::CommandlineParser::getStartCommand
const String & getStartCommand()
BALL::CommandlineParser::setToolManual
void setToolManual(const String &manual)
BALL::CommandlineParser::registerMandatoryGalaxyOutputId
void registerMandatoryGalaxyOutputId(const String &name, const String &description)
BALL::CommandlineParser::registerMandatoryInputFile
void registerMandatoryInputFile(const String &name, const String &description)
BALL::CommandlineParser::setSupportedFormats
void setSupportedFormats(String category, String par_name, String supported_formats)
BALL::CommandlineParser::setParameterAsAdvanced
void setParameterAsAdvanced(String name)
BALL::CommandlineParser::registerMandatoryIntegerParameter
void registerMandatoryIntegerParameter(const String &name, const String &description)
BALL::CommandlineParser::registerOptionalDoubleListParameter
void registerOptionalDoubleListParameter(const String &name, const String &description, const std::vector< double > &default_values=vector< double >())
BALL::CommandlineParser::registerMandatoryStringParameter
void registerMandatoryStringParameter(const String &name, const String &description)
BALL::CommandlineParser::setSupportedFormats
void setSupportedFormats(String par_name, String supported_formats)
BALL::CommandlineParser::NOT_FOUND
static const String NOT_FOUND
Definition commandlineParser.h:46
BALL::CommandlineParser::registerOptionalGalaxyOutputId
void registerOptionalGalaxyOutputId(const String &name, const String &description, const String &default_value="")
BALL::CommandlineParser::registerOptionalGalaxyOutputFolder
void registerOptionalGalaxyOutputFolder(const String &name, const String &description, const String &default_value="")
BALL::CommandlineParser::copyAdvancedParametersToOptions
void copyAdvancedParametersToOptions(Options &options)
BALL::CommandlineParser::registerOptionalOutputFileList
void registerOptionalOutputFileList(const String &name, const String &description, const std::vector< String > &default_values=vector< String >())
BALL::CommandlineParser::get
const String & get(String name)
BALL::CommandlineParser::registerMandatoryOutputFile
void registerMandatoryOutputFile(const String &name, const String &description)
BALL::CommandlineParser::registerMandatoryStringListParameter
void registerMandatoryStringListParameter(const String &name, const String &description)
BALL::CommandlineParser::EMTPY_LIST
static const list< String > EMTPY_LIST
Definition commandlineParser.h:47
BALL::CommandlineParser::registerOptionalStringListParameter
void registerOptionalStringListParameter(const String &name, const String &description, const std::vector< String > &default_values=vector< String >())
BALL::CommandlineParser::registerMandatoryIntegerListParameter
void registerMandatoryIntegerListParameter(const String &name, const String &description)
BALL::CommandlineParser::getList
const list< String > & getList(String name)
BALL::CommandlineParser::setParameterRestrictions
void setParameterRestrictions(String par_name, double min_value, double max_value)
BALL::CommandlineParser::registerOptionalOutputFile
void registerOptionalOutputFile(const String &name, const String &description, const String &default_value="")
BALL::CommandlineParser::registerOptionalInputFile
void registerOptionalInputFile(const String &name, const String &description, const String &default_value="")
BALL::CommandlineParser::registerMandatoryDoubleListParameter
void registerMandatoryDoubleListParameter(const String &name, const String &description)
BALL::CommandlineParser::registerOptionalIntegerParameter
void registerOptionalIntegerParameter(const String &name, const String &description, int default_value=0)
BALL::CommandlineParser::setParameterRestrictions
void setParameterRestrictions(String par_name, int min_value, int max_value)
BALL::CommandlineParser::registerOptionalDoubleParameter
void registerOptionalDoubleParameter(const String &name, const String &description, double default_value=0.0)
BALL::CommandlineParser::printHelp
void printHelp(const std::set< String > &parameter_names=std::set< String >(), bool show_manual=true)
BALL::CommandlineParser::registerMandatoryInputFileList
void registerMandatoryInputFileList(const String &name, const String &description)
BALL::CommandlineParser::setParameterRestrictions
void setParameterRestrictions(String category, String par_name, double min_value, double max_value)
BALL::CommandlineParser::parse
void parse(int argc, char *argv[])
BALL::CommandlineParser::registerAdvancedParameters
void registerAdvancedParameters(Options &options)
BALL::CommandlineParser::printToolInfo
void printToolInfo()
BALL::Options
Definition options.h:48
BALL::ParamFile::ParameterType
ParameterType
Definition paramFile.h:28
BALL::String
Definition string.h:57
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
options.h
paramFile.h
string.h