-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRule.cpp
More file actions
33 lines (26 loc) · 734 Bytes
/
Rule.cpp
File metadata and controls
33 lines (26 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Rule.h"
#include <sstream>
Rule::~Rule() {
delete headPredicate;
for (Predicate* predicate : bodyPredicates) {
delete predicate;
}
}
void Rule::AddHeadPredicate(Predicate* headPredicate) {
this->headPredicate = headPredicate;
}
void Rule::AddBodyPredicate(Predicate* bodyPredicate) {
bodyPredicates.push_back(bodyPredicate);
}
std::string Rule::ToString() {
std::stringstream ss;
ss << headPredicate->ToString() << " :- ";
for (Predicate* predicate : bodyPredicates) {
ss << predicate->ToString();
if (predicate != bodyPredicates.at(bodyPredicates.size() - 1)) {
ss << ",";
}
}
ss << ".";
return ss.str();
}