JNIEXPORT jlong JNICALL Java_blobseer_ObjectHandler_blob_1init(JNIEnv *env, jclass c, jstring jcfg) {
    jlong ret = 0;
    const char *cfg = env->GetStringUTFChars(jcfg, NULL);
    std::string cfg_file(cfg);
    env->ReleaseStringUTFChars(jcfg, cfg);
    try {
	object_handler *h = new object_handler(cfg_file);
	ret = (jlong)h;
    } catch (std::runtime_error &e) {
	ERROR(e.what());
    }
    return ret;
}
示例#2
0
void MHUD::Options::SaveCfgFile(std::string cfg_file_name, MHUD::Prefs new_prefs)
{
    // Update cache for the file if it exists
    if (cfg_files_.count(cfg_file_name) > 0)
    {
        cfg_files_[cfg_file_name] = new_prefs;
    }

    QSettings cfg_file(QString::fromStdString(cfg_file_name), QSettings::IniFormat);
    cfg_file.setValue("show_tears_fired", new_prefs.show_tears_fired);
    cfg_file.setValue("show_shot_height", new_prefs.show_shot_height);
    cfg_file.setValue("split_deal_chance", new_prefs.split_deal_chance);
    cfg_file.setValue("stat_precision", new_prefs.stat_precision);
}
   void LoadAConfigFile(std::string filename)
   {
      bool ALLOW_UNREGISTERED = true;

      po::options_description config_opts;
      config_opts.add(config_only_options).add(common_options);

      std::ifstream cfg_file(filename.c_str());
      if (cfg_file)
      {
         store(parse_config_file(cfg_file, config_opts, ALLOW_UNREGISTERED), results);
         notify(results);
      }
   }
示例#4
0
MHUD::Prefs MHUD::Options::ReadCfgFile(std::string cfg_file_name, bool use_cache)
{
    if (cfg_files_.count(cfg_file_name) > 0 && use_cache)
        return cfg_files_[cfg_file_name];

    // Read the preferences structure from the config file (if it exists)
    QSettings cfg_file(QString::fromStdString(cfg_file_name), QSettings::IniFormat);
    MHUD::Prefs cfg_prefs;
    cfg_prefs.show_tears_fired = cfg_file.value("show_tears_fired", false).toBool();
    cfg_prefs.show_shot_height = cfg_file.value("show_shot_height", false).toBool();
    cfg_prefs.split_deal_chance = cfg_file.value("split_deal_chance", true).toBool();
    cfg_prefs.stat_precision = cfg_file.value("stat_precision", 2).toInt();

    // Cache the result
    cfg_files_[cfg_file_name] = cfg_prefs;
    return cfg_prefs;
}
示例#5
0
void configManager::loadConfigFile()
{
	// read the XML file and create DOM tree
	QFile cfg_file( m_lmmsRcFile );
	QDomDocument dom_tree;

	if( cfg_file.open( QIODevice::ReadOnly ) )
	{
		QString errorString;
		int errorLine, errorCol;
		if( dom_tree.setContent( &cfg_file, false, &errorString, &errorLine, &errorCol ) )
		{
			// get the head information from the DOM
			QDomElement root = dom_tree.documentElement();

			QDomNode node = root.firstChild();

			// create the settings-map out of the DOM
			while( !node.isNull() )
			{
				if( node.isElement() &&
					node.toElement().hasAttributes () )
				{
					stringPairVector attr;
					QDomNamedNodeMap node_attr =
						node.toElement().attributes();
					for( int i = 0; i < node_attr.count();
									++i )
					{
		QDomNode n = node_attr.item( i );
		if( n.isAttr() )
		{
			attr.push_back( qMakePair( n.toAttr().name(),
							n.toAttr().value() ) );
		}
					}
					m_settings[node.nodeName()] = attr;
				}
				else if( node.nodeName() == "recentfiles" )
				{
					m_recentlyOpenedProjects.clear();
					QDomNode n = node.firstChild();
					while( !n.isNull() )
					{
		if( n.isElement() && n.toElement().hasAttributes() )
		{
			m_recentlyOpenedProjects <<
					n.toElement().attribute( "path" );
		}
		n = n.nextSibling();
					}
				}
				node = node.nextSibling();
			}

			if( value( "paths", "artwork" ) != "" )
			{
				m_artworkDir = value( "paths", "artwork" );
				if( !QDir( m_artworkDir ).exists() )
				{
					m_artworkDir = defaultArtworkDir();
				}
				if( m_artworkDir.right( 1 ) !=
							QDir::separator() )
				{
					m_artworkDir += QDir::separator();
				}
			}
			setWorkingDir( value( "paths", "workingdir" ) );
			setVSTDir( value( "paths", "vstdir" ) );
			setFLDir( value( "paths", "fldir" ) );
			setLADSPADir( value( "paths", "laddir" ) );
		#ifdef LMMS_HAVE_STK
			setSTKDir( value( "paths", "stkdir" ) );
		#endif
		#ifdef LMMS_HAVE_FLUIDSYNTH
			setDefaultSoundfont( value( "paths", "defaultsf2" ) );
		#endif
			setBackgroundArtwork( value( "paths", "backgroundartwork" ) );
		}
		else
		{
			QMessageBox::warning( NULL, MainWindow::tr( "Configuration file" ),
									MainWindow::tr( "Error while parsing configuration file at line %1:%2: %3" ).
													arg( errorLine ).
													arg( errorCol ).
													arg( errorString ) );
		}
		cfg_file.close();
	}


	if( m_vstDir.isEmpty() || m_vstDir == QDir::separator() ||
			!QDir( m_vstDir ).exists() )
	{
#ifdef LMMS_BUILD_WIN32
		m_vstDir = windowsConfigPath( CSIDL_PROGRAM_FILES ) +
											QDir::separator() + "VstPlugins";
#else
		m_vstDir = ensureTrailingSlash( QDir::home().absolutePath() );
#endif
	}

	if( m_flDir.isEmpty() || m_flDir == QDir::separator() )
	{
		m_flDir = ensureTrailingSlash( QDir::home().absolutePath() );
	}

	if( m_ladDir.isEmpty() || m_ladDir == QDir::separator() ||
			( !m_ladDir.contains( ':' ) && !QDir( m_ladDir ).exists() ) )
	{
#if defined(LMMS_BUILD_WIN32)
		m_ladDir = m_pluginDir + "ladspa" + QDir::separator();
#elif defined(LMMS_BUILD_APPLE)
		m_ladDir = qApp->applicationDirPath() + "/../lib/lmms/ladspa/";
#else
		m_ladDir = qApp->applicationDirPath() + '/' + LIB_DIR + "/ladspa/";
#endif
	}

#ifdef LMMS_HAVE_STK
	if( m_stkDir.isEmpty() || m_stkDir == QDir::separator() ||
			!QDir( m_stkDir ).exists() )
	{
#if defined(LMMS_BUILD_WIN32)
		m_stkDir = m_dataDir + "stk/rawwaves/";
#elif defined(LMMS_BUILD_APPLE)
		m_stkDir = qApp->applicationDirPath() + "/../share/stk/rawwaves/";
#else
		m_stkDir = "/usr/share/stk/rawwaves/";
#endif
	}
#endif


	QDir::setSearchPaths( "resources", QStringList() << artworkDir()
						<< defaultArtworkDir() );

	if( !QDir( m_workingDir ).exists() )
	{
		if( QMessageBox::question( 0,
			MainWindow::tr( "Working directory" ),
			MainWindow::tr( "The LMMS working directory %1 does not "
				"exist. Create it now? You can change the directory "
				"later via Edit -> Settings." ).arg( m_workingDir ),
					QMessageBox::Yes, QMessageBox::No ) ==
								QMessageBox::Yes )
		{
			QDir().mkpath( m_workingDir );
		}
	}
	if( QDir( m_workingDir ).exists() )
	{
		QDir().mkpath( userProjectsDir() );
		QDir().mkpath( userSamplesDir() );
		QDir().mkpath( userPresetsDir() );
	}
}
示例#6
0
int  UsrAccConfig::init(const char* cfg) {
	cfg_file(cfg);

	std::ifstream infile;
	infile.open(cfg,std::ios::in);
	std::string read_line;
	std::string read_section;
	unsigned int find_pos;
	std::string read_value;
	std::string read_key;
	if (infile.is_open()) {
		while (!infile.eof()) {
			std::getline(infile,read_line);

			if (read_line.find("#") != std::string::npos) {
				read_line.erase(read_line.find("#"));
			}

			if (read_line.find("//") != std::string::npos) {
				read_line.erase(read_line.find("//"));
			}

			if (read_line.length()==0) {continue;}


			if (read_line.find("[") != std::string::npos && read_line.find("]")!=std::string::npos) {
				read_section = read_line.substr(read_line.find("[")+1,read_line.find("]")-1);
			} else {
				if ((find_pos=read_line.find("=")) != std::string::npos) {
					if (read_section == "LoggerConfiguration") {
						deal_logger_configuration(read_line,find_pos);

						// initializing logger ...
						if (logger_config_file_ != "") {
							CommonLogger::instance().init(logger_config_file_.c_str(), "acc");
						}

					} else if (read_section == "System") {
						if (deal_system(read_line,find_pos) == -1) {
							return -1;
						}
					} else if (read_section == "AppReqServer") {
						if (deal_app_req_server(read_line,find_pos) == -1) {
							return -1;
						}
					} else if (read_section == "MEM") {
						if (deal_mem(read_line,find_pos)) {
							return -1;
						}
					} else if (read_section == "ServLogic") {
						if (deal_serv_logic(read_line,find_pos) == -1) {
							return -1;
						}
					}  else if (read_section == "FileManage") {
						if (deal_file_manage(read_line,find_pos) == -1) {
							return -1;
						}
					} else {
						printf("%s%s\n","unknown section name : ", read_section.c_str());
						return -1;
					}
				}
			}
		}

		if (logger_config_file_ == "") {
			return -1;
		}
	} else {
		printf("%s\n","failed to open the configuration file.");
		return -1;
	}
	return 0;
}
	//////////////////////////////////////////////////////////////////////////////
	/// @details    Constructor from configuration file name.
	///
	/// @param      cfg_filename  Configuration file name.
	///
	/// @post       Configuration has been loaded.
	///
	/// @exception  std::runtime_error  Configuration file could not be opened.
	///
	AppConfigReader::AppConfigReader(std::string const& cfg_filename)
		: m_cfg()
	{
		std::cout << "loading configuration from file \"" << cfg_filename << "\"" << std::endl;
		
		//  open file
		std::ifstream cfg_file(cfg_filename.c_str());
		if (! cfg_file.good())
		{
			throw std::runtime_error("failed to open config file");
		}
		
		//  process lines
		std::string line;
		unsigned int line_num = 0;
		while (std::getline(cfg_file, line))
		{
			++line_num;
			
			RemoveComment(line);
			
			std::istringstream splitter(line);
			
			//  read key (if any)
			std::string key;
			splitter >> key;
			if (0 == key.size())
			{
				continue;
			}

			//  read value (if any)
			std::string value;
			splitter >> value;

			if (0 == value.size())
			{
				std::cout << cfg_filename << ":" << line_num << ": warning: ignoring line with key but no value" << std::endl;
				std::cout << cfg_filename << ":" << line_num << ": " << line << std::endl;
				continue;				
			}
	
			//  identify which key we've just read
			if (key == "Nx")
			{
				m_cfg.m_Nx = StringToInt(value);
			}
			else if (key == "Ny")
			{
				m_cfg.m_Ny = StringToInt(value);
			}
			else if (key == "T")
			{
				m_cfg.m_T = StringToInt(value); 
			}
			else if (key == "TT")
			{
				m_cfg.m_TT = StringToInt(value);
			}
			else if (key == "r")
			{
				m_cfg.m_r = StringToDouble(value);
			}
			else if (key == "a")
			{
				m_cfg.m_a = StringToDouble(value);
			}
			else if (key == "b")
			{
				m_cfg.m_b = StringToDouble(value);
			}
			else if (key == "m")
			{
				m_cfg.m_m = StringToDouble(value);
			}
			else if (key == "k")
			{
				m_cfg.m_k = StringToDouble(value);
			}
			else if (key == "l")
			{
				m_cfg.m_l = StringToDouble(value);
			}
			else if (key == "dt")
			{
				m_cfg.m_dt = StringToDouble(value);
			}
			else
			{
				std::cout << cfg_filename << ":" << line_num << ": warning: unrecognised key name" << std::endl;
				std::cout << cfg_filename << ":" << line_num << ": " << line << std::endl;				
			}
		}
		
		m_cfg.Print();
	}