Nektar++
Public Member Functions | Public Attributes | List of all members
Nektar::NekMeshUtils::ConfigOption Struct Reference

Represents a command-line configuration option. More...

#include <Module.h>

Public Member Functions

 ConfigOption (bool isBool, std::string defValue, std::string desc)
 Construct a new configuration option. More...
 
 ConfigOption ()
 
template<typename T >
as ()
 Re-interpret the value stored in value as some type using boost::lexical_cast. More...
 
template<typename T >
bool isType ()
 Interpret the value stored in value as some type using boost::lexical_cast and return true of false depending on cast. More...
 

Public Attributes

bool isBool
 True if the configuration option is a boolean (thus does not need additional arguments). More...
 
bool beenSet
 True if the configuration option has been set at command line. If false, the default value will be put into value. More...
 
std::string value
 The value of the configuration option. More...
 
std::string defValue
 Default value of the configuration option. More...
 
std::string desc
 Description of the configuration option. More...
 

Detailed Description

Represents a command-line configuration option.

Definition at line 82 of file NekMeshUtils/Module/Module.h.

Constructor & Destructor Documentation

◆ ConfigOption() [1/2]

Nektar::NekMeshUtils::ConfigOption::ConfigOption ( bool  isBool,
std::string  defValue,
std::string  desc 
)
inline

Construct a new configuration option.

Parameters
isBoolTrue if the option is boolean type.
defValueDefault value of the option.
descDescription of the option.

Definition at line 91 of file NekMeshUtils/Module/Module.h.

91  :
93  desc(desc) {}
bool isBool
True if the configuration option is a boolean (thus does not need additional arguments).
std::string value
The value of the configuration option.
std::string defValue
Default value of the configuration option.
std::string desc
Description of the configuration option.
bool beenSet
True if the configuration option has been set at command line. If false, the default value will be pu...

◆ ConfigOption() [2/2]

Nektar::NekMeshUtils::ConfigOption::ConfigOption ( )
inline

Definition at line 94 of file NekMeshUtils/Module/Module.h.

94  :
95  isBool(false), beenSet(false), value(), defValue(), desc() {}
bool isBool
True if the configuration option is a boolean (thus does not need additional arguments).
std::string value
The value of the configuration option.
std::string defValue
Default value of the configuration option.
std::string desc
Description of the configuration option.
bool beenSet
True if the configuration option has been set at command line. If false, the default value will be pu...

Member Function Documentation

◆ as()

template<typename T >
T Nektar::NekMeshUtils::ConfigOption::as ( )
inline

Re-interpret the value stored in value as some type using boost::lexical_cast.

Definition at line 102 of file NekMeshUtils/Module/Module.h.

References value.

103  {
104  try
105  {
106  return boost::lexical_cast<T>(value);
107  }
108  catch(const std::exception &e)
109  {
110  std::cerr << e.what() << std::endl;
111  abort();
112  }
113  }
std::string value
The value of the configuration option.

◆ isType()

template<typename T >
bool Nektar::NekMeshUtils::ConfigOption::isType ( )
inline

Interpret the value stored in value as some type using boost::lexical_cast and return true of false depending on cast.

Definition at line 120 of file NekMeshUtils/Module/Module.h.

References value.

121  {
122  bool returnval = true;
123  try
124  {
125  boost::lexical_cast<T>(value);
126  }
127  catch(const std::exception &e)
128  {
129  returnval = false;
130  }
131 
132  return returnval;
133  }
std::string value
The value of the configuration option.

Member Data Documentation

◆ beenSet

bool Nektar::NekMeshUtils::ConfigOption::beenSet

True if the configuration option has been set at command line. If false, the default value will be put into value.

Definition at line 141 of file NekMeshUtils/Module/Module.h.

◆ defValue

std::string Nektar::NekMeshUtils::ConfigOption::defValue

Default value of the configuration option.

Definition at line 145 of file NekMeshUtils/Module/Module.h.

◆ desc

std::string Nektar::NekMeshUtils::ConfigOption::desc

Description of the configuration option.

Definition at line 147 of file NekMeshUtils/Module/Module.h.

◆ isBool

bool Nektar::NekMeshUtils::ConfigOption::isBool

True if the configuration option is a boolean (thus does not need additional arguments).

Definition at line 138 of file NekMeshUtils/Module/Module.h.

◆ value

std::string Nektar::NekMeshUtils::ConfigOption::value