File optionsreader.hxx#
-
class OptionsReader#
- #include <optionsreader.hxx>
Class to handle reading options from file
Example
Options opt; OptionsReader::getInstance()->read(&opt, “somefile.inp”);
opt now contains a tree of sections and options from the input file “somefile.inp”
Public Functions
-
void read(Options *options, const std::string &filename)#
Read the given file, parse options into the options tree.
- Parameters:
options – [inout] The options section to insert values and subsections into
file – [in] The name of the file. printf style arguments can be used to create the file name.
-
template<class S, class ...Args>
inline void read(Options *options, const S &format, const Args&... args)#
-
void write(Options *options, const std::string &filename)#
Write options to file
- Parameters:
options – [in] The options tree to be written
file – [in] The name of the file to (over)write
-
template<class S, class ...Args>
inline void write(Options *options, const S &format, const Args&... args)#
-
void parseCommandLine(Options *options, int argc, char **argv)#
Parse options from the command line
Example
int main(int argc, char** argv) { Options opt; OptionsReader::getInstance()->read(&opt, argc, argv); … return 0; }
- Parameters:
options – [inout] The options section to insert values and subsections into
argc – [in] The number of command-line arguments
argv – [in] The command line arguments
Public Static Functions
-
static OptionsReader *getInstance()#
Return a pointer to the instance singleton.
-
static inline void cleanup()#
Delete the instance.
Private Static Attributes
-
static OptionsReader *instance = nullptr#
The instance of this singleton.
-
void read(Options *options, const std::string &filename)#