diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 969fe41ce..390cefc34 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1139,7 +1139,7 @@ void Application::initTypes(void) App ::ConditionalExpression ::init(); App ::StringExpression ::init(); App ::FunctionExpression ::init(); - + App ::BooleanExpression ::init(); } void Application::initConfig(int argc, char ** argv) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index 0c7ace3ef..93d573f5f 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -1262,6 +1262,18 @@ Expression *ConstantExpression::copy() const return new ConstantExpression(owner, name.c_str(), quantity); } +TYPESYSTEM_SOURCE_ABSTRACT(App::BooleanExpression, App::NumberExpression); + +BooleanExpression::BooleanExpression(const DocumentObject *_owner, bool _value) + : NumberExpression(owner, _value ? 1.0 : 0.0) +{ +} + +Expression *BooleanExpression::copy() const +{ + return new BooleanExpression(owner, getValue() > 0.5 ? true : false); +} + namespace App { namespace ExpressionParser { diff --git a/src/App/Expression.h b/src/App/Expression.h index e20ea4d9c..5831cd64a 100644 --- a/src/App/Expression.h +++ b/src/App/Expression.h @@ -190,6 +190,15 @@ protected: std::string name; /**< Constant's name */ }; +class AppExport BooleanExpression : public NumberExpression { + TYPESYSTEM_HEADER(); +public: + BooleanExpression(const App::DocumentObject *_owner = 0, bool _value = false); + + virtual Expression * copy() const; + +}; + /** * Class implementing an infix expression.