icedb  version 0.5.1
Snow particle scattering database API
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
icedb::registry::options Class Reference

#include <options.hpp>

Inheritance diagram for icedb::registry::options:
Inheritance graph
[legend]
Collaboration diagram for icedb::registry::options:
Collaboration graph
[legend]

Public Member Functions

virtual ~options ()
 
void enumVals (std::ostream &out) const
 
bool hasVal (const std::string &key) const
 
template<class T >
getVal (const std::string &key) const
 Retrieves an option. Throws if nonexistant. More...
 
template<class T >
getVal (const std::string &key, const T &defaultval) const
 Retrieves an option. Returns defaultval if nonexistant. More...
 
template<class T >
options_ptr setVal (const std::string &key, const T &value)
 Adds or replaces an option. More...
 
template<class T >
options_ptr add (const std::string &key, const T &value)
 Adds an option. Throws if the same name already exists. More...
 
void filename (const std::string &val)
 
std::string filename () const
 
void extension (const std::string &val)
 
std::string extension () const
 
void filetype (const std::string &val)
 
std::string filetype () const
 
void exportType (const std::string &val)
 
std::string exportType () const
 

Static Public Member Functions

static std::shared_ptr< optionsgenerate ()
 

Protected Member Functions

 options ()
 

Protected Attributes

std::shared_ptr< options_innerp
 

Detailed Description

Definition at line 10 of file options.hpp.

Constructor & Destructor Documentation

◆ options()

icedb::registry::options::options ( )
protected

Definition at line 15 of file options.cpp.

15  {
16  p = std::shared_ptr<options_inner>(new options_inner);
17  }
std::shared_ptr< options_inner > p
Definition: options.hpp:14

◆ ~options()

icedb::registry::options::~options ( )
virtual

Definition at line 21 of file options.cpp.

21 {}

Member Function Documentation

◆ add()

template<class T >
options_ptr icedb::registry::options::add ( const std::string &  key,
const T &  value 
)

Adds an option. Throws if the same name already exists.

Definition at line 59 of file options.cpp.

References ICEDB_throw, and icedb::error::xKeyExists.

60  {
62  .add<std::string>("key", key)
63  .add<T>("newValue", value);
64  return this->setVal<T>(key, value);
65  }
bool hasVal(const std::string &key) const
Definition: options.cpp:35
#define ICEDB_throw(x)
Definition: error.hpp:88

◆ enumVals()

void icedb::registry::options::enumVals ( std::ostream &  out) const

Definition at line 22 of file options.cpp.

22  {
23  //out << "\tName\t\tValue" << std::endl;
24  for (const auto &v : p->_mapStr)
25  {
26  if (v.first != "password")
27  {
28  out << "\t" << v.first << ":\t" << v.second << std::endl;
29  }
30  else {
31  out << "\t" << v.first << ":\t" << "********" << std::endl;
32  }
33  }
34  }
std::shared_ptr< options_inner > p
Definition: options.hpp:14

◆ exportType() [1/2]

void icedb::registry::options::exportType ( const std::string &  val)
inline

Definition at line 36 of file options.hpp.

36 { setVal<std::string>("exportType", val); }

◆ exportType() [2/2]

std::string icedb::registry::options::exportType ( ) const
inline

Definition at line 37 of file options.hpp.

37 { return getVal<std::string>("exportType", ""); }

◆ extension() [1/2]

void icedb::registry::options::extension ( const std::string &  val)
inline

Definition at line 32 of file options.hpp.

32 { setVal<std::string>("extension", val); }

◆ extension() [2/2]

std::string icedb::registry::options::extension ( ) const
inline

Definition at line 33 of file options.hpp.

33 { return getVal<std::string>("extension", ""); }

◆ filename() [1/2]

void icedb::registry::options::filename ( const std::string &  val)
inline

Definition at line 30 of file options.hpp.

30 { setVal<std::string>("filename", val); }

◆ filename() [2/2]

std::string icedb::registry::options::filename ( ) const
inline

Definition at line 31 of file options.hpp.

31 { return getVal<std::string>("filename", ""); }

◆ filetype() [1/2]

void icedb::registry::options::filetype ( const std::string &  val)
inline

Definition at line 34 of file options.hpp.

34 { setVal<std::string>("filetype", val); }

◆ filetype() [2/2]

std::string icedb::registry::options::filetype ( ) const
inline

Definition at line 35 of file options.hpp.

35 { return getVal<std::string>("filetype", ""); }

◆ generate()

std::shared_ptr< options > icedb::registry::options::generate ( )
static

Definition at line 18 of file options.cpp.

Referenced by icedb::units::converter::canConvert(), icedb::units::conv_spec::conv_spec(), icedb::units::converter::getConverter(), and icedb::error::xError::push().

18  {
19  auto res = std::shared_ptr<options>(new options); return res;
20  }
Here is the caller graph for this function:

◆ getVal() [1/2]

template<class T >
T icedb::registry::options::getVal ( const std::string &  key) const

Retrieves an option. Throws if nonexistant.

Definition at line 39 of file options.cpp.

40  {
41  if (!hasVal(key)) return boost::lexical_cast<T>(std::string(""));
42  //RDthrow(Ryan_Debug::ICEDB_LOG_ERROR::xMissingKey())
43  // << Ryan_Debug::ICEDB_LOG_ERROR::key(key);
44  std::string valS = p->_mapStr.at(key);
45  T res = boost::lexical_cast<T>(valS);
46  return res;
47  }
bool hasVal(const std::string &key) const
Definition: options.cpp:35
std::shared_ptr< options_inner > p
Definition: options.hpp:14

◆ getVal() [2/2]

template<class T >
T icedb::registry::options::getVal ( const std::string &  key,
const T &  defaultval 
) const

Retrieves an option. Returns defaultval if nonexistant.

Definition at line 48 of file options.cpp.

49  {
50  if (!hasVal(key)) return defaultval;
51  return getVal<T>(key);
52  }
bool hasVal(const std::string &key) const
Definition: options.cpp:35

◆ hasVal()

bool icedb::registry::options::hasVal ( const std::string &  key) const

Definition at line 35 of file options.cpp.

35  {
36  if (p->_mapStr.count(key)) return true;
37  return false;
38  }
std::shared_ptr< options_inner > p
Definition: options.hpp:14

◆ setVal()

template<class T >
options_ptr icedb::registry::options::setVal ( const std::string &  key,
const T &  value 
)

Adds or replaces an option.

Definition at line 53 of file options.cpp.

54  {
55  std::string valS = boost::lexical_cast<std::string>(value);
56  p->_mapStr[key] = valS;
57  return this->shared_from_this();
58  }
std::shared_ptr< options_inner > p
Definition: options.hpp:14

Member Data Documentation

◆ p

std::shared_ptr<options_inner> icedb::registry::options::p
protected

Definition at line 14 of file options.hpp.


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