>This would be a wonderful improvement. So each leaf node would be a
>condition (i.e. a field name and a value), and each non-leaf node would
>be an operator (e.g. AND or OR). So far, this sounds good. Now how
>about adding operators like XOR. I could see that working, but in
>practice, XOR probably wouldn't be so useful... rather you might want a
>custom operator that says "return True iff exactly one of an entire
>group of conditions is true". I don't think it would be possible to
>implement this type of operator using a strictly binary tree... it would
>need to be a tree structure that allows for more than two child nodes.
>This would also make the internal representation more similar to the way
>it would be displayed in the GUI (where a binary tree would require a
>slightly different internal representation). If I'm not clear on this
>point, I can write up an example.
>
I think i have got it:
It is possible to extend expression types to include
an N peer boolean expression that contains a list of
expressions and applies the same operator to each.
Like a 'flatened' part of a binary tree:
'if (a | b | c | d)' instead of 'if (a | (b | (c | d)))'
(There are probably logical precedence rules to automatically
work out this sort of thing from a binary tree and group
leaf nodes. I bet its a one liner is lisp!).
Attached is some idl, does this 'express' a boolean
expression model for the GUI use cases you and
Matthew have 'expressed'?
Paul.
| ? + ? = To question
----------------\
Paul Sandoz
x19219
+353-1-8199219
// BooleanExpression type, marker for boolean expressions
//
interface nsIBooleanExpression
{
};
// Condition type, marker for conditions
//
// leaf node
//
interface nsIBooleanCondition : nsIBooleanExpression
{
};
// String match condition
//
interface nsIStringMatch : nsIBooleanCondition
{
.
.
.
};
interface nsIBooleanExpressionOperation : nsIBooleanExpression
{
attribute long operator;
};
// Unary node
//
interface nsIBooleanExpressionUnary : nsIBooleanExpressionOperation
{
attribute nsIBooleanExpression expression;
};
// Binary node
//
interface nsIBooleanExpressionBinary : nsIBooleanExpressionOperation
{
attribute nsIBooleanExpression leftHandExpression;
attribute nsIBooleanExpression rightHandExpression;
};
// NPeer node
//
interface nsIBooleanExpressionNPeer : nsIBooleanExpressionOperation
{
// nsISupportsArray<BooleanExpression>
//
attribute nsISupportsArray peerExpressions;
};