示例#1
0
void App::readConfig()
{
	string configFileName = config()->get(CPPAPP_CONFIG_FILE_CFG_KEY,
								   getDefaultConfigFile())->asString();
	
	Ref<FileInput> configInput = new FileInput(configFileName);
	if (!configInput->exists()) {
		LOG_WARNING("Configuration file " << configFileName << " does not exist.");
		return;
	}
	
	JSONParser parser;
	config_ = parser.parse(configInput);
	configInput->close();
	
	if (config_->isError()) {
		Ref<DynError> err = config_.as<DynError>();
		LOG_ERROR("Syntax error in config file at " << err->getErrorLoc() << ": " << err->getString());
		exit(1);
	}
	
	//Ref<PrettyPrinter> printer = new PrettyPrinter();
	//config_->print(printer);
	//printer->print("\n");
	
	// Override the configuration read from the file by the command line
	// options.
	options().setConfigKeys(config_);
}
示例#2
0
UString ConfigManager::getConfigFile() const {
	if (!_configFile.empty())
		return _configFile;

	return getDefaultConfigFile();
}