SemOpt  0.2alpha2-SCC
OrClause.cpp
Go to the documentation of this file.
1 
11 #include "OrClause.h"
12 
19 {
20  this->clause = vector<Variable>();
21 }
22 
29 OrClause::OrClause(int count, ...)
30 {
31  va_list ap;
32  va_start(ap, count);
33  this->clause = vector<Variable>();
34  for (int i = 0; i < count; i++)
35  {
36  this->clause.push_back(va_arg(ap, Variable));
37  }
38  va_end(ap);
39 }
40 
47 {
48  (this->clause).push_back(x);
49 }
50 
57 {
58  this->clause.insert(this->clause.begin(), x);
59 }
60 
68 void OrClause::toSS(stringstream *ss) const
69 {
70  if ((int) this->clause.size() != 0)
71  {
72  string sep = " ";
73  string endcl = "0";
74  for (int i = 0; i < (int) this->clause.size(); i++)
75  (*ss) << this->clause.at(i) << sep;
76  (*ss) << endcl;
77  }
78 }
79 
87 void OrClause::clone(OrClause *newclause)
88 {
89  (*newclause) = OrClause();
90  for (int i = 0; i < (int) this->clause.size(); i++)
91  (*newclause).appendVariable(this->clause.at(i));
92 }
93 
94 ostream& operator<<(ostream& out, const OrClause& r)
95 {
96  stringstream ss(stringstream::in | stringstream::out);
97  r.toSS(&ss);
98  out << ss.str();
99  return out;
100 }
101 
102 OrClause::~OrClause()
103 {
104 }
105