1#ifndef AMPGEN_NAMEDPARAMETER_H
2#define AMPGEN_NAMEDPARAMETER_H
42 auto line = parser->find(
m_name );
43 if( line == parser->end() )
return false ;
44 const std::vector<std::string>& vsl = line->second;
45 if ( vsl.size() < 2 )
return false;
48 for (
unsigned int i = 1; i < vsl.size(); i++ ) {
51 if ( status ==
false ) {
52 ERROR(
"Failed to parse token: " << vsl[i] <<
" for parameter: " <<
m_name );
70 NamedParameter(
const std::string&
name,
const std::vector<T>& defVec,
const std::string& helpString=
"")
80 if( type ==
"std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >" ) type =
"string";
82 << std::setw(20) <<
"[" + type +
"]" ;
84 if( tokens.size() == 0 ) std::cout << std::endl;
85 for(
size_t i = 0 ; i < tokens.size(); ++i){
87 std::cout << tokens[i];
88 if( def != T() ) std::cout <<
" (default = " << def <<
")";
89 std::cout << std::endl;
91 else std::cout << std::string(48,
' ') << tokens[i] << std::endl;
100 ERROR(
"Parameter name \"" <<
name() <<
"\". Index: " << i <<
" out of range [ " << 0 <<
" , "
102 throw std::runtime_error(
"array index out of bounds" );
121 void setVal(
const std::vector<T>& valList )
141 std::vector<T> return_container;
143 T obj = default_value;
146 if ( obj != T() ) return_container.push_back( obj );
147 }
while ( obj != default_value );
148 return return_container;
151 template <
typename T> std::ostream&
operator<<( std::ostream& os,
const NamedParameter<T>& np );
152 template <
typename ...T> std::string
optionalHelpString(
const std::string& header,
const T&... args);
159 for (
size_t i = 0; i < np.
size(); i++ ) {
160 if( i == 0 ) os <<
" = ";
162 if ( i != np.
size() ) os <<
" ";
169 std::stringstream rt;
171 for_each( std::make_tuple(args...), [&rt](
const auto& f)
mutable {
172 rt <<
"\n\033[3m " << f.first <<
"\033[0m: " << f.second;
A parameter with value specified by the user at runtime, either in an options file or via the command...
void setVal(const std::vector< T > &valList)
const T getVal(int i=0) const
std::vector< T > m_valueArray
< The helper string for this parameter, printed if the flag –help is used.
bool operator==(const G &other) const
bool operator!=(const G &other) const
const std::vector< T > & getVector() const
NamedParameter< T > & operator=(const T &d)
NamedParameter(const std::string &name, const T &def=T(), const std::string &helpString="")
NamedParameter(const std::string &name, const std::vector< T > &defVec, const std::string &helpString="")
bool setFromOptionsParser()
< The value (array) of this parameter.
static std::vector< T > getVectorArgument(const std::string &name, const T &default_value)
const std::string & name() const
NamedParameter< T > & operator=(const std::vector< T > &v)
std::string m_helpString
< Name of this parameter
void setVal(const T &val, int i=0)
static OptionsParser * getMe()
#define ERROR(X)
Used for printing errors messages, and will always be printed.
#define DEBUG(X)
Used for printing verbose debugging messages, only if DEBUGLEVEL is defined.
std::vector< std::string > split(const std::string &, char, bool=true)
std::ostream & operator<<(std::ostream &os, const CompiledExpressionBase &expression)
std::ostream & bold_on(std::ostream &)
std::string optionalHelpString(const std::string &header, const T &... args)
std::ostream & bold_off(std::ostream &)
std::string type_string()
Utility classes for compile-time metaprogramming, such as identifying the types of arguments for gene...
return_type lexical_cast(const std::string &word, bool &status)
std::enable_if_t< I==sizeof...(Tp), void > for_each(std::tuple< Tp... > &, FuncT)