1 #ifndef QUERY_H 2 #define QUERY_H 3 /* Query - query parsing and evaluation 4 ** 5 ** Initial version by Axel Dörfler, axeld@pinc-software.de 6 ** This file may be used under the terms of the OpenBeOS License. 7 */ 8 9 10 #include <SupportDefs.h> 11 12 #include "Index.h" 13 #include "Stack.h" 14 #include "Chain.h" 15 16 class Volume; 17 class Term; 18 class Equation; 19 class TreeIterator; 20 class Query; 21 22 23 class Expression { 24 public: 25 Expression(char *expr); 26 ~Expression(); 27 28 status_t InitCheck(); 29 const char *Position() const { return fPosition; } 30 Term *Root() const { return fTerm; } 31 32 protected: 33 Term *ParseOr(char **expr); 34 Term *ParseAnd(char **expr); 35 Term *ParseEquation(char **expr); 36 37 bool IsOperator(char **expr,char op); 38 39 private: 40 Expression(const Expression &); 41 Expression &operator=(const Expression &); 42 // no implementation 43 44 char *fPosition; 45 Term *fTerm; 46 }; 47 48 class Query { 49 public: 50 Query(Volume *volume, Expression *expression, uint32 flags); 51 ~Query(); 52 53 status_t GetNextEntry(struct dirent *,size_t size); 54 55 void SetLiveMode(port_id port,int32 token); 56 void LiveUpdate(Inode *inode,const char *attribute,int32 type,const uint8 *oldKey,size_t oldLength,const uint8 *newKey,size_t newLength); 57 58 Expression *GetExpression() const { return fExpression; } 59 60 private: 61 Volume *fVolume; 62 Expression *fExpression; 63 Equation *fCurrent; 64 TreeIterator *fIterator; 65 Index fIndex; 66 Stack<Equation *> fStack; 67 68 uint32 fFlags; 69 port_id fPort; 70 int32 fToken; 71 72 private: 73 friend Chain<Query>; 74 Query *fNext; 75 }; 76 77 #endif /* QUERY_H */ 78