From f7ecf2c3c46583a2439926002203fbb09d3631e1 Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 15 Sep 2020 19:12:45 -0400 Subject: [PATCH] Implemented parsing of attribute `exprtk`. For issue #23. --- src/ObjectFactory.cpp | 10 ++++++++++ src/libEval.cpp | 6 ------ test/TestObjectFactory.cpp | 4 +++- .../TestObjectFactory.testParseValidator.xml | 8 ++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ObjectFactory.cpp b/src/ObjectFactory.cpp index e66a0a44..c1177d10 100644 --- a/src/ObjectFactory.cpp +++ b/src/ObjectFactory.cpp @@ -179,6 +179,16 @@ namespace shellanything } } + //parse exprtk + std::string exprtk; + if (ParseAttribute(element, "exprtk", true, true, exprtk, error)) + { + if (!exprtk.empty()) + { + result.SetExprtk(exprtk); + } + } + //parse maxfiles int maxfiles = -1; if (ParseAttribute(element, "maxfiles", true, true, maxfiles, error)) diff --git a/src/libEval.cpp b/src/libEval.cpp index 2fe45ee6..7487b95d 100644 --- a/src/libEval.cpp +++ b/src/libEval.cpp @@ -35,13 +35,7 @@ namespace shellanything typedef exprtk::expression expression_t; typedef exprtk::parser parser_t; - //symbol_table_t symbol_table; - //symbol_table.add_variable("x",x); - //symbol_table.add_variable("y",y); - //symbol_table.add_variable("z",z); - expression_t expression; - parser_t parser; if (!parser.compile(expression_string,expression)) diff --git a/test/TestObjectFactory.cpp b/test/TestObjectFactory.cpp index 182268a0..8f87e592 100644 --- a/test/TestObjectFactory.cpp +++ b/test/TestObjectFactory.cpp @@ -152,7 +152,7 @@ namespace shellanything { namespace test //ASSERT all menus are available Menu::MenuPtrList menus = cmgr.GetConfigurations()[0]->GetMenus(); - ASSERT_EQ( 10, menus.size() ); + ASSERT_EQ( 11, menus.size() ); //assert tag properly parsed static const std::string expected_property = "bar"; @@ -164,6 +164,7 @@ namespace shellanything { namespace test static const std::string expected_inverse_unknown = "foo"; static const std::string expected_class = "file"; static const std::string expected_pattern = "*IMG_*"; + static const std::string expected_exprtk = "2>1"; ASSERT_EQ( expected_property, menus[0]->GetVisibility().GetProperties() ); ASSERT_EQ( 5, menus[1]->GetVisibility().GetMaxFiles() ); @@ -176,6 +177,7 @@ namespace shellanything { namespace test ASSERT_EQ( expected_inverse_unknown, menus[7]->GetVisibility().GetInserve() ); ASSERT_EQ( expected_class, menus[8]->GetVisibility().GetClass() ); ASSERT_EQ( expected_pattern, menus[9]->GetVisibility().GetPattern() ); + ASSERT_EQ( expected_exprtk, menus[10]->GetVisibility().GetExprtk() ); //cleanup ASSERT_TRUE( ra::filesystem::DeleteFile(template_target_path.c_str()) ) << "Failed deleting file '" << template_target_path << "'."; diff --git a/test/test_files/TestObjectFactory.testParseValidator.xml b/test/test_files/TestObjectFactory.testParseValidator.xml index d845318b..3a2e79bc 100644 --- a/test/test_files/TestObjectFactory.testParseValidator.xml +++ b/test/test_files/TestObjectFactory.testParseValidator.xml @@ -81,5 +81,13 @@ + + + + + + + +