Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
Nektar::NekMeshUtils::ConfigOption Struct Reference

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

#include <Module.h>

Collaboration diagram for Nektar::NekMeshUtils::ConfigOption:
Collaboration graph
[legend]

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 83 of file NekMeshUtils/Module/Module.h.

Constructor & Destructor Documentation

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 92 of file NekMeshUtils/Module/Module.h.

92  :
94  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...
Nektar::NekMeshUtils::ConfigOption::ConfigOption ( )
inline

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

95  :
96  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

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 103 of file NekMeshUtils/Module/Module.h.

References value.

104  {
105  try
106  {
107  return boost::lexical_cast<T>(value);
108  }
109  catch(const std::exception &e)
110  {
111  std::cerr << e.what() << std::endl;
112  abort();
113  }
114  }
std::string value
The value of the configuration option.
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 121 of file NekMeshUtils/Module/Module.h.

References value.

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

Member Data Documentation

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 142 of file NekMeshUtils/Module/Module.h.

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

Default value of the configuration option.

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

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

Description of the configuration option.

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

bool Nektar::NekMeshUtils::ConfigOption::isBool

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

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

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