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 #ifndef OWBI1_WQL_SELECT_STATEMENT_HPP_INCLUDE_GUARD_H_
00031 #define OWBI1_WQL_SELECT_STATEMENT_HPP_INCLUDE_GUARD_H_
00032 #include "OWBI1_config.h"
00033 #include "OWBI1_Array.hpp"
00034 #include "OWBI1_String.hpp"
00035 #include "OWBI1_WQLOperation.hpp"
00036 #include "OWBI1_WQLOperand.hpp"
00037 #include "OWBI1_WQLPropertySource.hpp"
00038 
00039 namespace OWBI1
00040 {
00041 
00053 class WQLCompile;
00054 class OWBI1_OWBI1PROVIFC_API WQLSelectStatement
00055 {
00056 public:
00057    WQLSelectStatement();
00058    ~WQLSelectStatement();
00061    void clear();
00062    const String& getClassName() const
00063    {
00064       return _className;
00065    }
00069    void setClassName(const String& className)
00070    {
00071       _className = className;
00072    }
00076    UInt32 getSelectPropertyNameCount() const
00077    {
00078       return _selectPropertyNames.size();
00079    }
00082    const String& getSelectPropertyName(UInt32 i) const
00083    {
00084       return _selectPropertyNames[i];
00085    }
00088    const StringArray& getSelectPropertyNames() const
00089    {
00090       return _selectPropertyNames;
00091    }
00095    void appendSelectPropertyName(const String& x)
00096    {
00097       _selectPropertyNames.append(x);
00098    }
00101    UInt32 getWherePropertyNameCount() const
00102    {
00103       return _wherePropertyNames.size();
00104    }
00107    const String& getWherePropertyName(UInt32 i) const
00108    {
00109       return _wherePropertyNames[i];
00110    }
00116    bool appendWherePropertyName(const String& x);
00120    void appendOperation(WQLOperation x)
00121    {
00122       _operStack.push_back(x);
00123    }
00127    void appendOperand(const WQLOperand& x)
00128    {
00129       _operStack.push_back(x);
00130    }
00133    bool hasWhereClause() const
00134    {
00135       return !_operStack.empty();
00136    }
00145    bool evaluateWhereClause(const WQLPropertySource* source) const;
00148    void print(std::ostream& ostr) const;
00149    String toString() const;
00150    void compileWhereClause(const WQLPropertySource* source, WQLCompile& wcl);
00151 private:
00152 
00153 #ifdef OWBI1_WIN32
00154 #pragma warning (push)
00155 #pragma warning (disable: 4251)
00156 #endif
00157 
00158    
00159    
00160    
00161    
00162    
00163    
00164    
00165    String _className;
00166    
00167    
00168    
00169    
00170    
00171    
00172    
00173    
00174    Array<String> _selectPropertyNames;
00175    
00176    
00177    
00178    
00179    
00180    Array<String> _wherePropertyNames;
00181    
00182    
00183    
00184    
00185    
00186    
00187    
00188    
00189    
00190    
00191    
00192    
00193    
00194    
00195    
00196    
00197    
00198    
00199    
00200    
00201    
00202    
00203    
00204    
00205    struct OperandOrOperation
00206    {
00207       enum Type
00208       {
00209          OPERATION,
00210          OPERAND
00211       };
00212       OperandOrOperation(WQLOperation o)
00213          : m_type(OPERATION)
00214          , m_operation(o)
00215       {}
00216       OperandOrOperation(const WQLOperand& o)
00217          : m_type(OPERAND)
00218          , m_operand(o)
00219       {}
00220       Type m_type;
00221       WQLOperation m_operation;
00222       WQLOperand m_operand;
00223       String toString() const
00224       {
00225          if (m_type == OPERATION)
00226          {
00227             return WQLOperationToString(m_operation);
00228          }
00229          else
00230          {
00231             return m_operand.toString();
00232          }
00233       }
00234    };
00235    Array<OperandOrOperation> _operStack;
00236    friend class WQLCompile;
00237 
00238 #ifdef OWBI1_WIN32
00239 #pragma warning (pop)
00240 #endif
00241 
00242 };
00243 
00244 } 
00245 
00246 #endif