Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
DataValue.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2013.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Stephan Aiche$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_DATASTRUCTURES_DATAVALUE_H
36 #define OPENMS_DATASTRUCTURES_DATAVALUE_H
37 
43 #include <QtCore/QString>
44 
45 namespace OpenMS
46 {
47 
57  class OPENMS_DLLAPI DataValue
58  {
59 
60 public:
61 
63  static const DataValue EMPTY;
64 
66  enum DataType
67  {
74  EMPTY_VALUE
75  };
76 
78 
79  DataValue();
82  DataValue(const char*);
84  DataValue(const std::string&);
86  DataValue(const String&);
88  DataValue(const QString&);
90  DataValue(const StringList&);
92  DataValue(const IntList&);
94  DataValue(const DoubleList&);
96  DataValue(long double);
98  DataValue(double);
100  DataValue(float);
102  DataValue(short int);
104  DataValue(unsigned short int);
106  DataValue(int);
108  DataValue(unsigned);
110  DataValue(long int);
112  DataValue(unsigned long);
114  DataValue(long long);
116  DataValue(unsigned long long);
118  DataValue(const DataValue&);
120  virtual ~DataValue();
122 
126 
127 
133  operator std::string() const;
134 
140  operator StringList() const;
141 
147  operator IntList() const;
148 
154  operator DoubleList() const;
155 
163  operator long double() const;
164 
172  operator double() const;
173 
181  operator float() const;
182 
190  operator short int() const;
191 
199  operator unsigned short int() const;
200 
209  operator int() const;
210 
218  operator unsigned int() const;
219 
227  operator long int() const;
228 
236  operator unsigned long int() const;
237 
245  operator long long() const;
246 
254  operator unsigned long long() const;
255 
262  const char* toChar() const;
264 
267 
268 
270  DataValue& operator=(const char*);
272  DataValue& operator=(const std::string&);
274  DataValue& operator=(const String&);
276  DataValue& operator=(const QString&);
278  DataValue& operator=(const StringList&);
280  DataValue& operator=(const IntList&);
282  DataValue& operator=(const DoubleList&);
284  DataValue& operator=(const long double);
286  DataValue& operator=(const double);
288  DataValue& operator=(const float);
290  DataValue& operator=(const short int);
292  DataValue& operator=(const unsigned short int);
294  DataValue& operator=(const int);
296  DataValue& operator=(const unsigned);
298  DataValue& operator=(const long int);
300  DataValue& operator=(const unsigned long);
302  DataValue& operator=(const long long);
304  DataValue& operator=(const unsigned long long);
305 
307 
311 
312 
314  String toString() const;
315 
317  QString toQString() const;
318 
326  bool toBool() const;
328 
330  inline DataType valueType() const
331  {
332  return value_type_;
333  }
334 
336  DataValue& operator=(const DataValue&);
337 
339  inline bool isEmpty() const
340  {
341  return value_type_ == EMPTY_VALUE;
342  }
343 
346 
347 
349  inline bool hasUnit() const
350  {
351  return unit_ != "";
352  }
353 
355  const String& getUnit() const;
356 
358  void setUnit(const String& unit);
359 
361 
363  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream&, const DataValue&);
364 
366  friend OPENMS_DLLAPI bool operator==(const DataValue&, const DataValue&);
367 
369  friend OPENMS_DLLAPI bool operator<(const DataValue&, const DataValue&);
370 
372  friend OPENMS_DLLAPI bool operator>(const DataValue&, const DataValue&);
373 
375  friend OPENMS_DLLAPI bool operator!=(const DataValue&, const DataValue&);
376 
377 protected:
378 
381 
383  union
384  {
391  } data_;
392 
393 private:
396 
398  void clear_();
399  };
400 }
401 
402 #endif // OPENMS_DATASTRUCTURES_DATAVALUE_H
StringList * str_list_
Definition: DataValue.h:388
bool hasUnit() const
Check if the value has a unit.
Definition: DataValue.h:349
A more convenient string class.
Definition: String.h:56
DataType value_type_
Type of the currently stored value.
Definition: DataValue.h:380
DoubleReal dou_
Definition: DataValue.h:386
double list
Definition: DataValue.h:73
static const DataValue EMPTY
Empty data value for comparisons.
Definition: DataValue.h:63
integer value
Definition: DataValue.h:69
std::ostream & operator<<(std::ostream &os, const ItraqQuantifier::ItraqQuantifierStats &stats)
string list
Definition: DataValue.h:71
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:151
IntList * int_list_
Definition: DataValue.h:389
DataType
Supported types for DataValue.
Definition: DataValue.h:66
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:57
DataType valueType() const
returns the type of value stored
Definition: DataValue.h:330
double value
Definition: DataValue.h:70
string value
Definition: DataValue.h:68
DoubleList * dou_list_
Definition: DataValue.h:390
bool isEmpty() const
test if the value is empty
Definition: DataValue.h:339
SignedSize ssize_
Definition: DataValue.h:385
String list.
Definition: StringList.h:56
integer list
Definition: DataValue.h:72
String * str_
Definition: DataValue.h:387
String unit_
The unit of the data value (if it has one), otherwise empty string.
Definition: DataValue.h:395
DoubleReal list.
Definition: DoubleList.h:56
Int list.
Definition: IntList.h:56

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:12 using doxygen 1.8.5