1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
4 //---------------------------------------------------------------------
7 BQuery predicate helper classes interface declaration.
9 #ifndef _QUERY_PREDICATE_H
10 #define _QUERY_PREDICATE_H
27 virtual uint32
Arity() const = 0;
28 virtual status_t
SetChildAt(QueryNode
*child
, int32 index
) = 0;
29 virtual QueryNode
*ChildAt(int32 index
) = 0;
31 virtual status_t
GetString(BString
&predicate
) = 0;
35 class LeafNode
: public QueryNode
{
40 virtual uint32
Arity() const;
41 virtual status_t
SetChildAt(QueryNode
*child
, int32 index
);
42 virtual QueryNode
*ChildAt(int32 index
);
46 class UnaryNode
: public QueryNode
{
51 virtual uint32
Arity() const;
52 virtual status_t
SetChildAt(QueryNode
*child
, int32 index
);
53 virtual QueryNode
*ChildAt(int32 index
);
60 class BinaryNode
: public QueryNode
{
63 virtual ~BinaryNode();
65 virtual uint32
Arity() const;
66 virtual status_t
SetChildAt(QueryNode
*child
, int32 index
);
67 virtual QueryNode
*ChildAt(int32 index
);
75 class AttributeNode
: public LeafNode
{
77 AttributeNode(const char *attribute
);
79 virtual status_t
GetString(BString
&predicate
);
86 class StringNode
: public LeafNode
{
88 StringNode(const char *value
, bool caseInsensitive
= false);
90 virtual status_t
GetString(BString
&predicate
);
92 inline const char *Value() const { return fValue
.String(); }
99 class DateNode
: public LeafNode
{
101 DateNode(const char *value
);
103 virtual status_t
GetString(BString
&predicate
);
110 template<typename ValueType
>
111 class ValueNode
: public LeafNode
{
113 ValueNode(const ValueType
&value
);
115 virtual status_t
GetString(BString
&predicate
);
122 template<typename ValueType
>
123 ValueNode
<ValueType
>::ValueNode(const ValueType
&value
)
130 template<typename ValueType
>
132 ValueNode
<ValueType
>::GetString(BString
&predicate
)
139 // specializations for float and double
140 template<> status_t ValueNode
<float>::GetString(BString
&predicate
);
141 template<> status_t ValueNode
<double>::GetString(BString
&predicate
);
145 typedef ValueNode
<int32
> Int32ValueNode
;
146 typedef ValueNode
<uint32
> UInt32ValueNode
;
147 typedef ValueNode
<int64
> Int64ValueNode
;
148 typedef ValueNode
<uint64
> UInt64ValueNode
;
149 typedef ValueNode
<float> FloatValueNode
;
150 typedef ValueNode
<double> DoubleValueNode
;
154 class SpecialOpNode
: public LeafNode
{
156 SpecialOpNode(query_op op
);
158 virtual status_t
GetString(BString
&predicate
);
165 class UnaryOpNode
: public UnaryNode
{
167 UnaryOpNode(query_op op
);
169 virtual status_t
GetString(BString
&predicate
);
176 class BinaryOpNode
: public BinaryNode
{
178 BinaryOpNode(query_op op
);
180 virtual status_t
GetString(BString
&predicate
);
191 virtual ~QueryStack();
193 status_t
PushNode(QueryNode
*node
);
194 QueryNode
*PopNode();
196 status_t
ConvertToTree(QueryNode
*&rootNode
);
199 status_t
_GetSubTree(QueryNode
*&rootNode
);
205 }; // namespace Storage
206 }; // namespace BPrivate
208 #endif // _QUERY_PREDICATE_H