OpenMS
2.7.0
|
Class to hold strings, numeric values, vectors of strings and vectors of numeric values using the stl types. More...
#include <OpenMS/DATASTRUCTURES/ParamValue.h>
Public Types | |
enum | ValueType : unsigned char { STRING_VALUE , INT_VALUE , DOUBLE_VALUE , STRING_LIST , INT_LIST , DOUBLE_LIST , EMPTY_VALUE } |
Supported types for ParamValue. More... | |
Public Member Functions | |
Constructors and destructors | |
ParamValue () | |
Default constructor. More... | |
ParamValue (const ParamValue &) | |
Copy constructor. More... | |
ParamValue (ParamValue &&) noexcept | |
Move constructor. More... | |
ParamValue (const char *) | |
specific constructor for char* (converted to string) More... | |
ParamValue (const std::string &) | |
specific constructor for std::string values More... | |
ParamValue (const std::vector< std::string > &) | |
specific constructor for string vectors More... | |
ParamValue (const std::vector< int > &) | |
specific constructor for integer vectors More... | |
ParamValue (const std::vector< double > &) | |
specific constructor for double vectors More... | |
ParamValue (long double) | |
specific constructor for long double values (note: the implementation uses double) More... | |
ParamValue (double) | |
specific constructor for double values (note: the implementation uses double) More... | |
ParamValue (float) | |
specific constructor for float values (note: the implementation uses double) More... | |
ParamValue (short int) | |
specific constructor for short int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (unsigned short int) | |
specific constructor for unsigned short int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (int) | |
specific constructor for int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (unsigned) | |
specific constructor for unsigned int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (long int) | |
specific constructor for long int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (unsigned long) | |
specific constructor for unsigned long int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (long long) | |
specific constructor for long long int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue (unsigned long long) | |
specific constructor for unsigned long long int values (note: the implementation uses ptrdiff_t) More... | |
~ParamValue () | |
Destructor. More... | |
Cast operators | |
These methods are used when the DataType is known. If they are applied to a ParamValue with the wrong DataType, an exception (Exception::ConversionError) is thrown. In particular, none of these operators will work for an empty ParamValue (DataType EMPTY_VALUE) - except toChar(), which will return 0. | |
operator std::string () const | |
conversion operator to string More... | |
operator std::vector< std::string > () const | |
conversion operator to string vector More... | |
operator std::vector< int > () const | |
conversion operator to integer vector More... | |
operator std::vector< double > () const | |
conversion operator to double vector More... | |
operator long double () const | |
conversion operator to long double More... | |
operator double () const | |
conversion operator to double More... | |
operator float () const | |
conversion operator to float More... | |
operator short int () const | |
conversion operator to short int More... | |
operator unsigned short int () const | |
conversion operator to unsigned short int More... | |
operator int () const | |
conversion operator to int More... | |
operator unsigned int () const | |
conversion operator to unsigned int More... | |
operator long int () const | |
conversion operator to long int More... | |
operator unsigned long int () const | |
conversion operator to unsigned long int More... | |
operator long long () const | |
conversion operator to long long More... | |
operator unsigned long long () const | |
conversion operator to unsigned long long More... | |
bool | toBool () const |
Conversion to bool. More... | |
const char * | toChar () const |
Convert ParamValues to char*. More... | |
std::string | toString (bool full_precision=true) const |
Convert ParamValue to string. More... | |
std::vector< std::string > | toStringVector () const |
Explicitly convert ParamValue to string vector. More... | |
std::vector< int > | toIntVector () const |
Explicitly convert ParamValue to IntList. More... | |
std::vector< double > | toDoubleVector () const |
Explicitly convert ParamValue to DoubleList. More... | |
Static Public Attributes | |
static const ParamValue | EMPTY |
Empty data value for comparisons. More... | |
Assignment operators | |
These methods are used to assign supported types directly to a ParamValue object. | |
ValueType | value_type_ |
Type of the currently stored value. More... | |
union { | |
ptrdiff_t | ssize_ |
double | dou_ |
std::string * | str_ |
std::vector< std::string > * | str_list_ |
std::vector< int > * | int_list_ |
std::vector< double > * | dou_list_ |
} | data_ |
Space to store the data. More... | |
ParamValue & | operator= (const ParamValue &) |
Assignment operator. More... | |
ParamValue & | operator= (ParamValue &&) noexcept |
Move assignment operator. More... | |
ParamValue & | operator= (const char *) |
specific assignment for char* (converted to string) More... | |
ParamValue & | operator= (const std::string &) |
specific assignment for std::string values More... | |
ParamValue & | operator= (const std::vector< std::string > &) |
specific assignment for string vectors More... | |
ParamValue & | operator= (const std::vector< int > &) |
specific assignment for integer vectors More... | |
ParamValue & | operator= (const std::vector< double > &) |
specific assignment for double vectors More... | |
ParamValue & | operator= (const long double) |
specific assignment for long double values (note: the implementation uses double) More... | |
ParamValue & | operator= (const double) |
specific assignment for double values (note: the implementation uses double) More... | |
ParamValue & | operator= (const float) |
specific assignment for float values (note: the implementation uses double) More... | |
ParamValue & | operator= (const short int) |
specific assignment for short int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const unsigned short int) |
specific assignment for unsigned short int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const int) |
specific assignment for int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const unsigned) |
specific assignment for unsigned int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const long int) |
specific assignment for long int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const unsigned long) |
specific assignment for unsigned long int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const long long) |
specific assignment for long long int values (note: the implementation uses ptrdiff_t) More... | |
ParamValue & | operator= (const unsigned long long) |
specific assignment for unsigned long long int values (note: the implementation uses ptrdiff_t) More... | |
ValueType | valueType () const |
returns the type of value stored More... | |
bool | isEmpty () const |
Test if the value is empty. More... | |
std::ostream & | operator<< (std::ostream &, const ParamValue &) |
output stream operator More... | |
bool | operator== (const ParamValue &, const ParamValue &) |
Equality comparator. More... | |
bool | operator< (const ParamValue &, const ParamValue &) |
Smaller than comparator (for vectors we use the size) More... | |
bool | operator> (const ParamValue &, const ParamValue &) |
Greater than comparator (for vectors we use the size) More... | |
bool | operator!= (const ParamValue &, const ParamValue &) |
Equality comparator. More... | |
void | clear_ () noexcept |
Clears the current state of the ParamValue and release every used memory. More... | |
static std::string | doubleToString (double value, bool full_precision=true) |
Class to hold strings, numeric values, vectors of strings and vectors of numeric values using the stl types.
enum ValueType : unsigned char |
Supported types for ParamValue.
Enumerator | |
---|---|
STRING_VALUE | string value |
INT_VALUE | integer value |
DOUBLE_VALUE | double value |
STRING_LIST | string vector |
INT_LIST | integer vector |
DOUBLE_LIST | double vector |
EMPTY_VALUE | empty value |
ParamValue | ( | ) |
Default constructor.
ParamValue | ( | const ParamValue & | ) |
Copy constructor.
|
noexcept |
Move constructor.
ParamValue | ( | const char * | ) |
specific constructor for char* (converted to string)
ParamValue | ( | const std::string & | ) |
specific constructor for std::string values
ParamValue | ( | const std::vector< std::string > & | ) |
specific constructor for string vectors
ParamValue | ( | const std::vector< int > & | ) |
specific constructor for integer vectors
ParamValue | ( | const std::vector< double > & | ) |
specific constructor for double vectors
ParamValue | ( | long double | ) |
specific constructor for long double values (note: the implementation uses double)
ParamValue | ( | double | ) |
specific constructor for double values (note: the implementation uses double)
ParamValue | ( | float | ) |
specific constructor for float values (note: the implementation uses double)
ParamValue | ( | short int | ) |
specific constructor for short int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | unsigned short int | ) |
specific constructor for unsigned short int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | int | ) |
specific constructor for int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | unsigned | ) |
specific constructor for unsigned int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | long int | ) |
specific constructor for long int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | unsigned long | ) |
specific constructor for unsigned long int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | long long | ) |
specific constructor for long long int values (note: the implementation uses ptrdiff_t)
ParamValue | ( | unsigned long long | ) |
specific constructor for unsigned long long int values (note: the implementation uses ptrdiff_t)
~ParamValue | ( | ) |
Destructor.
|
privatenoexcept |
Clears the current state of the ParamValue and release every used memory.
|
staticprivate |
Convert a double to std::string with full precision 15 decimal places are given, otherwise 3 numbers above 10000 or below 0.0001 are given in scientific notation (i.e. 1.0e04)
|
inline |
Test if the value is empty.
operator double | ( | ) | const |
conversion operator to double
Note: The implementation uses typedef double (as opposed to float, double, long double.)
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator float | ( | ) | const |
conversion operator to float
Note: The implementation uses typedef double (as opposed to float, double, long double.)
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator int | ( | ) | const |
conversion operator to int
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator long double | ( | ) | const |
conversion operator to long double
Note: The implementation uses typedef double (as opposed to float, double, long double.)
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator long int | ( | ) | const |
conversion operator to long int
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator long long | ( | ) | const |
conversion operator to long long
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator short int | ( | ) | const |
conversion operator to short int
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator std::string | ( | ) | const |
conversion operator to string
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator std::vector< double > | ( | ) | const |
conversion operator to double vector
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator std::vector< int > | ( | ) | const |
conversion operator to integer vector
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator std::vector< std::string > | ( | ) | const |
conversion operator to string vector
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator unsigned int | ( | ) | const |
conversion operator to unsigned int
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator unsigned long int | ( | ) | const |
conversion operator to unsigned long int
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator unsigned long long | ( | ) | const |
conversion operator to unsigned long long
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator unsigned short int | ( | ) | const |
conversion operator to unsigned short int
Note: The implementation uses typedef ptrdiff_t.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
ParamValue& operator= | ( | const char * | ) |
specific assignment for char* (converted to string)
ParamValue& operator= | ( | const double | ) |
specific assignment for double values (note: the implementation uses double)
ParamValue& operator= | ( | const float | ) |
specific assignment for float values (note: the implementation uses double)
ParamValue& operator= | ( | const int | ) |
specific assignment for int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const long double | ) |
specific assignment for long double values (note: the implementation uses double)
ParamValue& operator= | ( | const long int | ) |
specific assignment for long int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const long long | ) |
specific assignment for long long int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const ParamValue & | ) |
Assignment operator.
ParamValue& operator= | ( | const short int | ) |
specific assignment for short int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const std::string & | ) |
specific assignment for std::string values
ParamValue& operator= | ( | const std::vector< double > & | ) |
specific assignment for double vectors
ParamValue& operator= | ( | const std::vector< int > & | ) |
specific assignment for integer vectors
ParamValue& operator= | ( | const std::vector< std::string > & | ) |
specific assignment for string vectors
ParamValue& operator= | ( | const unsigned long long | ) |
specific assignment for unsigned long long int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const unsigned long | ) |
specific assignment for unsigned long int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const unsigned short int | ) |
specific assignment for unsigned short int values (note: the implementation uses ptrdiff_t)
ParamValue& operator= | ( | const unsigned | ) |
specific assignment for unsigned int values (note: the implementation uses ptrdiff_t)
|
noexcept |
Move assignment operator.
bool toBool | ( | ) | const |
Conversion to bool.
Converts the strings 'true' and 'false' to a bool.
Exception::ConversionError | is thrown for non-string parameters and string parameters with values other than 'true' and 'false'. |
Referenced by TOPPViewBase::showSpectrumGenerationDialog(), and SignalToNoiseEstimatorMedian< Container >::updateMembers_().
const char* toChar | ( | ) | const |
Convert ParamValues to char*.
If the ParamValue contains a string, a pointer to it's char* is returned. If the ParamValue is empty, nullptr is returned.
std::vector<double> toDoubleVector | ( | ) | const |
Explicitly convert ParamValue to DoubleList.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
std::vector<int> toIntVector | ( | ) | const |
Explicitly convert ParamValue to IntList.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
std::string toString | ( | bool | full_precision = true | ) | const |
Convert ParamValue to string.
Exception::ConversionError | is thrown for ParamValue::EMPTY and |
Referenced by TOPPViewBase::getSpectrumParameters(), TOPPASBase::loadPreferences(), TOPPViewBase::loadPreferences(), main(), TOPPOpenSwathBase::performCalibration(), TOPPASBase::TOPPASBase(), TOPPViewBase::TOPPViewBase(), TOPPASBase::updateCurrentPath(), and TOPPViewBase::updateCurrentPath().
std::vector<std::string> toStringVector | ( | ) | const |
Explicitly convert ParamValue to string vector.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
|
inline |
returns the type of value stored
|
friend |
Equality comparator.
|
friend |
Smaller than comparator (for vectors we use the size)
|
friend |
output stream operator
|
friend |
Equality comparator.
|
friend |
Greater than comparator (for vectors we use the size)
union { ... } data_ |
Space to store the data.
|
static |
Empty data value for comparisons.
|
protected |
Type of the currently stored value.