Start hacking on a C(++) implementation of the optimizer
[evolve-layout.git] / C / recheck_layouts.cpp
blob453c70fe62142a0d6d54da4e4995e6386f1c9632
1 #include <string>
2 #include <list>
3 #include <iostream>
5 #include "Layout.cpp"
6 #include "File.cpp"
8 using namespace std;
10 typedef list<Layout> layoutlist;
12 // return a list of all layouts in the file
13 // TODO better memory management
14 layoutlist getAllLayouts(const string &file) {
15 layoutlist l;
16 File f(file);
17 string line;
19 while(f.stream().good()) {
20 getline(f.stream(), line);
21 if(line == "# Evolved Layout ") {
22 Layout layout;
23 int lines = 3;
24 while(lines-- && f.stream().good()) {
25 getline(f.stream(), line);
26 layout.addLine(line);
28 l.push_back(layout);
32 return l;
36 // TODO implement
37 layoutlist getAllLayoutsInTextFilesIn(const string &folder = "results") {
38 throw new string("Not Implemented");
39 layoutlist l;
40 return l;
43 int main(int argc, char **argv) {
44 // check options
45 if(argc < 2) {
46 cerr << "Usage: " << argv[0] << " <filename>" << endl;
47 return 1;
50 string file(argv[1]);
51 layoutlist l = getAllLayouts(file);
53 // debugging output
54 for(layoutlist::const_iterator it = l.begin();
55 it != l.end(); ++it) {
56 cout << "Evolved: " << endl << it->toString() << endl;
59 return 0;