Пример #1
0
	ConfigTable readConfig(std::string filename) {
		std::ifstream ifs("configs/" + filename);
		if (!ifs.is_open())
		{
			std::cerr << "can't open file: " << filename << std::endl;
			return ConfigTable();
		}
		std::cout << "read config:" << filename << std::endl;

		std::string line;
		ConfigTable configTable;
		while (ifs >> line)
		{
			std::vector<std::string> v = Util::split(line, ":");
			if (v.size() != 2)
			{
				std::cerr << "invalid config status" << std::endl;
				continue;
			}
			configTable[v[0]] = v[1];
		}
		return configTable;
	}
Пример #2
0
GraphObject::GraphObject(const string& fname) {
  /* Check configuration file. */
  cfg = ConfigTable(fname, '\0');
  if(cfg.size() < 1) {
    cout << "WARNING! Configuration file '" << cfg.source()
	 << "' is empty or cannot be opened.\n";
    return;
  }

  /* Load data from input file(s). */
  if(cfg["VerboseMode"][1] != "off") print_greeting(0);
  if(!check_parameters(cfg)) {
    cerr << "ERROR! Erroneous instructions found.\n";
    print_checklist();
  }  
  else if(!configure()) {
    cerr << "ERROR! Configuration failed.\n";
    print_checklist();
  }
  else if(!import()) {
    cerr << "ERROR! Import failed.\n";
    print_checklist();
  }
}