1 /* Query - query parsing and evaluation
3 * Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de.
4 * This file may be used under the terms of the MIT License.
6 * Adjusted by Ingo Weinhold <bonefish@cs.tu-berlin.de> for usage in RAM FS.
13 #include <SupportDefs.h>
15 #include <util/DoublyLinkedList.h>
30 #define B_QUERY_NON_INDEXED 0x00000002
33 // Wraps the RAM FS Index to provide the interface required by the Query
34 // implementation. At least most of it.
39 IndexWrapper(Volume
*volume
);
41 status_t
SetTo(const char *name
);
45 off_t
GetSize() const;
46 int32
KeySize() const;
49 friend class IndexIterator
;
58 IndexIterator(IndexWrapper
*indexWrapper
);
60 status_t
Find(const uint8
*const key
, size_t keyLength
);
62 status_t
GetNextEntry(uint8
*buffer
, uint16
*keyLength
, size_t bufferSize
,
66 IndexWrapper
*fIndexWrapper
;
67 IndexEntryIterator fIterator
;
74 Expression(char *expr
);
78 const char *Position() const { return fPosition
; }
79 Term
*Root() const { return fTerm
; }
82 Term
*ParseOr(char **expr
);
83 Term
*ParseAnd(char **expr
);
84 Term
*ParseEquation(char **expr
);
86 bool IsOperator(char **expr
,char op
);
89 Expression(const Expression
&);
90 Expression
&operator=(const Expression
&);
97 class Query
: public DoublyLinkedListLinkImpl
<Query
> {
99 Query(Volume
*volume
, Expression
*expression
, uint32 flags
);
103 status_t
GetNextEntry(struct dirent
*, size_t size
);
105 void SetLiveMode(port_id port
, int32 token
);
106 void LiveUpdate(Entry
*entry
, Node
* node
, const char *attribute
,
107 int32 type
, const uint8
*oldKey
, size_t oldLength
,
108 const uint8
*newKey
, size_t newLength
);
110 Expression
*GetExpression() const { return fExpression
; }
113 // void SendNotification(Entry* entry)
117 Expression
*fExpression
;
119 IndexIterator
*fIterator
;
121 Stack
<Equation
*> fStack
;