Пример #1
0
int main(int argc, char **argv) {
	int c;
	std::string fname("");
	while ((c = getopt(argc, argv, "hf:")) != -1) {
		switch (c) {
		default:
		case 'h':	usage(); return 0; break;
		case 'f':	fname = optarg;	break;
		}
	}
	if (optind != argc) return (usage());

	Project project;
	
	// Setup the plugins
	PluginLoader *loader = PluginLoader::s_getSystemLoader();
	log4cxx::PropertyConfigurator::configure("logger.conf");
	
	try {
		loader->loadDir("./plugins");
	} catch (IOException e) {
		std::cerr << "Error loading plugins: " << e.what() << std::endl;
		return 1;
	}
	
	// Load a file if it's been passed in
	if (fname.length() > 0) {
		try {
			project.load(fname);
		} catch (const std::exception &e) {
			std::cerr << "error opening file: " << fname << std::endl;
			std::cerr << e.what() << std::endl;
		}
	}

	std::cout << "Press the 'X' key to exit the application" << std::endl;

	char ch;
	while ((ch = std::cin.get()) != 'x' && ch != 'X') {}
	
	try {
		loader->unloadAll();
	} catch (IOException e) {
		std::cerr << "Error unloading plugins: " << e.what() << std::endl;
		return 1;
	}
	return 0;
}