OpenMS
2.4.0
|
Class to hold strings, numeric values, lists of strings and lists of numeric values. More...
#include <OpenMS/DATASTRUCTURES/DataValue.h>
Public Types | |
enum | DataType { STRING_VALUE, INT_VALUE, DOUBLE_VALUE, STRING_LIST, INT_LIST, DOUBLE_LIST, EMPTY_VALUE } |
Supported types for DataValue. More... | |
Public Member Functions | |
DataType | valueType () const |
returns the type of value stored More... | |
DataValue & | operator= (const DataValue &) |
assignment operator More... | |
bool | isEmpty () const |
Test if the value is empty. More... | |
Constructors and destructors | |
DataValue () | |
default constructor More... | |
DataValue (const char *) | |
specific constructor for char* (converted to string) More... | |
DataValue (const std::string &) | |
specific constructor for std::string values More... | |
DataValue (const String &) | |
specific constructor for string values More... | |
DataValue (const QString &) | |
specific constructor for QString values More... | |
DataValue (const StringList &) | |
specific constructor for string lists More... | |
DataValue (const IntList &) | |
specific constructor for integer lists More... | |
DataValue (const DoubleList &) | |
specific constructor for double lists More... | |
DataValue (long double) | |
specific constructor for long double values (note: the implementation uses double) More... | |
DataValue (double) | |
specific constructor for double values (note: the implementation uses double) More... | |
DataValue (float) | |
specific constructor for float values (note: the implementation uses double) More... | |
DataValue (short int) | |
specific constructor for short int values (note: the implementation uses SignedSize) More... | |
DataValue (unsigned short int) | |
specific constructor for unsigned short int values (note: the implementation uses SignedSize) More... | |
DataValue (int) | |
specific constructor for int values (note: the implementation uses SignedSize) More... | |
DataValue (unsigned) | |
specific constructor for unsigned int values (note: the implementation uses SignedSize) More... | |
DataValue (long int) | |
specific constructor for long int values (note: the implementation uses SignedSize) More... | |
DataValue (unsigned long) | |
specific constructor for unsigned long int values (note: the implementation uses SignedSize) More... | |
DataValue (long long) | |
specific constructor for long long int values (note: the implementation uses SignedSize) More... | |
DataValue (unsigned long long) | |
specific constructor for unsigned long long int values (note: the implementation uses SignedSize) More... | |
DataValue (const DataValue &) | |
copy constructor More... | |
virtual | ~DataValue () |
destructor More... | |
Cast operators | |
These methods are used when the DataType is known. If they are applied to a DataValue with the wrong DataType, an exception (Exception::ConversionError) is thrown. In particular, none of these operators will work for an empty DataValue (DataType EMPTY_VALUE) - except toChar(), which will return 0. | |
operator std::string () const | |
conversion operator to string More... | |
operator StringList () const | |
conversion operator to string list More... | |
operator IntList () const | |
conversion operator to integer list More... | |
operator DoubleList () const | |
conversion operator to double list 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... | |
const char * | toChar () const |
Convert DataValues to char*. More... | |
StringList | toStringList () const |
Explicitly convert DataValue to StringList. More... | |
IntList | toIntList () const |
Explicitly convert DataValue to IntList. More... | |
DoubleList | toDoubleList () const |
Explicitly convert DataValue to DoubleList. More... | |
assignment/conversion operators | |
These methods are used to assign supported types to DataType. | |
DataValue & | operator= (const char *) |
specific assignment for char* (converted to string) More... | |
DataValue & | operator= (const std::string &) |
specific assignment for std::string values More... | |
DataValue & | operator= (const String &) |
specific assignment for string values More... | |
DataValue & | operator= (const QString &) |
specific assignment for QString values More... | |
DataValue & | operator= (const StringList &) |
specific assignment for string lists More... | |
DataValue & | operator= (const IntList &) |
specific assignment for integer lists More... | |
DataValue & | operator= (const DoubleList &) |
specific assignment for double lists More... | |
DataValue & | operator= (const long double) |
specific assignment for long double values (note: the implementation uses double) More... | |
DataValue & | operator= (const double) |
specific assignment for double values (note: the implementation uses double) More... | |
DataValue & | operator= (const float) |
specific assignment for float values (note: the implementation uses double) More... | |
DataValue & | operator= (const short int) |
specific assignment for short int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const unsigned short int) |
specific assignment for unsigned short int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const int) |
specific assignment for int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const unsigned) |
specific assignment for unsigned int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const long int) |
specific assignment for long int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const unsigned long) |
specific assignment for unsigned long int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const long long) |
specific assignment for long long int values (note: the implementation uses SignedSize) More... | |
DataValue & | operator= (const unsigned long long) |
specific assignment for unsigned long long int values (note: the implementation uses SignedSize) More... | |
conversion operators | |
These methods can be used independent of the DataType. If you already know the DataType, you should use a cast operator! | |
String | toString () const |
Conversion to String. More... | |
QString | toQString () const |
Conversion to QString. More... | |
bool | toBool () const |
Conversion to bool. More... | |
Methods to handle units | |
These methods are used when the DataValue has an associated unit. | |
bool | hasUnit () const |
Check if the value has a unit. More... | |
const String & | getUnit () const |
Return the unit associated to this DataValue. More... | |
void | setUnit (const String &unit) |
Sets the unit to the given String. More... | |
Static Public Attributes | |
static const DataValue | EMPTY |
Empty data value for comparisons. More... | |
Protected Attributes | |
DataType | value_type_ |
Type of the currently stored value. More... | |
union { | |
SignedSize ssize_ | |
double dou_ | |
String * str_ | |
StringList * str_list_ | |
IntList * int_list_ | |
DoubleList * dou_list_ | |
} | data_ |
Space to store the data. More... | |
Private Member Functions | |
void | clear_ () |
Clears the current state of the DataValue and release every used memory. More... | |
Private Attributes | |
String | unit_ |
The unit of the data value (if it has one), otherwise empty string. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &, const DataValue &) |
output stream operator More... | |
bool | operator== (const DataValue &, const DataValue &) |
Equality comparator. More... | |
bool | operator< (const DataValue &, const DataValue &) |
Smaller than comparator (for lists we use the size) More... | |
bool | operator> (const DataValue &, const DataValue &) |
Greater than comparator (for lists we use the size) More... | |
bool | operator!= (const DataValue &, const DataValue &) |
Equality comparator. More... | |
Class to hold strings, numeric values, lists of strings and lists of numeric values.
enum DataType |
Supported types for DataValue.
Enumerator | |
---|---|
STRING_VALUE | string value |
INT_VALUE | integer value |
DOUBLE_VALUE | double value |
STRING_LIST | string list |
INT_LIST | integer list |
DOUBLE_LIST | double list |
EMPTY_VALUE | empty value |
DataValue | ( | ) |
default constructor
DataValue | ( | const char * | ) |
specific constructor for char* (converted to string)
DataValue | ( | const std::string & | ) |
specific constructor for std::string values
DataValue | ( | const QString & | ) |
specific constructor for QString values
DataValue | ( | const StringList & | ) |
specific constructor for string lists
DataValue | ( | const DoubleList & | ) |
specific constructor for double lists
DataValue | ( | long | double | ) |
specific constructor for long double values (note: the implementation uses double)
DataValue | ( | short | int | ) |
specific constructor for short int values (note: the implementation uses SignedSize)
DataValue | ( | unsigned short | int | ) |
specific constructor for unsigned short int values (note: the implementation uses SignedSize)
DataValue | ( | int | ) |
specific constructor for int values (note: the implementation uses SignedSize)
DataValue | ( | unsigned | ) |
specific constructor for unsigned int values (note: the implementation uses SignedSize)
DataValue | ( | long | int | ) |
specific constructor for long int values (note: the implementation uses SignedSize)
DataValue | ( | unsigned | long | ) |
specific constructor for unsigned long int values (note: the implementation uses SignedSize)
DataValue | ( | long | long | ) |
specific constructor for long long int values (note: the implementation uses SignedSize)
DataValue | ( | unsigned long | long | ) |
specific constructor for unsigned long long int values (note: the implementation uses SignedSize)
|
virtual |
destructor
|
private |
Clears the current state of the DataValue and release every used memory.
|
inline |
Check if the value has a unit.
|
inline |
Test if the value is empty.
Referenced by IDFilter::HasMetaValue< HitType >::operator()(), and IDFilter::HasMaxMetaValue< HitType >::operator()().
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 DoubleList | ( | ) | const |
conversion operator to double list
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 SignedSize.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
operator IntList | ( | ) | const |
conversion operator to integer list
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 SignedSize.
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 SignedSize.
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 SignedSize.
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 StringList | ( | ) | const |
conversion operator to string list
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 SignedSize.
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 SignedSize.
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 SignedSize.
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 SignedSize.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
DataValue& operator= | ( | const char * | ) |
specific assignment for char* (converted to string)
DataValue& operator= | ( | const std::string & | ) |
specific assignment for std::string values
DataValue& operator= | ( | const QString & | ) |
specific assignment for QString values
DataValue& operator= | ( | const StringList & | ) |
specific assignment for string lists
DataValue& operator= | ( | const DoubleList & | ) |
specific assignment for double lists
DataValue& operator= | ( | const long | double | ) |
specific assignment for long double values (note: the implementation uses double)
specific assignment for double values (note: the implementation uses double)
specific assignment for float values (note: the implementation uses double)
DataValue& operator= | ( | const short | int | ) |
specific assignment for short int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const unsigned short | int | ) |
specific assignment for unsigned short int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const int | ) |
specific assignment for int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const unsigned | ) |
specific assignment for unsigned int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const long | int | ) |
specific assignment for long int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const unsigned | long | ) |
specific assignment for unsigned long int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const long | long | ) |
specific assignment for long long int values (note: the implementation uses SignedSize)
DataValue& operator= | ( | const unsigned long | long | ) |
specific assignment for unsigned long long int values (note: the implementation uses SignedSize)
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::preferencesDialog(), TOPPViewBase::showSpectrumGenerationDialog(), and SignalToNoiseEstimatorMedian< ContainerT >::updateMembers_().
const char* toChar | ( | ) | const |
DoubleList toDoubleList | ( | ) | const |
Explicitly convert DataValue to DoubleList.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
IntList toIntList | ( | ) | const |
Explicitly convert DataValue to IntList.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
QString toQString | ( | ) | const |
Conversion to QString.
Referenced by TOPPViewBase::preferencesDialog(), and TOPPViewBase::updateLayerBar().
String toString | ( | ) | const |
StringList toStringList | ( | ) | const |
Explicitly convert DataValue to StringList.
Exception::ConversionError | is thrown if a cast from the the wrong type is requested |
|
inline |
returns the type of value stored
Referenced by DataFilters::metaPasses_().
Smaller than comparator (for lists we use the size)
|
friend |
output stream operator
Greater than comparator (for lists we use the size)
union { ... } data_ |
Space to store the data.
double dou_ |
DoubleList* dou_list_ |
|
static |
Empty data value for comparisons.
IntList* int_list_ |
SignedSize ssize_ |
String* str_ |
StringList* str_list_ |
|
private |
The unit of the data value (if it has one), otherwise empty string.
|
protected |
Type of the currently stored value.