Skip to content

Commit f7ecf2c

Browse files
committed
Implemented parsing of attribute exprtk. For issue #23.
1 parent cb6b893 commit f7ecf2c

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

src/ObjectFactory.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ namespace shellanything
179179
}
180180
}
181181

182+
//parse exprtk
183+
std::string exprtk;
184+
if (ParseAttribute(element, "exprtk", true, true, exprtk, error))
185+
{
186+
if (!exprtk.empty())
187+
{
188+
result.SetExprtk(exprtk);
189+
}
190+
}
191+
182192
//parse maxfiles
183193
int maxfiles = -1;
184194
if (ParseAttribute(element, "maxfiles", true, true, maxfiles, error))

src/libEval.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ namespace shellanything
3535
typedef exprtk::expression<double> expression_t;
3636
typedef exprtk::parser<double> parser_t;
3737

38-
//symbol_table_t symbol_table;
39-
//symbol_table.add_variable("x",x);
40-
//symbol_table.add_variable("y",y);
41-
//symbol_table.add_variable("z",z);
42-
4338
expression_t expression;
44-
4539
parser_t parser;
4640

4741
if (!parser.compile(expression_string,expression))

test/TestObjectFactory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ namespace shellanything { namespace test
152152

153153
//ASSERT all menus are available
154154
Menu::MenuPtrList menus = cmgr.GetConfigurations()[0]->GetMenus();
155-
ASSERT_EQ( 10, menus.size() );
155+
ASSERT_EQ( 11, menus.size() );
156156

157157
//assert <visibility> tag properly parsed
158158
static const std::string expected_property = "bar";
@@ -164,6 +164,7 @@ namespace shellanything { namespace test
164164
static const std::string expected_inverse_unknown = "foo";
165165
static const std::string expected_class = "file";
166166
static const std::string expected_pattern = "*IMG_*";
167+
static const std::string expected_exprtk = "2>1";
167168

168169
ASSERT_EQ( expected_property, menus[0]->GetVisibility().GetProperties() );
169170
ASSERT_EQ( 5, menus[1]->GetVisibility().GetMaxFiles() );
@@ -176,6 +177,7 @@ namespace shellanything { namespace test
176177
ASSERT_EQ( expected_inverse_unknown, menus[7]->GetVisibility().GetInserve() );
177178
ASSERT_EQ( expected_class, menus[8]->GetVisibility().GetClass() );
178179
ASSERT_EQ( expected_pattern, menus[9]->GetVisibility().GetPattern() );
180+
ASSERT_EQ( expected_exprtk, menus[10]->GetVisibility().GetExprtk() );
179181

180182
//cleanup
181183
ASSERT_TRUE( ra::filesystem::DeleteFile(template_target_path.c_str()) ) << "Failed deleting file '" << template_target_path << "'.";

test/test_files/TestObjectFactory.testParseValidator.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,13 @@
8181
</actions>
8282
</menu>
8383

84+
<menu name="menu10">
85+
<!-- exprtk attribute is set -->
86+
<visibility exprtk="2>1" />
87+
<actions>
88+
<property name="baz" value="true" />
89+
</actions>
90+
</menu>
91+
8492
</shell>
8593
</root>

0 commit comments

Comments
 (0)