#include <iostream>
#include "eden.pb.h"
#include <fstream>
#include <sstream>
#include <string>
#include "google/protobuf/text_format.h"

using namespace std;

int main(){
  cout << "Hello!" << endl;
  eden::pigs Pigs;
  Pigs.set_count(10);
  string str;
  cout << "0" << endl;
  google::protobuf::TextFormat::PrintToString(Pigs, &str);
  cout << str << endl;

  // fstream input("../pigs.pt", ios::in | ios::binary);
  // if (!input) {
  //   cout << "pigs.pt" << ": File not found.  Creating a new file." << endl;
  // } else if (!Pigs->ParseFromIstream(&input)) {
  //   cerr << "Failed to parse pigs." << endl;
  // }
 
  cout << "1" << endl;
  std::ostringstream conf_ss;
  conf_ss << std::ifstream("../pigs.pt").rdbuf();
  cout << "2" << endl;
  google::protobuf::TextFormat::ParseFromString(conf_ss.str(), &Pigs);
  cout << "3" << endl;
  cout << Pigs.count() << ", " << Pigs.sight() << ", " << endl;

  return 0;
}
