Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / headers / os / storage / Query.h
blobfff4c7522dd2db285ce6937a8e09ec9de9e94e6c
1 /*
2 * Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _QUERY_H
6 #define _QUERY_H
9 #include <EntryList.h>
10 #include <Messenger.h>
11 #include <OS.h>
13 class BVolume;
14 struct entry_ref;
17 namespace BPrivate {
18 namespace Storage {
19 class QueryNode;
20 class QueryStack;
21 class QueryTree;
25 typedef enum {
26 B_INVALID_OP = 0,
27 B_EQ,
28 B_GT,
29 B_GE,
30 B_LT,
31 B_LE,
32 B_NE,
33 B_CONTAINS,
34 B_BEGINS_WITH,
35 B_ENDS_WITH,
36 B_AND = 0x101,
37 B_OR,
38 B_NOT,
39 _B_RESERVED_OP_ = 0x100000
40 } query_op;
43 class BQuery : public BEntryList {
44 public:
45 BQuery();
46 virtual ~BQuery();
48 status_t Clear();
50 status_t PushAttr(const char* attrName);
51 status_t PushOp(query_op op);
53 status_t PushUInt32(uint32 value);
54 status_t PushInt32(int32 value);
55 status_t PushUInt64(uint64 value);
56 status_t PushInt64(int64 value);
57 status_t PushFloat(float value);
58 status_t PushDouble(double value);
59 status_t PushString(const char* value,
60 bool caseInsensitive = false);
61 status_t PushDate(const char* date);
63 status_t SetVolume(const BVolume* volume);
64 status_t SetPredicate(const char* expression);
65 status_t SetTarget(BMessenger messenger);
67 bool IsLive() const;
69 status_t GetPredicate(char* buffer, size_t length);
70 status_t GetPredicate(BString* predicate);
71 size_t PredicateLength();
73 dev_t TargetDevice() const;
75 status_t Fetch();
77 // BEntryList interface
78 virtual status_t GetNextEntry(BEntry* entry, bool traverse = false);
79 virtual status_t GetNextRef(entry_ref* ref);
80 virtual int32 GetNextDirents(struct dirent* buffer, size_t length,
81 int32 count = INT_MAX);
82 virtual status_t Rewind();
83 virtual int32 CountEntries();
85 private:
86 bool _HasFetched() const;
87 status_t _PushNode(BPrivate::Storage::QueryNode* node,
88 bool deleteOnError);
89 status_t _SetPredicate(const char* expression);
90 status_t _EvaluateStack();
91 void _ParseDates(BString& parsedPredicate);
93 // FBC
94 virtual void _QwertyQuery1();
95 virtual void _QwertyQuery2();
96 virtual void _QwertyQuery3();
97 virtual void _QwertyQuery4();
98 virtual void _QwertyQuery5();
99 virtual void _QwertyQuery6();
101 private:
102 BPrivate::Storage::QueryStack* fStack;
103 char* fPredicate;
104 dev_t fDevice;
105 bool fLive;
106 port_id fPort;
107 long fToken;
108 int fQueryFd;
109 int32 _reservedData[4];
112 #endif // _QUERY_H