MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Types | Public Member Functions | List of all members
mfem::OptionsParser Class Reference

#include <optparser.hpp>

Public Types

enum  OptionType {
  INT, DOUBLE, STRING, ENABLE,
  DISABLE, ARRAY, VECTOR
}
 

Public Member Functions

 OptionsParser (int _argc, char *_argv[])
 
void AddOption (bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
 
void AddOption (int *var, const char *short_name, const char *long_name, const char *description, bool required=false)
 
void AddOption (double *var, const char *short_name, const char *long_name, const char *description, bool required=false)
 
void AddOption (const char **var, const char *short_name, const char *long_name, const char *description, bool required=false)
 
void AddOption (Array< int > *var, const char *short_name, const char *long_name, const char *description, bool required=false)
 
void AddOption (Vector *var, const char *short_name, const char *long_name, const char *description, bool required=false)
 
void Parse ()
 
bool Good () const
 
bool Help () const
 
void PrintOptions (std::ostream &out) const
 
void PrintError (std::ostream &out) const
 
void PrintHelp (std::ostream &out) const
 
void PrintUsage (std::ostream &out) const
 

Detailed Description

Class for parsing command-line options.

The class is initialized with argc and argv, and new options are added with the AddOption method. Currently options of type bool, int, double, char*, mfem::Array<int>, and mfem::Vector are supported.

See the MFEM examples for sample use.

Definition at line 31 of file optparser.hpp.

Member Enumeration Documentation

Enumerator
INT 
DOUBLE 
STRING 
ENABLE 
DISABLE 
ARRAY 
VECTOR 

Definition at line 34 of file optparser.hpp.

Constructor & Destructor Documentation

mfem::OptionsParser::OptionsParser ( int  _argc,
char *  _argv[] 
)
inline

Definition at line 71 of file optparser.hpp.

Member Function Documentation

void mfem::OptionsParser::AddOption ( bool *  var,
const char *  enable_short_name,
const char *  enable_long_name,
const char *  disable_short_name,
const char *  disable_long_name,
const char *  description,
bool  required = false 
)
inline

Definition at line 76 of file optparser.hpp.

void mfem::OptionsParser::AddOption ( int *  var,
const char *  short_name,
const char *  long_name,
const char *  description,
bool  required = false 
)
inline

Definition at line 86 of file optparser.hpp.

void mfem::OptionsParser::AddOption ( double *  var,
const char *  short_name,
const char *  long_name,
const char *  description,
bool  required = false 
)
inline

Definition at line 92 of file optparser.hpp.

void mfem::OptionsParser::AddOption ( const char **  var,
const char *  short_name,
const char *  long_name,
const char *  description,
bool  required = false 
)
inline

Definition at line 98 of file optparser.hpp.

void mfem::OptionsParser::AddOption ( Array< int > *  var,
const char *  short_name,
const char *  long_name,
const char *  description,
bool  required = false 
)
inline

Definition at line 105 of file optparser.hpp.

void mfem::OptionsParser::AddOption ( Vector var,
const char *  short_name,
const char *  long_name,
const char *  description,
bool  required = false 
)
inline

Definition at line 112 of file optparser.hpp.

bool mfem::OptionsParser::Good ( ) const
inline

Definition at line 125 of file optparser.hpp.

bool mfem::OptionsParser::Help ( ) const
inline

Definition at line 126 of file optparser.hpp.

void mfem::OptionsParser::Parse ( )

Parse the command-line options. Note that this function expects all the options provided through the command line to have a corresponding AddOption. In particular, this function cannot be used for partial parsing.

Definition at line 150 of file optparser.cpp.

void mfem::OptionsParser::PrintError ( std::ostream &  out) const

Definition at line 335 of file optparser.cpp.

void mfem::OptionsParser::PrintHelp ( std::ostream &  out) const

Definition at line 378 of file optparser.cpp.

void mfem::OptionsParser::PrintOptions ( std::ostream &  out) const

Definition at line 304 of file optparser.cpp.

void mfem::OptionsParser::PrintUsage ( std::ostream &  out) const

Definition at line 434 of file optparser.cpp.


The documentation for this class was generated from the following files: