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;
41 mutable bool set_cmdline;
44 struct option opt,
const char* argname,
const char* desc,
const std::function<
int(
const char* arg)>& callback,
45 bool header,
bool sdl_avail,
bool set_cmdline) :
52 set_cmdline(set_cmdline)
69 #define DEF_FLAG_OPTVAL(longName, shortName, text, func, sdl_avail) \ 70 addOption({ longName, optional_argument, 0, shortName }, "[BOOL]", text, func, false, sdl_avail); 72 #define DEF_FLAG(longName, shortName, text, func) \ 73 addOption({ longName, no_argument, 0, shortName }, "", text, func, false, false); 75 #define DEF_ARG(longName, shortName, argName, text, func, sdl_avail) \ 76 addOption({ longName, required_argument, 0, shortName }, argName, text, func, false, sdl_avail); 78 #define DEF_ARG_OPTVAL(longName, shortName, argName, text, func, sdl_avail) \ 79 addOption({ longName, optional_argument, 0, shortName }, "[" argName "]", text, func, false, sdl_avail); 82 #define DEF_SECTION_HEADING(text) \ 83 addOption({ "", optional_argument, 0, 0 }, "", text, std::function<int(const char* arg)>(), true, false); 102 ConfigBase(
bool suppress_print,
bool suppress_sdl) : suppress_print_(suppress_print), suppress_sdl_(suppress_sdl) {}
112 ConfigBase() : suppress_print_(true), suppress_sdl_(true) { options.reserve(100); }
127 struct option opt,
const char* argname,
const char* desc, std::function<
int(
const char* arg)> callback,
128 bool header,
bool sdl_avail);
137 virtual int checkArgsAfterParsing();
142 void enableDashDashSupport(std::function<
int(
const char* arg)> callback);
146 void addPositionalCallback(std::function<
int(
int num,
const char* arg)> callback);
161 static bool parseBoolean(
const std::string& arg,
bool& success,
const std::string& option);
172 int parseCmdLine(
int argc,
char* argv[],
bool ignore_unknown =
false);
176 std::vector<LongOption> options;
177 std::map<char, int> short_options;
178 std::string short_options_string;
179 size_t longest_option = 0;
180 size_t num_options = 0;
181 std::function<int(const char* arg)> dashdash_callback;
182 std::function<int(int num, const char* arg)> positional_args;
184 std::string run_name_;
185 bool suppress_print_;
191 #endif // SST_CORE_CONFIGBASE_H void addOption(struct option opt, const char *argname, const char *desc, std::function< int(const char *arg)> callback, bool header, bool sdl_avail)
Add options to the Config object.
Definition: configBase.cc:62
Struct that holds all the getopt_long options along with the docuementation for the option...
Definition: configBase.h:33
virtual std::string getUsagePrelude()
Called to get the prelude for the help/usage message.
Definition: configBase.cc:101
ConfigBase(bool suppress_print, bool suppress_sdl)
ConfigBase constructor.
Definition: configBase.h:102
int printUsage()
Called to print the help/usage message.
Definition: configBase.cc:125
int parseCmdLine(int argc, char *argv[], bool ignore_unknown=false)
Parse command-line arguments to update configuration values.
Definition: configBase.cc:213
ConfigBase()
Default constructor used for serialization.
Definition: configBase.h:112
Base class to parse command line options for SST Simulation Configuration variables.
Definition: configBase.h:95
bool setOptionExternal(const std::string &entryName, const std::string &value)
Set a configuration string to update configuration values.
Definition: configBase.cc:346
std::string getRunName()
Get the name of the executable being run.
Definition: configBase.h:153