How to implement a expression builder in C++/QT which is similar to Microsoft TFS query builder?

298 Views Asked by At

In Microsoft TFS, there is a query builder as follow: enter image description here

And I'm requested to implement a feature just like TFS query builder in C++/QT. But I don't even know how to google it.

Basically, with this feature, user will be able to set the condition to execute a specific action when our app running. eg:

// the condition will be set by user before run this application
// and I want provide a UI similar to TFS query to user
if (var_a >= 0 && (var_b + var_c) < 10) 
{
   prompt the warning dialog
}

this condition (var_a >= 0 && (var_b + var_c) < 10) will be stored as xml as below:

<ConditionPair Operator="AND">
    <Condition Operator="GE">
        <LValue>
            <Kind>Variable</Kind>
            <Value>var_a</Value>
        </LValue>
        <RValue>
            <Kind>Const</Kind>
            <Value>0</Value>
        </RValue>
    </Condition>
    <Condition Operator="LT">
        <LValue>
            <Kind>Expression</Kind>
            <Value>
                <MathExp Operator="ADD">
                    <LValue>
                        <Kind>Variable</Kind>
                        <Value>var_b</Value>
                    </LValue>
                    <RValue>
                        <Kind>Variable</Kind>
                        <Value>var_c</Value>
                    </RValue>
                </MathExp>
            </Value>
        </LValue>
        <RValue>
            <Kind>Const</Kind>
            <Value>10</Value>
        </RValue>
    </Condition>
</ConditionPair>

I know how to implement the UI, but I DO NOT know how to interpret the expression.

Is there any open source library or blog about this topic available online?

Any thoughts about this is appreciated.

1

There are 1 best solutions below

0
On

I don't really know if I've understood you, but maybe you could use Qt Script to interpret (parse) the commands and then act.