Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_DATASTRUCTURES_DATAVALUE_H
00036 #define OPENMS_DATASTRUCTURES_DATAVALUE_H
00037
00038 #include <OpenMS/CONCEPT/Exception.h>
00039 #include <OpenMS/DATASTRUCTURES/String.h>
00040 #include <OpenMS/DATASTRUCTURES/StringList.h>
00041 #include <OpenMS/DATASTRUCTURES/IntList.h>
00042 #include <OpenMS/DATASTRUCTURES/DoubleList.h>
00043 #include <QtCore/QString>
00044
00045 namespace OpenMS
00046 {
00047
00057 class OPENMS_DLLAPI DataValue
00058 {
00059
00060 public:
00061
00063 static const DataValue EMPTY;
00064
00066 enum DataType
00067 {
00068 STRING_VALUE,
00069 INT_VALUE,
00070 DOUBLE_VALUE,
00071 STRING_LIST,
00072 INT_LIST,
00073 DOUBLE_LIST,
00074 EMPTY_VALUE
00075 };
00076
00078
00079
00080 DataValue();
00082 DataValue(const char*);
00084 DataValue(const std::string&);
00086 DataValue(const String&);
00088 DataValue(const QString&);
00090 DataValue(const StringList&);
00092 DataValue(const IntList&);
00094 DataValue(const DoubleList&);
00096 DataValue(long double);
00098 DataValue(double);
00100 DataValue(float);
00102 DataValue(short int);
00104 DataValue(unsigned short int);
00106 DataValue(int);
00108 DataValue(unsigned);
00110 DataValue(long int);
00112 DataValue(unsigned long);
00114 DataValue(long long);
00116 DataValue(unsigned long long);
00118 DataValue(const DataValue&);
00120 virtual ~DataValue();
00122
00126
00127
00133 operator std::string() const;
00134
00140 operator StringList() const;
00141
00147 operator IntList() const;
00148
00154 operator DoubleList() const;
00155
00163 operator long double() const;
00164
00172 operator double() const;
00173
00181 operator float() const;
00182
00190 operator short int() const;
00191
00199 operator unsigned short int() const;
00200
00209 operator int() const;
00210
00218 operator unsigned int() const;
00219
00227 operator long int() const;
00228
00236 operator unsigned long int() const;
00237
00245 operator long long() const;
00246
00254 operator unsigned long long() const;
00255
00262 const char* toChar() const;
00264
00267
00268
00270 DataValue& operator=(const char*);
00272 DataValue& operator=(const std::string&);
00274 DataValue& operator=(const String&);
00276 DataValue& operator=(const QString&);
00278 DataValue& operator=(const StringList&);
00280 DataValue& operator=(const IntList&);
00282 DataValue& operator=(const DoubleList&);
00284 DataValue& operator=(const long double);
00286 DataValue& operator=(const double);
00288 DataValue& operator=(const float);
00290 DataValue& operator=(const short int);
00292 DataValue& operator=(const unsigned short int);
00294 DataValue& operator=(const int);
00296 DataValue& operator=(const unsigned);
00298 DataValue& operator=(const long int);
00300 DataValue& operator=(const unsigned long);
00302 DataValue& operator=(const long long);
00304 DataValue& operator=(const unsigned long long);
00305
00307
00311
00312
00314 String toString() const;
00315
00317 QString toQString() const;
00318
00326 bool toBool() const;
00328
00330 inline DataType valueType() const
00331 {
00332 return value_type_;
00333 }
00334
00336 DataValue& operator=(const DataValue&);
00337
00339 inline bool isEmpty() const
00340 {
00341 return value_type_ == EMPTY_VALUE;
00342 }
00343
00346
00347
00349 inline bool hasUnit() const
00350 {
00351 return unit_ != "";
00352 }
00353
00355 const String& getUnit() const;
00356
00358 void setUnit(const String& unit);
00359
00361
00363 friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream&, const DataValue&);
00364
00366 friend OPENMS_DLLAPI bool operator==(const DataValue&, const DataValue&);
00367
00369 friend OPENMS_DLLAPI bool operator<(const DataValue&, const DataValue&);
00370
00372 friend OPENMS_DLLAPI bool operator>(const DataValue&, const DataValue&);
00373
00375 friend OPENMS_DLLAPI bool operator!=(const DataValue&, const DataValue&);
00376
00377 protected:
00378
00380 DataType value_type_;
00381
00383 union
00384 {
00385 SignedSize ssize_;
00386 DoubleReal dou_;
00387 String* str_;
00388 StringList* str_list_;
00389 IntList* int_list_;
00390 DoubleList* dou_list_;
00391 } data_;
00392
00393 private:
00395 String unit_;
00396
00398 void clear_();
00399 };
00400 }
00401
00402 #endif // OPENMS_DATASTRUCTURES_DATAVALUE_H