Skip to content

Commit

Permalink
Implemented parsing of attribute exprtk. For issue #23.
Browse files Browse the repository at this point in the history
  • Loading branch information
end2endzone committed Sep 15, 2020
1 parent cb6b893 commit f7ecf2c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/ObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 0 additions & 6 deletions src/libEval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ namespace shellanything
typedef exprtk::expression<double> expression_t;
typedef exprtk::parser<double> 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))
Expand Down
4 changes: 3 additions & 1 deletion test/TestObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <visibility> tag properly parsed
static const std::string expected_property = "bar";
Expand All @@ -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() );
Expand All @@ -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 << "'.";
Expand Down
8 changes: 8 additions & 0 deletions test/test_files/TestObjectFactory.testParseValidator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,13 @@
</actions>
</menu>

<menu name="menu10">
<!-- exprtk attribute is set -->
<visibility exprtk="2>1" />
<actions>
<property name="baz" value="true" />
</actions>
</menu>

</shell>
</root>

0 comments on commit f7ecf2c

Please sign in to comment.