summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp')
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
index c92274c..2e37b29 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
@@ -264,13 +264,17 @@ void SWIDataModel::eval(const std::string& expr) {
}
bool SWIDataModel::evalAsBool(const std::string& expr) {
- PlCompound compound(expr.c_str());
- PlTermv termv(compound.arity());
- for (int i = 0; i < compound.arity(); i++) {
- termv[i] = compound[i + 1];
+ try {
+ PlCompound compound(expr.c_str());
+ PlTermv termv(compound.arity());
+ for (int i = 0; i < compound.arity(); i++) {
+ termv[i] = compound[i + 1];
+ }
+ PlQuery query(compound.name(), termv);
+ return query.next_solution() > 0;
+ } catch(...) {
+ return false;
}
- PlQuery query(compound.name(), termv);
- return query.next_solution() > 0;
}
std::string SWIDataModel::evalAsString(const std::string& expr) {