ProteoWizard
Functions
pwiz::util::env Namespace Reference

Functions

template<typename T >
get (const char *name, const T &defaultValue)
 
template<typename T >
get (const std::string &name, const T &defaultValue)
 
std::string get (const std::string &name)
 explicit single-argument overload More...
 

Function Documentation

§ get() [1/3]

template<typename T >
T pwiz::util::env::get ( const char *  name,
const T &  defaultValue 
)

Definition at line 34 of file Environment.hpp.

References boost::lexical_cast(), and pwiz::msdata::id::value().

35 {
36  if (!name)
37  throw std::runtime_error("[env::get()] null variable name");
38 
39  T value(defaultValue);
40  char* result = ::getenv(name);
41  if (result)
42  value = boost::lexical_cast<T>(result);
43  return value;
44 }
float lexical_cast(const std::string &str)
PWIZ_API_DECL std::string value(const std::string &id, const std::string &name)
convenience function to extract a named value from an id string

§ get() [2/3]

template<typename T >
T pwiz::util::env::get ( const std::string &  name,
const T &  defaultValue 
)

Definition at line 48 of file Environment.hpp.

49 {
50  if (name.empty())
51  throw std::runtime_error("[env::get()] empty variable name");
52 
53  return get(name.c_str(), defaultValue);
54 }

§ get() [3/3]

std::string pwiz::util::env::get ( const std::string &  name)
inline

explicit single-argument overload

Definition at line 58 of file Environment.hpp.

58 {return get<std::string>(name, std::string());}