SemOpt  0.2alpha2-SCC
misc.cpp
Go to the documentation of this file.
1 
8 #include "semopt.h"
9 
15 bool fexists(const char *filename)
16 {
17  if (ifstream(filename))
18  return true;
19  else
20  return false;
21 }
22 
23 bool parse_solution_aspartix(set<set<string> > *preferred, const char *file)
24 {
25  ifstream infile;
26  infile.open(file);
27  if (infile.good() == false)
28  return false;
29 
30  string inLine;
31  while (getline(infile, inLine))
32  {
33  int start = 0;
34  int pos = 0;
35  set<string> sol_asp = set<string>();
36 
37  while (((int) (pos = inLine.find("in(", start))) != ((int) string::npos))
38  {
39  string arg = inLine.substr(pos + 3,
40  inLine.find(")", pos + 3) - (pos + 3));
41  sol_asp.insert(arg);
42  start = pos + 4;
43  }
44  (*preferred).insert(sol_asp);
45  }
46  set<set<string> >::iterator it;
47  for (it = preferred->begin(); it != preferred->end(); it++)
48  {
49  set<string>::iterator inner;
50  cout << "{";
51  for (inner = (*it).begin(); inner != (*it).end(); inner++)
52  {
53  cout << (*inner) << " ";
54  }
55  cout << "}" << endl;
56  }
57  return true;
58 }