diff --git a/Common.vcxproj b/Common.vcxproj index d5daff0..91f2842 100644 --- a/Common.vcxproj +++ b/Common.vcxproj @@ -182,6 +182,7 @@ + @@ -230,6 +231,7 @@ + diff --git a/Common.vcxproj.filters b/Common.vcxproj.filters index 690105f..38f7b2b 100644 --- a/Common.vcxproj.filters +++ b/Common.vcxproj.filters @@ -141,6 +141,9 @@ filters\loudnessCorrection + + parser + @@ -267,6 +270,9 @@ filters\loudnessCorrection + + parser + diff --git a/Editor/Editor.pro b/Editor/Editor.pro index 8330019..514cd8c 100644 --- a/Editor/Editor.pro +++ b/Editor/Editor.pro @@ -21,6 +21,7 @@ SOURCES += main.cpp\ ../helpers/LogHelper.cpp \ ../helpers/StringHelper.cpp \ ../helpers/RegistryHelper.cpp \ + ../parser/LogicalOperators.cpp \ IFilterGUIFactory.cpp \ IFilterGUI.cpp \ guis/PreampFilterGUI.cpp \ @@ -139,6 +140,7 @@ HEADERS += \ ../helpers/LogHelper.h \ ../helpers/StringHelper.h \ ../helpers/RegistryHelper.h \ + ../parser/LogicalOperators.h \ IFilterGUIFactory.h \ stable.h \ IFilterGUI.h \ diff --git a/filters/ExpressionFilterFactory.cpp b/filters/ExpressionFilterFactory.cpp index 2725282..815e24a 100644 --- a/filters/ExpressionFilterFactory.cpp +++ b/filters/ExpressionFilterFactory.cpp @@ -25,6 +25,7 @@ #include "parser/RegexFunctions.h" #include "parser/RegistryFunctions.h" #include "parser/StringOperators.h" +#include "parser/LogicalOperators.h" #include "FilterEngine.h" #include "ExpressionFilterFactory.h" @@ -45,6 +46,7 @@ void ExpressionFilterFactory::initialize(FilterEngine* engine) parser->RemoveOprt(L"+"); parser->DefineOprt(new AddOperator()); + parser->DefineInfixOprt(new NotOperator()); } vector ExpressionFilterFactory::createFilter(const wstring& configPath, wstring& command, wstring& parameters) diff --git a/parser/LogicalOperators.cpp b/parser/LogicalOperators.cpp new file mode 100644 index 0000000..e321e3d --- /dev/null +++ b/parser/LogicalOperators.cpp @@ -0,0 +1,44 @@ +/* + This file is part of Equalizer APO, a system-wide equalizer. + Copyright (C) 2019 Jonas Thedering + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "stdafx.h" +#include "LogicalOperators.h" + +using namespace std; +using namespace mup; + +NotOperator::NotOperator() + : IOprtInfix(L"not", prINFIX) +{} + +void NotOperator::Eval(ptr_val_type& ret, const ptr_val_type* arg, int argc) +{ + assert(argc == 1); + *ret = !arg[0]->GetBool(); +} + +const char_type* NotOperator::GetDesc() const +{ + return L"logical not"; +} + +IToken* NotOperator::Clone() const +{ + return new NotOperator(*this); +} diff --git a/parser/LogicalOperators.h b/parser/LogicalOperators.h new file mode 100644 index 0000000..bd025b2 --- /dev/null +++ b/parser/LogicalOperators.h @@ -0,0 +1,32 @@ +/* + This file is part of Equalizer APO, a system-wide equalizer. + Copyright (C) 2019 Jonas Thedering + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +#include +#include + +class NotOperator : public mup::IOprtInfix +{ +public: + NotOperator(); + void Eval(mup::ptr_val_type& ret, const mup::ptr_val_type* arg, int argc) override; + const mup::char_type* GetDesc() const; + mup::IToken* Clone() const override; +};