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 char *file, ...)¶ Read the given file, parse options into the options tree.
- Parameters
options
: The options section to insert values and subsections intofile
: The name of the file. printf style arguments can be used to create the file name.
-
void
write
(Options *options, const char *file, ...)¶ Write options to file
- Parameters
options
: The options tree to be writtenfile
: The name of the file to (over)write
-
void
parseCommandLine
(Options *options, int argc, char **argv)¶ Parse options from the command line
Example
- Parameters
options
: The options section to insert values and subsections intoargc
: The number of command-line argumentsargv
: The command line arguments
int main(int argc, char** argv) { Options opt; OptionsReader::getInstance()->read(&opt, argc, argv); … return 0; }
Public Static Functions
-
OptionsReader *
getInstance
()¶ Return a pointer to the instance singleton.
-
static void
cleanup
()¶ Delete the instance.
Private Static Attributes
-
OptionsReader *
instance
= nullptr¶ The instance of this singleton.
-
void