12 #ifndef SST_CORE_CONFIGBASE_H 13 #define SST_CORE_CONFIGBASE_H 15 #include "sst/core/sst_types.h" 25 extern int main(
int argc,
char** argv);
38 std::function<int(const char* arg)> callback;
40 std::vector<bool> annotations;
41 std::function<std::string(void)> ext_help;
42 mutable bool set_cmdline;
45 struct option opt,
const char* argname,
const char* desc,
const std::function<
int(
const char* arg)>& callback,
46 bool header, std::vector<bool> annotations, std::function<std::string(
void)> ext_help,
bool set_cmdline) :
52 annotations(annotations),
54 set_cmdline(set_cmdline)
76 #define DEF_FLAG_OPTVAL(longName, shortName, text, func, ...) \ 77 addOption({ longName, optional_argument, 0, shortName }, "[BOOL]", text, func, { __VA_ARGS__ }); 79 #define DEF_FLAG(longName, shortName, text, func, ...) \ 80 addOption({ longName, no_argument, 0, shortName }, "", text, func, { __VA_ARGS__ }); 82 #define DEF_ARG(longName, shortName, argName, text, func, ...) \ 83 addOption({ longName, required_argument, 0, shortName }, argName, text, func, { __VA_ARGS__ }); 85 #define DEF_ARG_OPTVAL(longName, shortName, argName, text, func, ...) \ 86 addOption({ longName, optional_argument, 0, shortName }, "[" argName "]", text, func, { __VA_ARGS__ }); 89 #define DEF_ARG_EH(longName, shortName, argName, text, func, eh, ...) \ 90 addOption({ longName, required_argument, 0, shortName }, argName, text, func, { __VA_ARGS__ }, eh); 93 #define DEF_SECTION_HEADING(text) addHeading(text); 112 ConfigBase(
bool suppress_print) : suppress_print_(suppress_print) {}
122 ConfigBase() : suppress_print_(true) { options.reserve(100); }
125 ConfigBase(
bool suppress_print, std::vector<AnnotationInfo> annotations) :
126 annotations_(annotations),
127 suppress_print_(suppress_print)
147 struct option opt,
const char* argname,
const char* desc, std::function<
int(
const char* arg)> callback,
148 std::vector<bool> annotations, std::function<std::string(
void)> ext_help = std::function<std::string(
void)>());
162 virtual int checkArgsAfterParsing();
167 void enableDashDashSupport(std::function<
int(
const char* arg)> callback);
171 void addPositionalCallback(std::function<
int(
int num,
const char* arg)> callback);
184 bool getAnnotation(
const std::string& entryName,
char annotation);
189 static bool parseBoolean(
const std::string& arg,
bool& success,
const std::string& option);
200 int parseCmdLine(
int argc,
char* argv[],
bool ignore_unknown =
false);
211 std::vector<LongOption> options;
212 std::map<char, int> short_options;
213 std::string short_options_string;
214 size_t longest_option = 0;
215 size_t num_options = 0;
216 std::function<int(const char* arg)> dashdash_callback;
217 std::function<int(int num, const char* arg)> positional_args;
220 std::map<std::string, std::function<std::string(void)>> extra_help_map;
223 std::vector<AnnotationInfo> annotations_;
225 std::string run_name_;
226 bool suppress_print_;
227 bool has_extended_help_ =
false;
232 #endif // SST_CORE_CONFIGBASE_H void addOption(struct option opt, const char *argname, const char *desc, std::function< int(const char *arg)> callback, std::vector< bool > annotations, std::function< std::string(void)> ext_help=std::function< std::string(void)>())
Add options to the Config object.
Definition: configBase.cc:62
bool wasOptionSetOnCmdLine(const std::string &option)
Check to see if an option was set on the command line.
Definition: configBase.cc:413
void addHeading(const char *desc)
Adds a heading to the usage output.
Definition: configBase.cc:107
Struct that holds all the getopt_long options along with the docuementation for the option...
Definition: configBase.h:33
bool getAnnotation(const std::string &entryName, char annotation)
Get the value of an annotation for an option.
Definition: configBase.cc:423
virtual std::string getUsagePrelude()
Called to get the prelude for the help/usage message.
Definition: configBase.cc:116
Definition: configBase.h:58
int printUsage()
Called to print the help/usage message.
Definition: configBase.cc:141
int parseCmdLine(int argc, char *argv[], bool ignore_unknown=false)
Parse command-line arguments to update configuration values.
Definition: configBase.cc:264
int printExtHelp(const std::string &option)
Called to print the extended help for an option.
Definition: configBase.cc:246
ConfigBase(bool suppress_print)
ConfigBase constructor.
Definition: configBase.h:112
ConfigBase()
Default constructor used for serialization.
Definition: configBase.h:122
Base class to parse command line options for SST Simulation Configuration variables.
Definition: configBase.h:105
bool setOptionExternal(const std::string &entryName, const std::string &value)
Set a configuration string to update configuration values.
Definition: configBase.cc:397
std::string getRunName()
Get the name of the executable being run.
Definition: configBase.h:178