VHISTlib  1.84.0.3018
/daten/ahuesgen/projects/vhist/code/vhistlib/include/vhistfindlib/expressionvalue.h
00001 /* $HEADERS
00002  $Id: expressionvalue.h 2168 2011-05-30 09:09:54Z ahuesgen $
00003  */
00004 
00005 #ifndef EXPRESSIONVALUE_H
00006 #define EXPRESSIONVALUE_H
00007 
00008 #include "../shared/misc_defines.h"
00009 
00010 #include <QString>
00011 #include <QtDebug>
00012 
00013 namespace vhist
00014 {
00015 
00016 struct Variable
00017 {
00018     QString name;
00019     QString attribute;
00020 };
00021 
00022 
00023 struct Operator
00024 {
00025     QString operatorValue;
00026     int precedence;
00027     char association; // 'l' for left, 'r' for right
00028     int numArguments;
00029 };
00030 
00031 
00032 enum ValueType
00033 {
00034     VALUE_TYPE_VARIABLE = 1,
00035     VALUE_TYPE_STRING = 2,
00036     VALUE_TYPE_OPERATOR = 4
00037 };
00038 
00039 
00040 class ExpressionValue
00041 {
00042 public:
00043     ExpressionValue();
00044     
00045 public:
00046     bool isVariable() const;
00047     bool isString() const;
00048     bool isOperator() const;
00049 
00050 public:
00051     QString originalText() const;
00052     int position() const;
00053     int length() const;
00054 
00055     QString string() const;
00056 
00057     QString operatorName() const;
00058     int precedence() const;
00059     void setPrecedence(int newPrecedence);
00060     int numArgs() const;
00061     char association() const;
00062 
00063     QString variableName() const;
00064     QString variableAttribute() const;
00065 
00066 public:
00067     void setVariableName(const QString& name);
00068 
00069     
00070 
00071 private:
00072     ValueType m_type;
00073     Variable m_var;
00074     QString m_string;
00075     Operator m_operator;
00076     QString m_originalText;
00077     int m_pos;
00078     
00079 public:
00080     static ExpressionValue fromString(const QString& string, int pos = -1,
00081             const QString& originalText = "");
00082     static ExpressionValue fromVariable(const QString& variableName,
00083             const QString attribute, int pos = -1,
00084             const QString& originalText = "");
00085     static ExpressionValue fromVariable(const QString& variable,
00086             int pos = -1, const QString& originalText = "");
00087     static ExpressionValue fromOperator(const QString& string,
00088             int pos = -1, const QString& originalText = "");
00089 };
00090 
00091 }
00092 
00093 QDebug operator<<(QDebug dbg, const vhist::ExpressionValue &v);
00094 
00095 #endif // EXPRESSIONVALUE_H

VHISTlib 1.84.0.3018 of Jun 28 2013, generated by doxygen.