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