VHISTlib
1.84.0.3018
|
00001 /* $HEADERS 00002 $Id: returnvalue.h 2168 2011-05-30 09:09:54Z ahuesgen $ 00003 */ 00004 00005 #ifndef RETURNVALUE_H 00006 #define RETURNVALUE_H 00007 00008 #include "../shared/misc_defines.h" 00009 00010 #include <QString> 00011 #include <QDateTime> 00012 00013 namespace vhist 00014 { 00015 00016 enum ReturnValueType 00017 { 00018 RETURN_VALUE_BOOL, 00019 RETURN_VALUE_STRING, 00020 RETURN_VALUE_NOT_MATCHED, 00021 RETURN_VALUE_INVALID_TYPE, 00022 RETURN_VALUE_INVALID_OPERATOR, 00023 RETURN_VALUE_UNKNOWN_TOKEN_TYPE, 00024 RETURN_VALUE_NOT_ASSIGNED_YET 00025 }; 00026 00027 00028 class ReturnValue 00029 { 00030 public: 00031 ReturnValue(ReturnValueType t, QString v); 00032 00033 public: 00034 bool isNumber() const; 00035 bool isDate() const; 00036 bool isString() const; 00037 bool isBool() const; 00038 bool isValid() const; 00039 bool isUnassignedVariable() const; 00040 00041 QDateTime toDate(bool* success = NULL) const; 00042 float toNumber(bool* success = NULL) const; 00043 QString toString(bool* success = NULL) const; 00044 bool toBool(bool* success = NULL) const; 00045 00046 public: 00047 static ReturnValue fromString(const QString string); 00048 static ReturnValue fromBool(bool boolean); 00049 static ReturnValue fromNumber(float number); 00050 00051 public: 00052 bool operator ==(const ReturnValue& rhs); 00053 00054 private: 00055 ReturnValueType m_type; 00056 QString m_value; 00057 }; 00058 00059 } 00060 00061 #endif // RETURNVALUE_H