optional<CryConfigFile> CryConfigLoader::loadOrCreate(const bf::path &filename) { if (bf::exists(filename)) { return _loadConfig(filename); } else { return _createConfig(filename); } }
void MainWindow::_launchRenderer() { _loadConfig(); Integrator* integrator = _ui->renderer->integrator(); if (!integrator || integrator->type() != config->integrator()) { _ui->renderer->setIntegrator(Integrator::instanciateIntegrator(config->integrator())); } _ui->renderer->render(); }
bool NCUtils::writeConfig( const QString &filename, const QString &group, const QString &option, const QString &value ) { /************** reads configuration file **************/ QStringList list; QString retVal; int groupfoundLine = -1; int optfoundLine = -1; if ( !QFile::exists( filename ) ) { //not exists, create new. //groupfoundLine = 0; //optfoundLine = 0; } else { if ( !_loadConfig( filename, list, group, option, groupfoundLine, optfoundLine ) ) return false; } if ( optfoundLine < 0 ) { // option not found, we need inser as new line if ( groupfoundLine < 0 ) { // group not found also. list += "[" + group + "]"; list += option + " = " + value; } else { // group exists //QStringList::Iterator it = list.at( groupfoundLine ); list.insert( groupfoundLine, option + " = " + value ); } } else { // option found list.insert( optfoundLine, option + " = " + value ); /* QStringList::Iterator it = list.at( optfoundLine ); if ( it != list.end() ) { it = list.remove( it ); //remove line if ( it != list.end() ) list.insert( it, option + " = " + value ); else // we were at end of file. list += option + " = " + value; // append file; } else return false; */ } return _saveConfig( filename, list ); }
QString NCUtils::readConfig( const QString &filename, const QString &group, const QString &option ) { /************** reads configuration file **************/ //#ifdef NCAPP_DEBUGMODE //qDebug( "NCUtils::readConfig( %s, %s, %s )", filename.latin1(), group.latin1(), option.latin1() ); //#endif QStringList list; QString retVal; int groupfoundLine = -1; int optfoundLine = -1; if ( !_loadConfig( filename, list, group, option, groupfoundLine, optfoundLine ) ) return ""; if ( optfoundLine < 0 ) // option not found return ""; //QStringList::const_iterator it = list.at( optfoundLine ); retVal = list.at( optfoundLine ); int eTokenPos = -1; //if ( it != list.end() ) { if ( !retVal.isEmpty() ) { //retVal = *it; // option line eTokenPos = retVal.indexOf("="); if ( eTokenPos < 0 ) retVal = ""; else retVal = retVal.mid( eTokenPos+1 ).trimmed(); // everything after "=" token } else retVal = ""; return retVal; }
RSConfig::RSConfig() { _loadConfig(); }
void RSConfig::reload() { arguments.clear(); _loadConfig(); }
bool Utils::_init() { if (!_loadConfig("config/global_setting.json", m_docGlobalSetting, m_globalSettingMap, m_bGlobalSettingLoaded)) return false; if (!_loadConfig("config/text.json", m_docText, m_textMap, m_bTextLoaded)) return false; return true; }