whereClause.h
Go to the documentation of this file.
00001 // $Id$
00002 // Author: John Wu <John.Wu at acm.org>
00003 //      Lawrence Berkeley National Laboratory
00004 // Copyright 2007-2012 the Regents of the University of California
00008 #ifndef IBIS_WHERECLAUSE_H
00009 #define IBIS_WHERECLAUSE_H
00010 #include "qExpr.h"
00011 
00012 namespace ibis {
00013     class selectClause;
00014     class whereClause;
00015     class whereLexer;
00016     class whereParser;
00017 }
00018 
00077 class ibis::whereClause {
00078 public:
00080     explicit whereClause(const char *cl=0);
00082     whereClause(const whereClause&);
00084     ~whereClause();
00085 
00087     int parse(const char *cl);
00089     void setExpr(const ibis::qExpr *ex) {
00090         clause_.clear();
00091         delete expr_;
00092         expr_ = ex->dup();
00093     }
00095     void resetString() {
00096         if (expr_ != 0) {
00097             std::ostringstream oss;
00098             oss << *expr_;
00099             clause_ = oss.str();
00100         }
00101         else {
00102             clause_.clear();
00103         }
00104     }
00105 
00107     void clear() throw ();
00109     bool empty() const {return (expr_ == 0);}
00110 
00112     const char* getString(void) const {
00113         if (clause_.empty())
00114             return 0;
00115         else
00116             return clause_.c_str();
00117     }
00122     const ibis::qExpr* getExpr(void) const {return expr_;}
00127     ibis::qExpr* getExpr(void) {return expr_;}
00129     void simplify() {ibis::qExpr::simplify(expr_);}
00131     int verify(const ibis::part& p0, const ibis::selectClause *sel=0) const;
00132 
00134     ibis::qExpr* operator->() {return expr_;}
00136     const ibis::qExpr* operator->() const {return expr_;}
00137 
00139     whereClause& operator=(const whereClause&);
00141     void swap(whereClause& rhs) throw () {
00142         clause_.swap(rhs.clause_);
00143         ibis::qExpr* tmp = rhs.expr_;
00144         rhs.expr_ = expr_;
00145         expr_ = tmp;
00146     }
00147 
00148     static int verifyExpr(const ibis::qExpr*, const ibis::part&,
00149                           const ibis::selectClause *);
00150     static int verifyExpr(ibis::qExpr*&, const ibis::part&,
00151                           const ibis::selectClause *);
00152     static int removeAlias(ibis::qContinuousRange*&, const ibis::column*);
00153 
00154 protected:
00155     std::string clause_;        
00156     ibis::qExpr *expr_;         
00157 
00158     void amplify(const ibis::part&);
00159 
00160 private:
00161     ibis::whereLexer *lexer;    // hold a pointer for the parser
00162 
00163     friend class ibis::whereParser;
00164 }; // class ibis::whereClause
00165 
00166 namespace std {
00167     inline ostream& operator<<(ostream& out, const ibis::whereClause& wc) {
00168         wc->print(out);
00169         return out;
00170     } // std::operator<<
00171 }
00172 #endif

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive