Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | Friends

DataValue Class Reference
[Datastructures]

Class to hold strings, numeric values, lists of strings and lists of numeric values. More...

#include <OpenMS/DATASTRUCTURES/DataValue.h>

List of all members.

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
DataValueoperator= (const DataValue &)
 assignment operator
bool isEmpty () const
 test if the value is empty
Constructors and destructors

 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 String &)
 specific constructor for string values
 DataValue (const QString &)
 specific constructor for QString values
 DataValue (const StringList &)
 specific constructor for string lists
 DataValue (const IntList &)
 specific constructor for integer lists
 DataValue (const DoubleList &)
 specific constructor for double lists
 DataValue (long double)
 specific constructor for long double values (note: the implementation uses DoubleReal)
 DataValue (double)
 specific constructor for double values (note: the implementation uses DoubleReal)
 DataValue (float)
 specific constructor for float values (note: the implementation uses DoubleReal)
 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)
 DataValue (const DataValue &)
 copy constructor
virtual ~DataValue ()
 destructor
cast operators

These methods are used when the DataType is known. If they are applied to a DataValue with the wrong DataType, an exception is thrown.

 operator std::string () const
 conversion operator to string
 operator StringList () const
 conversion operator to string list
 operator IntList () const
 conversion operator to integer list
 operator DoubleList () const
 conversion operator to double list
 operator long double () const
 conversion operator to long double
 operator double () const
 conversion operator to double
 operator float () const
 conversion operator to float
 operator short int () const
 conversion operator to short int
 operator unsigned short int () const
 conversion operator to unsigned short int
 operator int () const
 conversion operator to int
 operator unsigned int () const
 conversion operator to unsigned int
 operator long int () const
 conversion operator to long int
 operator unsigned long int () const
 conversion operator to unsigned long int
 operator long long () const
 conversion operator to long long
 operator unsigned long long () const
 conversion operator to unsigned long long
const char * toChar () const
 Convert DataValues to char*.
assignment/conversion operators

These methods are used to assign supported types to DataType.

DataValueoperator= (const char *)
 specific assignment for char* (converted to string)
DataValueoperator= (const std::string &)
 specific assignment for std::string values
DataValueoperator= (const String &)
 specific assignment for string values
DataValueoperator= (const QString &)
 specific assignment for QString values
DataValueoperator= (const StringList &)
 specific assignment for string lists
DataValueoperator= (const IntList &)
 specific assignment for integer lists
DataValueoperator= (const DoubleList &)
 specific assignment for double lists
DataValueoperator= (const long double)
 specific assignment for long double values (note: the implementation uses DoubleReal)
DataValueoperator= (const double)
 specific assignment for double values (note: the implementation uses DoubleReal)
DataValueoperator= (const float)
 specific assignment for float values (note: the implementation uses DoubleReal)
DataValueoperator= (const short int)
 specific assignment for short int values (note: the implementation uses SignedSize)
DataValueoperator= (const unsigned short int)
 specific assignment for unsigned short int values (note: the implementation uses SignedSize)
DataValueoperator= (const int)
 specific assignment for int values (note: the implementation uses SignedSize)
DataValueoperator= (const unsigned)
 specific assignment for unsigned int values (note: the implementation uses SignedSize)
DataValueoperator= (const long int)
 specific assignment for long int values (note: the implementation uses SignedSize)
DataValueoperator= (const unsigned long)
 specific assignment for unsigned long int values (note: the implementation uses SignedSize)
DataValueoperator= (const long long)
 specific assignment for long long int values (note: the implementation uses SignedSize)
DataValueoperator= (const unsigned long long)
 specific assignment for unsigned long long int values (note: the implementation uses SignedSize)
conversion operators

These methods can be used independent of the DataType. If you already know the DataType, you should use a cast operator!
For conversion of string DataValues to numeric types, first use toString() and then the conversion methods of String.

String toString () const
 Conversion to String.
QString toQString () const
 Conversion to QString.
bool toBool () const
 Conversion to bool.
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.
const StringgetUnit () const
 Return the unit associated to this DataValue.
void setUnit (const String &unit)
 Sets the unit to the given String.

Static Public Attributes

static const DataValue EMPTY
 Empty data value for comparisons.

Protected Attributes

DataType value_type_
 Type of the currently stored value.
union {
   SignedSize   ssize_
   DoubleReal   dou_
   String *   str_
   StringList *   str_list_
   IntList *   int_list_
   DoubleList *   dou_list_
data_
 Space to store the data.

Private Member Functions

void clear_ ()
 Clears the current state of the DataValue and release every used memory.

Private Attributes

String unit_
 The unit of the data value (if it has one), otherwise empty string.

Friends

std::ostream & operator<< (std::ostream &, const DataValue &)
 output stream operator
bool operator== (const DataValue &, const DataValue &)
 Equality comparator.
bool operator< (const DataValue &, const DataValue &)
 Smaller than comparator (for lists we use the size).
bool operator> (const DataValue &, const DataValue &)
 Greater than comparator (for lists we use the size).
bool operator!= (const DataValue &, const DataValue &)
 Equality comparator.

Detailed Description

Class to hold strings, numeric values, lists of strings and lists of numeric values.


Member Enumeration Documentation

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


Constructor & Destructor Documentation

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 String  ) 

specific constructor for string values

DataValue ( const QString &   ) 

specific constructor for QString values

DataValue ( const StringList  ) 

specific constructor for string lists

DataValue ( const IntList  ) 

specific constructor for integer lists

DataValue ( const DoubleList  ) 

specific constructor for double lists

DataValue ( long  double  ) 

specific constructor for long double values (note: the implementation uses DoubleReal)

DataValue ( double   ) 

specific constructor for double values (note: the implementation uses DoubleReal)

DataValue ( float   ) 

specific constructor for float values (note: the implementation uses DoubleReal)

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)

DataValue ( const DataValue  ) 

copy constructor

virtual ~DataValue (  )  [virtual]

destructor


Member Function Documentation

void clear_ (  )  [private]

Clears the current state of the DataValue and release every used memory.

const String& getUnit (  )  const

Return the unit associated to this DataValue.

Referenced by MzMLHandler< MapType >::writeCV_().

bool hasUnit (  )  const [inline]

Check if the value has a unit.

Referenced by MzMLHandler< MapType >::writeCV_().

bool isEmpty (  )  const [inline]

test if the value is empty

Referenced by MzMLHandler< MapType >::writeCV_().

operator double (  )  const

conversion operator to double

Note: The implementation uses typedef DoubleReal (as opposed to float, double, long double.)

Exceptions:
Exception::ConversionError is thrown if a cast from the the wrong type is requested
operator DoubleList (  )  const

conversion operator to double list

Exceptions:
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 DoubleReal (as opposed to float, double, long double.)

Exceptions:
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.

Exceptions:
Exception::ConversionError is thrown if a cast from the the wrong type is requested
operator IntList (  )  const

conversion operator to integer list

Exceptions:
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 DoubleReal (as opposed to float, double, long double.)

Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

Exceptions:
Exception::ConversionError is thrown if a cast from the the wrong type is requested
operator std::string (  )  const

conversion operator to string

Exceptions:
Exception::ConversionError is thrown if a cast from the the wrong type is requested
operator StringList (  )  const

conversion operator to string list

Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

Exceptions:
Exception::ConversionError is thrown if a cast from the the wrong type is requested
DataValue& operator= ( const   float  ) 

specific assignment for float values (note: the implementation uses DoubleReal)

DataValue& operator= ( const short  int  ) 

specific assignment for short 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 DoubleList  ) 

specific assignment for double lists

DataValue& operator= ( const long  long  ) 

specific assignment for long long int values (note: the implementation uses SignedSize)

DataValue& operator= ( const StringList  ) 

specific assignment for string lists

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 String  ) 

specific assignment for string values

DataValue& operator= ( const long  int  ) 

specific assignment for long int values (note: the implementation uses SignedSize)

DataValue& operator= ( const QString &   ) 

specific assignment for QString values

DataValue& operator= ( const   unsigned  ) 

specific assignment for unsigned 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 unsigned long  long  ) 

specific assignment for unsigned long long int values (note: the implementation uses SignedSize)

DataValue& operator= ( const   double  ) 

specific assignment for double values (note: the implementation uses DoubleReal)

DataValue& operator= ( const IntList  ) 

specific assignment for integer lists

DataValue& operator= ( const DataValue  ) 

assignment operator

DataValue& operator= ( const long  double  ) 

specific assignment for long double values (note: the implementation uses DoubleReal)

DataValue& operator= ( const   int  ) 

specific assignment for int values (note: the implementation uses SignedSize)

void setUnit ( const String unit  ) 

Sets the unit to the given String.

Referenced by MzMLHandler< MapType >::handleCVParam_().

bool toBool (  )  const

Conversion to bool.

Converts the strings 'true' and 'false' to a bool.

Exceptions:
Exception::ConversionError is thrown for non-string parameters and string parameters with values other than 'true' and 'false'.

Referenced by TOPPViewBase::preferencesDialog(), and FeatureFinderAlgorithmMRM< PeakType, FeatureType >::run().

const char* toChar (  )  const

Convert DataValues to char*.

If the DataValue contains a string, a pointer to it's char* is returned. If the DataValue is empty, NULL is returned.

QString toQString (  )  const

Conversion to QString.

Referenced by TOPPViewBase::preferencesDialog(), and TOPPViewBase::updateLayerBar().

String toString (  )  const
DataType valueType (  )  const [inline]

returns the type of value stored

Referenced by TOPPRNPxl::main_(), DataFilters::metaPasses_(), and MzMLHandler< MapType >::writeUserParam_().


Friends And Related Function Documentation

bool operator!= ( const DataValue ,
const DataValue  
) [friend]

Equality comparator.

bool operator< ( const DataValue ,
const DataValue  
) [friend]

Smaller than comparator (for lists we use the size).

std::ostream& operator<< ( std::ostream &  ,
const DataValue  
) [friend]

output stream operator

bool operator== ( const DataValue ,
const DataValue  
) [friend]

Equality comparator.

bool operator> ( const DataValue ,
const DataValue  
) [friend]

Greater than comparator (for lists we use the size).


Member Data Documentation

union { ... } data_ [protected]

Space to store the data.

const DataValue EMPTY [static]
String unit_ [private]

The unit of the data value (if it has one), otherwise empty string.

DataType value_type_ [protected]

Type of the currently stored value.


OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:51 using doxygen 1.7.1